Domains domain#
Domain plugins for pyCIF.
A domain plugin loads and stores all geographical information about a model or data-stream grid — both horizontal and vertical. Every other plugin that handles spatially gridded data (models, transforms, fluxes, …) references a domain to know the grid layout.
Required attributes and functions#
The following attributes and functions must be defined for any domain plugin.
Initialisation attributes#
Set in read_grid or create_domain:
unstructured_domain(optional)Set to
Truewhen the grid cannot be represented as a regular 2-D array; cells are stored as a flat list instead.Warning
For unstructured domains, always set
nlon= number of cells andnlat= 1.regular_degrees(optional)Used together with
unstructured_domain; set toTruewhen cells are regular rectangles in degrees (speeds up area computation).nlon/nlat/nlevGrid dimensions (zonal, meridional, vertical).
zlon/zlatCell-centre coordinate arrays; shape
(nlat, nlon)for structured grids or(1, ncells)for unstructured grids.zlonc/zlatcCell-corner coordinate arrays; shape
(nlat+1, nlon+1)for structured grids or(nvertices, ncells)for unstructured grids.sigma_a/sigma_bAlpha / beta coefficients of sigma pressure levels (
p = sigma_a + sigma_b * psurf).pressure_unit(optional)Pressure unit for sigma levels:
'Pa'or'hPa'(default'Pa').heights(optional)Heights above ground level (m) for each vertical level.
Warning
When both sigma levels and heights are provided, only sigma levels are used.
lon_cyclic(optional)Truefor globally cyclic (periodic) zonal grids.projection(optional)Set to
'xy'when coordinates are in metres from a reference point rather than GPS degrees.
The horizontal grid definition drives horizontal regridding and the vertical grid definition drives vertical interpolation.
Online attributes#
Computed on demand during the run:
zlon_side/zlat_sideLongitudes / latitudes of the domain lateral boundary (or buffer region).
zlonc_side/zlatc_sideCorner equivalents of the side coordinates.
nlon_side/nlat_sideNumber of cells along the sides;
nlat_side > 1for buffer regions.areasGrid-cell areas (m²).
Required functions#
read_grid(self, **kwargs)Called first during domain initialisation. Should populate all attributes listed above from pre-existing coordinate files. If it raises
IOErrororAttributeError,create_domainis called automatically as a fallback.def read_grid(self, **kwargs): self.zlon = ... self.zlat = ... self.zlonc = ... self.zlatc = ... self.nlon = ... self.nlat = ... self.nlev = ... self.sigma_a = ... self.sigma_b = ...
See
pycif.plugins.domains.chimere.read_grid()for a full example.create_domain(self, **kwargs)Fallback called when
read_gridfails. Generates the grid from YAML configuration parameters instead of reading from files.See
pycif.plugins.domains.chimere.create_domain()for a full example.get_sides(self)(optional)Defines
zlon_side,zlat_side,zlonc_side,zlatc_side,nlon_side,nlat_side. When not provided, the default implementation (outer border of the domain) frompycif.utils.classes.domains.Domain.get_sides()is used.
- 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/.
Available Domains domain#
The following domains are implemented in pyCIF so far:
- CHIMERE HCOORD/VCOORD domain
CHIMERE/std - Dynamico grid
dynamico/std - ECMWF grib2 data files
ECMWF/grib2 - FLEXPART/std
FLEXPART/std - Gridded NetCDF domain
gridded_netcdf/std - ICON-ART/std
ICON-ART/std - LMDZ dynamico domain
LMDZ/dynamico - LMDZ regular lat-lon domain
LMDZ/regular - LMDz grid
LMDZ/std - Unstructured grid NetCDF domain
gridded_netcdf/unstructured - dummy/std
dummy/std - wrfchem/std
wrfchem/std