sup3r.bias.bias_transforms.get_spatial_bc_quantiles
- get_spatial_bc_quantiles(lat_lon: array, base_dset: str, feature_name: str, bias_fp: str, threshold: float = 0.1)[source]
Statistical distributions previously estimated for given lat/lon points
Recover the parameters that describe the statistical distribution previously estimated with
QuantileDeltaMappingCorrection
for three datasets:base
(historical reference),bias
(historical biased reference), andbias_fut
(the future biased dataset, usually the data to correct).- Parameters:
lat_lon (ndarray) – Array of latitudes and longitudes for the domain to bias correct (n_lats, n_lons, 2)
base_dset (str) – Name of feature used as historical reference. A Dataset with name “base_{base_dset}_params” will be retrieved from
bias_fp
.feature_name (str) – Name of the feature that is being corrected. Datasets with names “bias_{feature_name}_params” and “bias_fut_{feature_name}_params” will be retrieved from
bias_fp
.bias_fp (str) – Filepath to bias correction file from the bias calc module. Must have datasets “base_{base_dset}_params”, “bias_{feature_name}_params”, and “bias_fut_{feature_name}_params” that define the statistical distributions.
threshold (float) – Nearest neighbor euclidean distance threshold. If the coordinates are more than this value away from the bias correction lat/lon, an error is raised.
- Returns:
params (dict) – A dictionary collecting the following parameters: - base : np.array
Parameters used to define the statistical distribution estimated for the
base_dset
. It has a shape of (I, J, P), where (I, J) are the same first two dimensions of the given lat_lon and P is the number of parameters and depends on the type of distribution. SeeQuantileDeltaMappingCorrection
for more details.bias : np.array Parameters used to define the statistical distribution estimated for (historical)
feature_name
. It has a shape of (I, J, P), where (I, J) are the same first two dimensions of the given lat_lon and P is the number of parameters and depends on the type of distribution. SeeQuantileDeltaMappingCorrection
for more details.bias_fut : np.array Parameters used to define the statistical distribution estimated for (future)
feature_name
. It has a shape of (I, J, P), where (I, J) are the same first two dimensions of the given lat_lon and P is the number of parameters used and depends on the type of distribution. SeeQuantileDeltaMappingCorrection
for more details.
cfg (dict) – Metadata used to guide how to use of the previous parameters on reconstructing the statistical distributions. For instance, cfg[‘dist’] defines the type of distribution. See
QuantileDeltaMappingCorrection
for more details, including which metadata is saved.
Warning
Be careful selecting which bias_fp to use. In particular, if “bias_fut_{feature_name}_params” is representative for the desired target period.
See also
sup3r.bias.qdm.QuantileDeltaMappingCorrection
Estimate the statistical distributions loaded here.
Examples
>>> lat_lon = np.array([ ... [39.649033, -105.46875 ], ... [39.649033, -104.765625]]) >>> params, cfg = get_spatial_bc_quantiles( ... lat_lon, "ghi", "rsds", "./dist_params.hdf")