sup3r.bias.bias_transforms.local_linear_bc

sup3r.bias.bias_transforms.local_linear_bc#

local_linear_bc(data, lat_lon, feature_name, bias_fp, lr_padded_slice=None, out_range=None, smoothing=0)[source]#

Bias correct data using a simple annual (or multi-year) *scalar +adder method on a site-by-site basis.

Parameters:
  • data (np.ndarray) – Sup3r input data to be bias corrected, assumed to be 3D with shape (spatial, spatial, temporal) for a single feature.

  • lat_lon (ndarray) – Array of latitudes and longitudes for the domain to bias correct (n_lats, n_lons, 2)

  • feature_name (str) – Name of feature that is being corrected. Datasets with names “{feature_name}_scalar” and “{feature_name}_adder” will be retrieved from bias_fp.

  • bias_fp (str) – Filepath to bias correction file from the bias calc module. Must have datasets “{feature_name}_scalar” and “{feature_name}_adder” that are the full low-resolution shape of the forward pass input that will be sliced using lr_padded_slice for the current chunk.

  • lr_padded_slice (tuple | None) – Tuple of length four that slices (spatial_1, spatial_2, temporal, features) where each tuple entry is a slice object for that axes. Note that if this method is called as part of a sup3r forward pass, the lr_padded_slice will be included in the kwargs for the active chunk. If this is None, no slicing will be done and the full bias correction source shape will be used.

  • out_range (None | tuple) – Option to set floor/ceiling values on the output data.

  • smoothing (float) – Value to use to smooth the scalar/adder data. This can reduce the effect of extreme values within aggregations over large number of pixels. This value is the standard deviation for the gaussian_filter kernel.

Returns:

out (np.ndarray) – out = data * scalar + adder