improver.utilities.rescale module¶
Provides support utility for rescaling data.
-
improver.utilities.rescale.apply_double_scaling(data_cube, scaled_cube, data_vals, scaling_vals, combine_function=<ufunc 'minimum'>)[source]¶ From data_cube, an array of limiting values is created based on a linear rescaling from three data_vals to three scaling_vals. The three values refer to a lower-bound, a mid-point and an upper-bound. This rescaled data_cube is combined with scaled_cube to produce an array containing either the higher or lower value as needed.
- Parameters
data_cube (iris.cube.Cube) – Data from which to create a rescaled data array
scaled_cube (iris.cube.Cube) – Data already in the rescaled frame of reference which will be combined with the rescaled data_cube using the combine_function.
data_vals (tuple of three values) – Lower, mid and upper points to rescale data_cube from
scaling_vals (tuple of three values) – Lower, mid and upper points to rescale data_cube to
(Callable[[numpy.ndarray, numpy.ndarray], (combine_function) –
numpy.ndarray]) – Function that takes two arrays of the same shape and returns one array of the same shape. Expected to be numpy.minimum (default) or numpy.maximum.
- Returns
Output data from data_cube after rescaling and combining with scaled_cube. This array will have the same dimensions as scaled_cube.
- Return type
-
improver.utilities.rescale.rescale(data, data_range=None, scale_range=(0.0, 1.0), clip=False)[source]¶ Rescale data array so that data_min => scale_min and data_max => scale max. All adjustments are linear
- Parameters
data (numpy.ndarray) – Source values
data_range (list) – List containing two floats Lowest and highest source value to rescale. Default value of None is converted to [min(data), max(data)]
scale_range (list) – List containing two floats Lowest and highest value after rescaling. Defaults to (0., 1.)
clip (bool) – If True, points where data were outside the scaling range will be set to the scale min or max appropriately. Default is False which continues the scaling beyond min and max.
- Returns
Output array of scaled data. Has same shape as data.
- Return type