downscaleR icon indicating copy to clipboard operation
downscaleR copied to clipboard

Error in (min(piece, na.rm = TRUE) - head):(max(piece, na.rm = TRUE)

Open cyndyfem opened this issue 3 years ago • 7 comments

Hi, I tried to bias correct CMIP6 data using era5. I tried using eqm, pqm and qdm. They all returned thesame error. Only ISIMIP3 worked. Please see the error below.

precipitation

BCC_pr_eqm <- biasCorrection(y = OBS_pr, x = BCC_pr, precipitation = TRUE,

  •                          method = "eqm", wet.threshold = 0.1, window = c(30, 15), cross.val = "kfold",
    
  •                          folds = fold, parallel=T , max.ncores=12, ncores= 16)
    

[2021-12-09 20:48:29] Trying to determine the time zone... [2021-12-09 20:48:29] Time zone identified and set to GMT See 'setGridDates.asPOSIXlt' to change the time zone [2021-12-09 20:48:29] Trying to determine the time zone... [2021-12-09 20:48:29] Time zone identified and set to GMT See 'setGridDates.asPOSIXlt' to change the time zone [2021-12-09 20:48:29] Trying to determine the time zone... [2021-12-09 20:48:29] Time zone identified and set to GMT See 'setGridDates.asPOSIXlt' to change the time zone Validation 1, 5 remaining [2021-12-09 20:48:30] Argument precipitation is set as TRUE, please ensure that this matches your data. Error in (min(piece, na.rm = TRUE) - head):(max(piece, na.rm = TRUE) + : result would be too long a vector In addition: Warning messages: 1: In array(data = c(as.numeric(yearList[seq(2, length(yearList), 3)]), : NAs introduced by coercion 2: In array(data = c(as.numeric(yearList[seq(2, length(yearList), 3)]), : NAs introduced by coercion 3: In min(indDays[indObs]) : no non-missing arguments to min; returning Inf 4: In max(indDays[indObs]) : no non-missing arguments to max; returning -Inf

cyndyfem avatar Dec 09 '21 12:12 cyndyfem

The error only occurs when the window option is used. I had a similar error and it was related to the way dates were read in biascorrection. I solved it by fixing the dates before the data are imported to biascorrection for both y and x e.g obs$Dates$start<-as.POSIXct(obs$Dates$start, tz = "GMT", format = "%Y-%m-%d") obs$Dates$end<-as.POSIXct(obs$Dates$end, tz = "GMT", format = "%Y-%m-%d")

Hopefully this will solve the issue

durutti avatar Dec 10 '21 19:12 durutti

Hi, Thank you for this reply. Yes, I have done as you suggested. It worked for some methods and did not work for some others. It was a good input. thank you. I should probably remove the window.

cyndyfem avatar Dec 13 '21 02:12 cyndyfem

Hi, I am back!!! Please, do you know how to write out the bias-corrected output from the climate4R grid to .nc for further processing? I tried to use the grid2nc function in loadeR.2nc package but it always shut down the R session. I tried it both on Ubuntu and windows but it is still the same problem. I have, however, reported this on the loadeR.2nc page but I have not gotten a reply yet. Are there alternatives?

Thanks for your assistance.

cyndyfem avatar Dec 16 '21 04:12 cyndyfem

grid2nc works fine here on two ubuntu maschines (18.04 and 20.04). If you could provide some code or the variable you want to save then I could help as a first step check the dimensions of your bias corrected data and their attributes

cheers

durutti avatar Dec 16 '21 06:12 durutti

I think the problem is related to the way you are trying to pass the varAttribute in grid2nc. change it to NULL and see if anything changes. if you still want that attribute declare it before grid2nc

e.g attr(OBS_H$Variable, "units") <- "mm/day"

durutti avatar Dec 16 '21 08:12 durutti

Thank you very much!!!

It worked now!!!

cyndyfem avatar Dec 16 '21 11:12 cyndyfem

If you do not mind, maybe we could have some collaborations? You have solved my problem!!!

cyndyfem avatar Dec 16 '21 11:12 cyndyfem