Closed cyndyfem closed 5 years ago
In addition, when I tried using the biasCorrection function, I got the error
Error in if (nrow(aux.ind)) if (!is.matrix(coords)) { : argument is of length zero
Hi @cyndyfem,
Could you please post the result of applying function str()
to your data?
HI @miturbide please, see the results below
str(x) 'data.frame': 9855 obs. of 14 variables: $ X65046: num 0 0 0 0 0 0 0 0 0 0 ... $ X65064: num 0 0 0 0 0 0 0 0 0 0 ... $ X65055: num 0 0 0 0 0 0 0 0 0 0 ... $ X65134: num 0 0 0 0 0 0 0 0 0 0 ... $ X61085: num 0 0 0 0 0 0 0 0 0 0 ... $ X61045: num 0 0 0 0 0 0 0 0 0 0 ... $ X61090: num 0 0 0 0 0 0 0 0 0 0 ... $ X61091: num 0 0 0 0 0 0 0 0 0 0 ... $ X61096: num 0 0 0 0 0 0 0 0 0 0 ... $ X65073: num 0 0 0 0 0 0 0 0 0 0 ... $ X65028: num 0 0 0 0 0 0 0 0 0 0 ... $ X65019: num 0 0 0 0 0 0 0 0 0 0 ... $ X65075: num 0 0 0 0 0 0 0 0 0 0 ... $ X65082: num 0 0 0 0 0 0 0 0 0 0 ...
str(y) 'data.frame': 9855 obs. of 14 variables: $ X65046: num 0 0 0 0 0 0 0 0 0 0 ... $ X65064: num 0 0 0 0 0 0 0 0 0 0 ... $ X65055: num 0 0 0 0 0 0 0 0 0 0 ... $ X65134: num 0 0 0 0 0 0 0 0 0 0 ... $ X61085: num 0 0 0 0 0 0 0 0 0 0 ... $ X61045: num 0 0 0 0 0 0 0 0 0 0 ... $ X61090: num 0 0 0 0 0 0 0 0 0 0 ... $ X61091: num 0 0 0 0 0 0 0 0 0 0 ... $ X61096: num 0 0 0 0 0 0 0 0 0 0 ... $ X65073: num 0 0 0 0 0 0 0 0 0 0 ... $ X65028: num 0 0 0 0 0 0 0 0 0 0 ... $ X65019: num 0 0 0 0 0 0 0 0 0 0 ... $ X65075: num 0 0 0 0 0 0 0 0 0 0 ... $ X65082: num 0 0 0 0 0 0 0 0 0 0 ...
Is these data for a single station or for 14 stations?
If the case is the latter, you could apply biasCorrection1D
for each of the columns in your data in a loop (your data is 2D).
Please note that function biasCorrection
only works with "climate4R grids": https://github.com/SantanderMetGroup/loadeR/wiki
@miturbide thanks for your reply. Yes, the situation is for the later. Okay, I would like to give an example for just a single station.
Sys.setenv(JAVA_HOME='C:\Program Files\Java\jdk1.7.0_80\jre') library(downscaleR) library(loadeR)
x<-read.csv("prc.txt",header=TRUE) x<-data.frame(x[,1]) y<-read.csv("D:/Cordex/Hist/Historical/prc.txt",header=TRUE) y<-data.frame(y[,1])
BC <- biasCorrection1D(o=x, p = y,s = y,precip = TRUE,method = "eqm", extrapolation = "constant",pr.threshold = 0.1)
Error in biasCorrection1D(o = x, p = y, s = y, precip = TRUE, method = "eqm", : could not find function "biasCorrection1D"
I have successfully used the biasCorrection function with climate4R grids, but the biasCorrection1D function is not working for my new experiment.
biasCorrection1D
is an internal function. Internal functions in R need to be called in this form:
package:::function()
As described in the help documentation, in downscaleR, internal functions for bias correction work with vectors (1D data). A data.frame is a 2D object, thus, when you run e.g. y <- data.frame(y[,1])
you are creating a 2D object, you should simply use y <- y[,1]
.
I recommend you to use the internal function eqm
for this specific case, otherwise (using biasCorrection1D) you have to set parameters for other methods. For instance:
data("EOBS_Iberia_pr")
data("CORDEX_Iberia_pr")
y <- VALUE_Iberia_pr$Data[,1]
x <- CORDEX_Iberia_pr$Data[, 4, 7]
class(x) # numeric
class(y) # numeric
eqm1 <- downscaleR:::eqm(o = y, p = x, s = x,
precip = TRUE,
pr.threshold = 1,
extrapolation = "constant",
n.quantiles = 100)
ok. Thank you. It worked
Hi, I have an extracted gridded data for one station. I want to bias correct the extracted station using an observed data. I used the biasCorrection1D command but it did not work. I am not trying to bias-correct the grids but only bias- correcting and extracted grid data. Is there an option to do this in downscaleR since it seems the function biasCorrection1D does not seem to work anymore. Thanks!