Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in grid$Data[i, , ind.NN.y[k, l], ind.NN.x[k, l]] : incorrect number of dimensions #89

Open
catorpar opened this issue Mar 16, 2022 · 5 comments

Comments

@catorpar
Copy link

Hello,

I'm trying to conduct a bias correction but I'm getting the following error:

Error in grid$Data[i, , ind.NN.y[k, l], ind.NN.x[k, l]] : incorrect number of dimensions

I used loadeR to upload the observed and GCM datasets, then defined the x, y and newdata variables and run the biasCorrection function as indicated by example, and that's when the error occurs.

`obsdata <- "~/Future Climate Analysis/Observed"
Obs <- loadStationData(dataset = obsdata, var="precip", stationID = NULL)
gcmdata <- "~Future Climate Analysis/GCM"
GCM <- loadStationData(dataset = gcmdata, var="precip", stationID = NULL)
ObsTrain <- subsetGrid(Obs,years = 2006:2010, station.id = "26130570")
GCMTrain <- subsetGrid(GCM,years = 2006:2010, station.id = "cam_44")
GCMTest <- subsetGrid(GCM,years= 2011:2015, station.id = "cam_44")
x <- ObsTrain
y <- GCMTrain
newdata <- GCMTest

biasCorrection(x, y, newdata = newdata, precipitation = TRUE, method = "eqm", window=NULL, wet.threshold = 0.1, join.members = TRUE)
`
Attached you can find the files I'm using to complete the bias correction.

GCM.zip
Observed.zip

Any help will be greatly appreciate it.

Camilo

@dsys2003
Copy link

If you want to use biasCorrection, you must use aggr.d or aggr.m, this is a bug.

@durutti
Copy link

durutti commented May 7, 2022

For me, the version that doesn't give the error when using locations is downscaleR-3.3.2. So you can install it locally until the bug is fixed

@miturbide
Copy link
Member

We have included a step in biasCorrection to ensure the correspondence of dates between observed and simulated data in the training period. However, this new implementation (in the transformeR package) was not adapted to single station data in its first version... it is now, in the development version of transformeR.

You can install this version as follows:

library(devtools)
install_github("SantanderMetGroup/transformeR@devel")

@durutti
Copy link

durutti commented May 9, 2022

Yes it works now !!!
I think a minor change is needed in line 8 in setGridDates.asPOSIXlt
if (length(strsplit(ref, "-")[[1]]) == 3) chnage to
if (length(strsplit(as.character(ref), "-")[[1]]) == 3)

example

d<-as.POSIXlt(as.Date('2000-1-1'))
s<-strsplit(d, "-")
Error in strsplit(d, "-") : non-character argument

s<-strsplit(as.character(d), "-")

length(s[[1]])==3
[1] TRUE

Thank you very much for your efforts

@miturbide
Copy link
Member

miturbide commented May 9, 2022

Thanks durutti, good point. Line 8 has been updated in the devel branch following your suggestion. Now the function works with date class objects too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants