Hi @jhardenberg!
I have created function CST_QuantileMapping based on qmap package. I have selected this package because it allows using different methodologies for the quantile mapping adjustment and it is the one used in ADAMONT. Furthermore, it has multiple references and it was used in the publication "Bias Correction of GCM Precipitation by Quantile Mapping: How Well Do Methods Preserve Changes in Quantiles and Extremes?"(2015).
The function structure is the expected for CSTools package:
- CST_QuantileMapping working on 's2dv_cube' objects
- QuantileMapping working in arrays with multiple dimensions (and calling multiApply::Apply)
- a basic function 'qmapcor' which performs the computation in the minimum number of dimensions
The function allows to provide a hindcast in 'exp' and historical observation in 'obs' and, if needed, a forecast in 'exp_cor' in which the correction will be applied. It also contains two important parameters implemented by myself:
-
one to select the length of the sample on time dimension using
sample_length
parameter (if the drift changes along the timeseries the correction captures the change and, if the forecast is longer than the hindcast, the correction of the latest sample is reused) -
another to select the dimensions to use in the sample defining
sample_dimensions
parameter (for instance, a user may consider part of the sample all start date and members or may prefer to correct them separately, by default the first case is considered)
I am in the testing phase now (I need to focus in the sample_dimesnions
parameter) but if you want to give me early feedback it would be great! I also attached a draft of the file I am using to test the functions CST_QM_test2.R
Thanks in advance!
Núria