sup3r.bias.bias_transforms.get_spatial_bc_presrat

get_spatial_bc_presrat(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 PresRat for three datasets: base (historical reference), bias (historical biased reference), and bias_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:

  • dict – A dictionary containing: - base : np.array

    Parameters used to define the statistical distribution estimated for the base_dset. It has a shape of (I, J, T, P), where (I, J) are the same first two dimensions of the given lat_lon; T is time in intervals equally spaced along a year. Check cfg[‘time_window_center’] below to map each T to a day of the year; and P is the number of parameters and depends on the type of distribution. See PresRat 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, T, P), where (I, J) are the same first two dimensions of the given lat_lon; T is time in intervals equally spaced along a year. Check cfg[‘time_window_center’] to map each T to a day of the year; and P is the number of parameters and depends on the type of distribution. See PresRat 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, T, P), where (I, J) are the same first two dimensions of the given lat_lon; T is time in intervals equally spaced along a year. Check cfg[‘time_window_center’] to map each T to a day of the year; and P is the number of parameters used and depends on the type of distribution. See PresRat for more details.

    • bias_tau_fut : np.array The threshold for negligible magnitudes. Any value smaller than that should be replaced by zero to preserve the zero (precipitation) rate. I has dimension of (I, J, dummy), where (I, J) are the same first two dimensions of the given lat_lon; and a dummy 3rd dimension required due to the way sup3r saves data in an HDF.

    • k_factor : np.array The K factor used to preserve the mean rate of change from the model (see [Pierce2015]). It has a shape of (I, J, T), where (I, J) are the same first two dimensions of the given lat_lon; T is time in intervals equally spaced along a year. Check cfg[‘time_window_center’] to map each T to a day of the year.

  • 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, and cfg[‘time_window_center’] maps the dimension T in days of the year for the dimension T of the parameters above. See PresRat 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.PresRat

Estimate the statistical distributions loaded here.

References

[Pierce2015]

Pierce, D. W., Cayan, D. R., Maurer, E. P., Abatzoglou, J. T., & Hegewisch, K. C. (2015). Improved bias correction techniques for hydrological simulations of climate change. Journal of Hydrometeorology, 16(6), 2421-2442.

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")