
library(maps)
library(s2dverification)
library(boot)
library(ncdf)
library(ncdf4)
library(abind)
library(psych)
library(startR)


# Clean memory
rm(list=ls())
gc()

# variable and obs
var   <- 'tas' 

# namelist of experiment 
nltimemin <- 1 # number of leadtimes min in the experiments (in months)
nltimemax <- 7  # number of leadtimes max in the experiments (in months)

# sequence of starting dates
date_ini = 1992
date_fin = 2018
sdates  <-  paste0(c(date_ini:date_fin), '0501')

# Region to extract -----------------------------------------------------------------
lonmin <- 0; lonmax <- 360; latmin <- -90; latmax <- 90 # WORLD

a0pe <- list(path = '/esarchive/exp/ecearth/a0pe/$STORE_FREQ$_mean/$VAR_NAME$_*/$VAR_NAME$_*_S$START_DATE$_r$MEMBER_NUMBER$i1p1_*.nc')
# a0pe <- list(path = '/esarchive/exp/ecearth/a0pe/$STORE_FREQ$_mean/$VAR_NAME$-r360*180*/$VAR_NAME$_*_S$START_DATE$_r$MEMBER_NUMBER$i1p1_*.nc')  # for sic

# EC-Earth3
exp_data4 <- Load(var, exp= list(a0pe), obs=NULL, sdates , nmember=25, output = 'lonlat',leadtimemin = nltimemin,leadtimemax = nltimemax,lonmin = lonmin, lonmax = lonmax, latmin = latmin,latmax = latmax,grid='r512x256')


