Caution: branch created from 'develop-UTC'
The first timestamp in ECMWF system5c3s total daily precipitation is one day ahead from the start date. For the start date 1st of November 1993, the first timestamp is the 2nd of November 1993.
Until now, Load interpreted that the first timestamp is equal to the start date, therefore, one day lagged observations were loaded.
To solve this issue, the code in this branch reads the first timestamp and its units. When creating the temporal indices to load in observations, the previous information is used to shift one day if necessary.
Its current status misses modifying the metadata (to do it soon).
A comparison between this code and the original Load can be done with:
source("/esarchive/scratch/nperez/git/s2dverification/R/Load.R")
source("/esarchive/scratch/nperez/git/s2dverification/R/LeapYear.R")
source('/esarchive/scratch/nperez/git/s2dverification/R/Utils.R')
library(bigmemory)
library(ncdf4)
library(plyr)
data <- Load(var = 'prlr',
exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")),
obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')),
sdates = '19931101', #paste0(1993:2018, '1101')
nmember = 25,leadtimemin = 1,
leadtimemax = NULL,
storefreq = "daily", sampleperiod = 1,
latmin = 42, latmax = 49, lonmin = 4, lonmax = 11,
output = 'lonlat', nprocs = 1,
method = 'conservative', grid = 'r360x181',
maskmod = vector("list", 15), maskobs = vector("list", 15),
configfile = NULL, varmin = NULL, varmax = NULL,
silent = FALSE, dimnames = NULL,
remapcells = 2, path_glob_permissive = 'partial',
nmemberobs = NULL, nleadtime = NULL)
dim(data$mod)
dim(data$obs)
sum(is.na(data$mod))
sum(is.na(data$obs))
s2dverification::PlotEquiMap(data$mod[1,1,1,1,,], data$lon, data$lat,
filled.continents = FALSE)
dev.new()
s2dverification::PlotEquiMap(data$obs[1,1,1,1,,], data$lon, data$lat,
filled.continents = FALSE)
data$Dates$start[1]
obs <- s2dverification::Load(var = 'prlr', exp = NULL,
obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')),
sdates = '19931101', #paste0(1993:2018, '1101')
nmember = 25,leadtimemin = 1,
leadtimemax = 2,
storefreq = "daily", sampleperiod = 1,
latmin = 42, latmax = 49, lonmin = 4, lonmax = 11,
output = 'lonlat', nprocs = 1,
method = 'conservative', grid = 'r360x181',
maskmod = vector("list", 15), maskobs = vector("list", 15),
configfile = NULL, varmin = NULL, varmax = NULL,
silent = FALSE, dimnames = NULL,
remapcells = 2, path_glob_permissive = 'partial',
nmemberobs = 1, nleadtime = NULL)
dev.new()
s2dverification::PlotEquiMap(obs$obs[1,1,1,2,,], obs$lon, obs$lat,
filled.continents = FALSE)