Start and CST_Load return different values (transform)
I found the values loaded from Start are different from those from CST_Load. Please see the following testing codes.
# This script compares the SEAS5 prlr outputs from CST_Load and startR
rm(list = ls())
library(startR)
library(CSTools)
library(s2dv)
# startR
path.exp <- '/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_s0-24h/$var$_$sdate$.nc'
y1 <- 1981
y2 <- 2016
mon <- c(12, 3, 6, 8)
seasons <- c('DJF', 'MAM', 'JJA', 'SON')
leadtimemin <- 1; leadtimemax <- 3
# SA domain
lons.min <- 0
lons.max <- 60
lats.min <- -40
lats.max <- 10
season <- 1
var <- 'prlr'
ini_month <- sprintf("%02d", mon[season])
sdate <- paste0(y1:y2, ini_month, '01')
data <- Start(data = path.exp, var = var, sdate = sdate,
member = 1, time = leadtimemin:leadtimemax,
longitude = values(list(lons.min, lons.max)),
latitude = values(list(lats.min, lats.max)),
return_vars = list(latitude = 'data', longitude = 'data', time = 'sdate'),
synonims = list(latitude = c('lat', 'latitude'), longitude = c('lon', 'longitude'),
member = c('member', 'ensemble')),
transform = CDORemapper,
transform_params = list(grid = 'r1440x721',
method = 'bicubic',
crop = c(lons.min, lons.max, lats.min, lats.max)),
transform_vars = c('latitude', 'longitude'),
retrieve = TRUE)
##############################################################
# CST_Load
path.exp <- c('/esarchive/exp/ecmwf/system5c3s/monthly_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$YEAR$$MONTH$01.nc')
data1 <- CST_Load(var = var, exp = list(list(path = path.exp)),
sdates = sdate, nmember = 1,
leadtimemin = 1, leadtimemax = 3, output = 'lonlat',
storefreq = 'monthly',
latmin = lats.min, latmax = lats.max,
lonmin = lons.min, lonmax = lons.max,
grid = "r1440x721", method = 'bicubic')
# check
as.numeric(attributes(data)$Variables$dat1$longitude)
as.numeric(attributes(data)$Variables$dat1$latitude)
data[1,1,,1,1,1,1]
data1$lon
data1$lat
data1$data[1,1,,1,1,1]
The longitude and latitude are identical (with flipped latitude though), but the prlr is quite different:
> data1$data[1,1,,1,1,1]
[1] 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
[7] 4.5576e-11 0.0000e+00 0.0000e+00 1.8230e-10 0.0000e+00 0.0000e+00
...
> data[1,1,,1,1,1,1]
[1] 2.002488e-08 2.423495e-08 3.495666e-08 1.409433e-08 2.392731e-08
[6] 3.876224e-08 3.320200e-08 2.134658e-08 2.342598e-08 2.682708e-08
...
Did I do something wrong with the data loading?
I saw another issue discussing the influence of the consecutive interpolation method on the output, is it something related to the difference in the CDORemapper used between the two functions?
Could you please help with this? Thank you.
Best, Chung