CST_RFSlope shows error: 0 (non-NA) cases
Hi @jhardenberg and @silvia,
As you know I am preparing the CSTools manuscript and I was doing some checks to ensure that everything is fine.
I have created this code to compute the Slope by months:
library(CSTools)
era5 <- list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_*/$VAR_NAME$_$YEAR$$MONTH$.nc')
years <- unlist(lapply(1993:2018, function(x){paste0(x, sprintf("%02d",1:12), '01')}))
era5 <- CST_Load(var = 'prlr', exp = list(era5), sdates = years, nmember = 1,
storefreq = "daily", sampleperiod = 1,
latmin = 37.5, latmax = 53.25, lonmin = 2.5, lonmax = 18.25,
output = 'lonlat', nprocs = 1)
era5 <- CST_SplitDim(era5, split_dim = 'sdate', indices = rep(1:12, 26))
slope <- CST_RFSlope(era5, time_dim = c('sdate', 'ftime'), kmin = 7)
However, I get the following error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
The function stops running in the second loop which corresponds to February, so, I thought it may be due to NA values. I have kept looking at the data, and the NA values seem not to be the problem but the nature of the data:
> .RFSlope(data[1,1,,,2,1:200], kmin = 7)
lat lon rainfarm_samples
56 56 200
log(k[kmin:kmax])
2.231256
> .RFSlope(data[1,1,,,2,1:750], kmin = 7)
lat lon rainfarm_samples
56 56 750
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
> .RFSlope(data[1,1,,,2,1:720], kmin = 7)
lat lon rainfarm_samples
56 56 720
log(k[kmin:kmax])
2.152069
So, it converges to a result for 200 and 720 rainfarm_samples but it fails for 750 or the full samples 806.
Do you know if I am doing something wrong or could this error being avoided?
Thanks,
Núria