import iris
from esmvalcore.preprocessor import climate_statistics, extract_time
import glob
import matplotlib.pyplot as plt
import iris.analysis.stats
import iris.analysis.cartography
from matplotlib.gridspec import GridSpec 
import iris.plot as iplt
import iris.quickplot as qplt
import cartopy.crs as ccrs
import cartopy

path = "/esarchive/scratch/jcos/output/recipe_decadal_constrains_20220718_053727/preproc/constr_s1961/tos_dple/"
file_paths = glob.glob(f"{path}*.nc")
file_paths.sort()

for file in file_paths:
    cube = iris.load_cube(file)[0]
    print(file)
    plt.figure()
    qplt.pcolormesh(cube)
    plt.gca().coastlines()
    plt.savefig(file.replace(".nc", ".png"))
    
