sup3r.bias.utilities.qdm_bc#
- qdm_bc(handler, bc_files, bias_feature, relative=True, threshold=0.1, no_trend=False, delta_denom_min=None, delta_denom_zero=None, delta_range=None, out_range=None, max_workers=1)[source]#
Bias Correction using Quantile Delta Mapping
Bias correct this DataHandler’s data with Quantile Delta Mapping. The required statistical distributions should be pre-calculated using
sup3r.bias.bias_calc.QuantileDeltaMappingCorrection
.Warning: There is no guarantee that the coefficients from
bc_files
match the resource processed here. Be careful choosingbc_files
.- Parameters:
handler (DataHandler) – DataHandler instance with .data attribute containing data to bias correct
bc_files (list | tuple | str) – One or more filepaths to .h5 files output by
bias_calc.QuantileDeltaMappingCorrection
. These should contain datasets named “base_{bias_feature}_params”, “bias_{feature}_params”, and “bias_fut_{feature}_params” where {feature} is one of the features contained by this DataHandler and the data is a 3D array of shape (lat, lon, time) where time.bias_feature (str) – Name of the feature used as (historical) reference. Dataset with name “base_{bias_feature}_params” will be retrieved from
bc_files
.relative (bool, default=True) – Switcher to apply QDM as a relative (use True) or absolute (use False) correction value.
threshold (float, default=0.1) – Nearest neighbor euclidean distance threshold. If the DataHandler coordinates are more than this value away from the bias correction lat/lon, an error is raised.
no_trend (bool, default=False) – An option to ignore the trend component of the correction, thus resulting in an ordinary Quantile Mapping, i.e. corrects the bias by comparing the distributions of the biased dataset with a reference datasets. See
params_mf
ofrex.utilities.bc_utils.QuantileDeltaMapping
. Note that this assumes that “bias_{feature}_params” (params_mh
) is the data distribution representative for the target data.delta_denom_min (float | None) – Option to specify a minimum value for the denominator term in the calculation of a relative delta value. This prevents division by a very small number making delta blow up and resulting in very large output bias corrected values. See equation 4 of Cannon et al., 2015 for the delta term.
delta_denom_zero (float | None) – Option to specify a value to replace zeros in the denominator term in the calculation of a relative delta value. This prevents division by a very small number making delta blow up and resulting in very large output bias corrected values. See equation 4 of Cannon et al., 2015 for the delta term.
delta_range (tuple | None) – Option to set a (min, max) on the delta term in QDM. This can help prevent QDM from making non-realistic increases/decreases in otherwise physical values. See equation 4 of Cannon et al., 2015 for the delta term.
out_range (None | tuple) – Option to set floor/ceiling values on the output data.
max_workers (int | None) – Max number of workers to use for QDM process pool