import moviepy.video.io.ImageSequenceClip
import os
Var="DHW"
ssp=("ssp585")
model=("BCC-CSM2-MR","CESM2","CanESM5","IPSL-CM6A-LR","MIROC6","NorESM2-MM","MRI-ESM2-0","EC-Earth3","ensemble5","ensemble8")
Colormaps=["RdYlBu"]#'Spectral','ocean',"coolwarm",
for Colormap in Colormaps:
    for i in ssp:
        for j in model:
            ListY=[]
            path="Videos/Animated_%s_%s_%s_%s_ON"%(Colormap,Var,i,j)+".webm"
            isFile = os.path.isfile(path)
            if isFile:
                print(" Ya existe "+ path)
                continue
            for year in range(1986,2101):
                ListY.append('./ConCoralN/%s_%s_%s_%s_DHW_%s.png'%(Colormap,Var,i,j,year))
            print("%s_%s_%s_%s_ON"%(Colormap,Var,i,j))    
            movie_clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(ListY, 2)
            movie_clip.write_videofile(path)
            
Var="DHW"
ssp=("ssp245","ssp370","ssp585")
model=("ensemble5","ensemble8","BCC-CSM2-MR","CESM2","CanESM5","EC-Earth3","IPSL-CM6A-LR","MIROC6","MRI-ESM2-0","NorESM2-MM")
Colormaps=["noaa"]
for Colormap in Colormaps:
    for i in ssp:
        for j in model:
            ListY=[]
            for year in range(1986,2101):
                ListY.append('ConCoralN/%s_%s_%s_%s_DHW_%s.png'%(Colormap,Var,i,j,year))
            movie_clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(ListY, 2)
            movie_clip.write_videofile("Videos/Animated_%s_%s_%s_%s_ON"%(Colormap,Var,i,j)+".webm")

