Can longitudes of HadISST be shifted to fit those of experiment?
Hi @aho,
I want to load HadISST dataset with StartR to compare then the data with my experiments. The problem is that the longitudes of HadISST are from -179.5 to 179.5 (Note the 0.5 shifted longitudes).
I can shift the longitudes after the loading process, but I was wondering if I cannot make this transformation inside the load function with CDORemap. But I haven't been successful so far.
My code is:
path_obs <- paste0('/esarchive/obs/ukmo/hadisst_v1.1/monthly_mean/tos/$var$_$date$.nc')
data_obs_retrieve <- startR::Start(dat = path_obs,
var = 'tos',
date = dates_files,
time = values(dates_v2),
lat = values(list(lat_min, lat_max)),
lon = values(list(-180, 179.5)),
time_var = 'time',
time_across = 'date',
merge_across_dims = TRUE,
merge_across_dims_narm = TRUE,
split_multiselected_dims = TRUE,
transform = startR::CDORemapper,
transform_extra_cells = 2,
transform_params = list(grid = 'r360x180',
method = 'conservative',
crop = c(-180, 179.5,
-90, 90)),
transform_vars = c('lat', 'lon'),
synonims = list(lon = c('lon', 'longitude'),
lat = c('lat', 'latitude')),
return_vars = list(lat='dat',
lon='dat',
time=c('date')),
lon_reorder = CircularSort(-180,180),
lat_reorder = Sort(decreasing = F),
retrieve = T)
lat_obs = as.vector(attr(data_obs_retrieve, 'Variables')$dat1$lat)
lon_obs = as.vector(attr(data_obs_retrieve, 'Variables')$dat1$lon)
with dates_files
and dates_v2
coming from the loading of the experiment:
path <- paste0('/esarchive/exp/ecearth/a35b/diags/DCPP/EC-Earth-Consortium/EC-Earth3-HR/dcppA-hindcast/$memb$/Omon/$var$/r360x180/v*/$var$_Omon_EC-Earth3-HR_dcppA-hindcast_s$sdate$-$memb$_r360x180_$chunk$.nc',sep='')
lat_min <- -90
lat_max <- 90
lon_min_exp <- 0
lon_max_exp <- 359.9
membs <- c('r1i1p1f1','r2i1p1f1','r3i1p1f1','r4i1p1f1','r5i1p1f1')
startdates <- c('1993','1995','1998','2000','2003','2005','2008','2010','2013')
forecast_month <- c(11,12,1,2)
data_exp_retrieve <- startR::Start(dat = path,
var = vari,
memb = membs,
sdate = startdates, #paste(seq(yr1,yr2)),
chunk = 'all',
time = c(1:length(forecast_month)),
chunk_depends = 'sdate',
time_across = 'chunk',
merge_across_dims = TRUE,
lat = values(list(lat_min, lat_max)),
lat_reorder = Sort(),
lon = values(list(lon_min_exp, lon_max_exp)),
lon_reorder = CircularSort(-180,180),
synonims = list(lon = c('lon', 'longitude'),
lat = c('lat', 'latitude')),
return_vars = list(time= c('sdate','chunk'), # c('sdate'),
lat='dat',
lon='dat'),
retrieve = T)
dates_to_use <- attr(data_exp_retrieve, 'Variables')$common$time
dates_v2 = dates_to_use[,,1]
names(dim(dates_v2)) = c("sdate","time")
dates_files <- sort(unique(gsub('-', '', sapply(as.character(dates_to_use), substr, 1, 7))))
I hope I don't forget to indicate any variable ;)
If you could give me a hand!
Thanks