improver.generate_ancillaries.generate_topographic_zone_weights module

Module for generating the weights for topographic zones.

class GenerateTopographicZoneWeights[source]

Bases: BasePlugin

Generate weights generated by determining where the orography lies within the topographic zones.

_abc_impl = <_abc_data object>
static add_weight_to_lower_adjacent_band(topographic_zone_weights, orography_band, midpoint, band_number)[source]

Once we have found the weight for a point in one band, we need to add 1-weight to the band below for points that are below the midpoint, unless the band being processed is the lowest band.

Parameters:
  • topographic_zone_weights (ndarray) – Weights that we have already calculated for the points within the orography band.

  • orography_band (ndarray) – All points within the orography band of interest.

  • midpoint (float) – The midpoint of the band the point is in.

  • band_number (float) – The index that corresponds to the band that is currently being processed.

Return type:

ndarray

Returns:

Topographic zone array containing the weights that we have already calculated for the points within the orography band that has been updated to account for the lower adjacent band.

static add_weight_to_upper_adjacent_band(topographic_zone_weights, orography_band, midpoint, band_number, max_band_number)[source]

Once we have found the weight for a point in one band, we need to add 1-weight to the band above for points that are above the midpoint, unless the band being processed is the uppermost band.

Parameters:
  • topographic_zone_weights (ndarray) – Weights that we have already calculated for the points within the orography band.

  • orography_band (ndarray) – All points within the orography band of interest.

  • midpoint (float) – The midpoint of the band the point is in.

  • band_number (float) – The index that corresponds to the band that is currently being processed.

  • max_band_number (float) – The highest index for the bands coordinate in the weights.

Return type:

ndarray

Returns:

Weights that we have already calculated for the points within the orography band that has been updated to account for the upper adjacent band.

static calculate_weights(points, band)[source]

Calculate weights where the weight at the midpoint of a band is 1.0 and the weights at the edge of the band is 0.5. The midpoint is assumed to be in the middle of the band.

Parameters:
  • points (ndarray) – The points at which to find the weights. e.g. np.array([125]) or np.array([125, 140]).

  • band (List[float]) – The band to be used for determining the weight that the selected points should have within the band e.g. [100., 200.].

Return type:

ndarray

Returns:

The weights generated to indicate the contribution of each point to a band.

process(orography, thresholds_dict, landmask=None)[source]

Calculate the weights depending upon where the orography point is within the topographic zones.

Parameters:
  • orography (Cube) – Orography on standard grid.

  • thresholds_dict (Dict[str, List[float]]) – Definition of orography bands required. The expected format of the dictionary is e.g. {‘bounds’: [[0, 50], [50, 200]], ‘units’: ‘m’}

  • landmask (Optional[Cube]) – Land mask on standard grid, with land points set to one and sea points set to zero. If provided sea points are masked out in the output array.

Return type:

Cube

Returns:

Cube containing the weights depending upon where the orography point is within the topographic zones.