domains class#
- class pycif.utils.classes.domains.Domain(**kwargs)[source]#
Bases:
PluginPlugin type for spatial model domains.
Stores horizontal (lon/lat grid centres and corners) and vertical (hybrid sigma-pressure or height-above-ground) grid definitions, and provides utilities for computing cell areas and boundary coordinates.
Concrete implementations live in
pycif/plugins/domains/.- classmethod register_plugin(name, version, module, subtype='', **kwargs)[source]#
Register a module for a plugin and version with possibly options
- Parameters:
name (str) – name of the plugin
version (str) – version of the plugin
module (types.ModuleType) – module defining the interface between pyCIF and the plugin
plugin_type (str) – type of plugin
**kwargs (dictionary) – default options for module
- property vdomain_type#
Type of vertical coordinate system used by this domain.
- Returns:
"sigma"if hybrid sigma-pressure coordinates are defined,"height"if AGL heights are defined,"none"otherwise.
- Return type:
str
- read_grid(*args, **kwargs)[source]#
Read a grid from an existing file
- Parameters:
self (Domain) – plugin defining the domain. Should include
file (filegrid to be able to read the grid from a)
- Returns:
Grid domain with meshgrids for center lon/lat and corner lon/lat
- create_domain(*args, **kwargs)[source]#
Creates a grid if needed
- Parameters:
domain (dictionary) – dictionary defining the domain.
- calc_areas(*args, **kwargs)[source]#
Compute the area of each grid cell in the domain.
Delegates to
calc_areas().- Returns:
Array of cell areas in m².
- Return type:
numpy.ndarray
- initiate_template()[source]#
Initialise the Domain plugin template.
Loads the registered domain module and attaches
read_grid,create_domain,calc_areasandget_sidesas bound methods. Also wrapsini_datato automatically callread_grid()(orcreate_domain()on failure),get_sides()andget_vmiddle()after data initialisation.
- get_sides()[source]#
Compute and store the boundary (side) coordinates of the domain.
Concatenates the West, East, South and North edge lon/lat corner coordinates into
zlonc_side/zlatc_side, and the corresponding midpoint coordinates intozlon_side/zlat_side. Setsnlon_sideandnlat_side.
- get_vmiddle()[source]#
Derive mid-level vertical coordinates from layer interfaces, or vice-versa.
If
sigma_a/sigma_bhybrid-sigma interfaces are defined but mid-levels are not, computessigma_a_midandsigma_b_midas arithmetic means of adjacent levels.If mid-levels are defined but interfaces are not, reconstructs the interface arrays.
The same logic applies symmetrically for
heights/heights_mid(heights above ground level).