error in loading obs: Error in if (ori_month <= 2) { : missing value where TRUE/FALSE needed
hi @aho ,
I have this error
Error in if (ori_month <= 2) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: ! Warning: Parameter 'pattern_dims' not specified. Taking the first dimension,
! 'dat' as 'pattern_dims'.
2: ! Warning: Could not find any pattern dim with explicit data set descriptions (in
! the form of list of lists). Taking the first pattern dim, 'dat', as
! dimension with pattern specifications.
3: ! Warning: Found specified values for dimension 'lat' but no 'lat_var' requested.
! "lat_var = 'lat'" has been automatically added to the Start call.
4: ! Warning: Found specified values for dimension 'lon' but no 'lon_var' requested.
! "lon_var = 'lon'" has been automatically added to the Start call.
5: In NcDataReader(file_path, file_object, list(var = var_name), NULL, :
NAs introduced by coercion
when trying to load obs based on metadata from exps for a period 1981-2016
. The strange thing is that for a shorter period, like 1981-2000
this works fine.
The code is
# Delete previous data
rm(list=ls())
gc()
library(boot)
library(s2dv)
library(s2dverification)
library(startR)
library(ncdf4)
library(multiApply)
library(SpecsVerification)
# ATL
lonmin <- -80
lonmax <- 50
latmin <- -60
latmax <- 50
sdates <- paste0(c(1981:2016), '0501')
#sdates.test <- paste0(c(1981:2015), '0501')
# exp
repos_a33d <- paste0('/esarchive/scratch/eexarcho/Eleftheria/TRIATLAS/Analysis_a33d_a33e_a33f/',
'Data/a33d/$var$/',
'$var$_Amon_EC-Earth3-CC_historical_S$sdate$_$member$_gr_$chunk$.nc')
a33d <- Start(dat = repos_a33d,
var = 'tos',
member = 'all',
sdate = sdates,
chunk = 'all',
# time = 'all',
time = indices(1:12), #first time step per day
chunk_depends = 'sdate',
time_across = 'chunk',
merge_across_dims = TRUE,
lat = values(list(latmin, latmax)),
lat_reorder = Sort(), ##1
lon = values(list(lonmin, lonmax)),
lon_reorder = CircularSort(-180, 180),
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(lon = 'dat',
lat = 'dat',
time = 'sdate'),
retrieve = T)
lons <- as.vector(attr(a33d, 'Variables')$dat1$lon)
lats <- as.vector(attr(a33d, 'Variables')$dat1$lat)
dates <- attr(a33f, 'Variables')$common$time
dates_file <- sort(unique(gsub('-', '', sapply(as.character(dates), substr, 1, 7))))
obs.data <- Start(dat = repos_obs,
var = 'tos',
date = dates_file,
# time = 'all',
# time_across = 'date',
# merge_across_dims = TRUE,
# merge_across_dims_narm = TRUE,
## -----------------------------------------------------------------------
time = values(dates), #dim: [sdate = 2, time = 12]
#because time is assigned by 'values', set the tolerance to avoid too distinct match
time_var = 'time',
# time_tolerance = as.difftime(372, units = 'hours'),
#time values are across all the files
time_across = 'date',
#combine time and file_date dims
merge_across_dims = TRUE,
#exclude the additional NAs generated by merge_across_dims
merge_across_dims_narm = TRUE,
#split time dim, because it is two-dimensional
split_multiselected_dims = TRUE,
## -----------------------------------------------------------------------
lat = values(lats),
lon = values(lons),
#---------transform to get identical lat and lon------------ ##4
transform = CDORemapper,
transform_extra_cells = 2,
transform_params = list(grid = 't170grid',
method = 'conservative',
crop = c(lonmin, lonmax, latmin, latmax)),
transform_vars = c('lat', 'lon'),
#-----------------------------------------------------------
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(lat = NULL, ##3
lon = NULL, ##3
time = 'date'),
retrieve = TRUE)
thanks!