improver.generate_ancillaries.generate_ancillary module¶
Module containing ancillary generation utilities for Improver
-
class
improver.generate_ancillaries.generate_ancillary.CorrectLandSeaMask[source]¶ Bases:
improver.BasePluginRound landsea mask to binary values
Corrects interpolated land sea masks to boolean values of False [sea] and True [land].
-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 213¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
static
process(standard_landmask)[source]¶ - Read in the interpolated landmask and round values < 0.5 to False
and values >=0.5 to True.
- Parameters
standard_landmask (iris.cube.Cube) – input landmask on standard grid.
- Returns
output landmask of boolean values.
- Return type
-
-
class
improver.generate_ancillaries.generate_ancillary.GenerateOrographyBandAncils[source]¶ Bases:
improver.BasePluginGenerate topographic band ancillaries for the standard grids.
Reads orography files, then generates binary mask of land points within the orography band specified.
-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 213¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
gen_orography_masks(standard_orography, standard_landmask, thresholds, units='m')[source]¶ Function to generate topographical band masks.
For each threshold defined in ‘thresholds’, a cube with 0 over sea points and 1 for land points within the topography band will be generated. The lower threshold is exclusive to the band whilst the upper threshold is inclusive i.e: lower_threshold < band <= upper_threshold
For example, for threshold pair [1,3] with orography:
[[0 0 2] and sea mask: [[0 0 1] [2 2 3] [1 1 1] [0 1 4]] [0 1 1]]
the resultant array will be:
[[0 0 1] [0 1 1] [0 0 0]]
- Parameters
standard_orography (iris.cube.Cube) – The standard orography.
standard_landmask (iris.cube.Cube) – The landmask generated by gen_landmask.
thresholds (list) – Upper and/or lower thresholds of the current topographical band.
units (str) – Units to be fed to CF_units to create a unit for the cube. The unit must be convertable to meters. If no unit is given this will default to meters.
- Returns
Cube containing topographical band mask.
- Return type
- Raises
KeyError – if the key does not match any in THRESHOLD_DICT.
-
process(orography, thresholds_dict, landmask=None)[source]¶ - Loops over the supplied orographic bands, adding a cube
for each band to the mask cubelist.
- Parameters
orography (iris.cube.Cube) – orography on standard grid.
thresholds_dict (dict) –
Definition of orography bands required. Has key-value pairs of “bounds”: list of list of pairs of bounds for each band and “units”:”string containing units of bounds”, for example:
{'bounds':[[0,100], [100,200]], 'units': "m"}
landmask (iris.cube.Cube) – land mask on standard grid. If provided sea points are set to zero in every band.
- Returns
list of orographic band mask cubes.
- Return type
-
static
sea_mask(landmask, orog_band, sea_fill_value=None)[source]¶ Function to mask sea points and substitute the default numpy fill value behind this mask_cube.
- Parameters
landmask (numpy.ndarray) – The landmask generated by gen_landmask.
orog_band (numpy.ndarray) – The binary array to which the landmask will be applied.
sea_fill_value (float) – A fill value to set sea points to and leave the output unmasked, rather than the default behaviour of returning a masked array with a default fill value.
- Returns
An array where the sea points have been masked out and filled with a default fill value, or just filled with the given sea_fill_value and not masked.
- Return type
-
-
improver.generate_ancillaries.generate_ancillary._make_mask_cube(mask_data, coords, topographic_bounds, topographic_units, sea_points_included=False)[source]¶ Makes cube from numpy masked array generated from orography fields.
- Parameters
mask_data (numpy.ma.core.MaskedArray) – The numpy array to make a cube from.
coords (dict) – Dictionary of coordinate on the model ancillary file.
topographic_bounds (list) – List containing the lower and upper thresholds defining the mask
topographic_units (str) – Name of the units of the topographic zone coordinate of the output cube.
sea_points_included (bool) – Default is False. Value for the output cube attribute ‘topographic_zones_include_seapoints’, signifying whether sea points have been included when the ancillary is generated.
- Returns
Cube containing the mask_data array, with appropriate coordinate and attribute information.
- Return type