import os
import glob
from PIL import Image

ssp=["ssp245","ssp370","ssp585"]
model=("BCC-CSM2-MR","CESM2","CanESM5","EC-Earth3","IPSL-CM6A-LR","MIROC6","MRI-ESM2-0","NorESM2-MM","ensemble5","ensemble8")
Colorpalete=["RdYlBu",'Spectral','ocean',"coolwarm","noaa"]
ExportDirectory="img/"
DataDirectory="../Data/"
listEval=[]
for i in ssp:
    for j in model:
        Var="DHW"
        ff=DataDirectory+"%s_%s_%s_DHW.nc"%(Var,i,j)
        for CM in Colorpalete:
            for countyear in range(115):
                year=1986
                Evaluado=ExportDirectory+"%s_%s"%(CM,ff.split("/")[-1].replace(".nc","_%s.png"%(year+countyear)))
                listEval.append(Evaluado)
A1=set(listEval)
for name in glob.glob(ExportDirectory+"*.png"): 
    if name not in A1:
        try:
            im = Image.open(name)
        except:
            if os.path.exists(name):
                os.remove(name)
            
        print(name) 
