pycif.plugins.domains.chimere — API reference#

Configuration reference: chimere plugin

pycif.plugins.domains.chimere.create_domain.create_domain(domain, **kwargs)[source]#

Generate and write CHIMERE coordinate files from YAML configuration.

Creates the {workdir}/domain/ directory tree and calls:

  • make_hcoord() — generates horizontal coordinate files (COORD_{domid} and COORDcorner_{domid}).

  • make_vcoord() — generates the vertical sigma-level file (VCOORD_{nlev}_{p1}_{pmax}).

  • make_landuse() — copies or generates the land-use file.

  • make_domainlist() — appends the new domain entry to domainlist.nml.

Parameters:
  • domain – CHIMERE domain plugin instance with workdir, type, and all grid-geometry parameters set.

  • **kwargs – unused.

pycif.plugins.domains.chimere.read_domain.read_grid(domain, **kwargs)[source]#

Read the CHIMERE horizontal and vertical grid from pre-computed coordinate files.

Reads domainlist.nml to determine grid dimensions (nzo × nme), then loads cell centres from HCOORD/COORD_{domid} and corners from HCOORD/COORDcorner_{domid}. Vertical sigma levels are read from VCOORD/VCOORD_{nlev}_{p1}_{pmax} and stored as sigma_a / sigma_b (in hPa).

Sets on domain: nlon, nlat, nlev, zlon, zlat, zlonc, zlatc, corners, sigma_a, sigma_b.

Parameters:
  • domain – CHIMERE domain plugin instance with repgrid, domid, nlev, p1, and pmax set.

  • **kwargs – unused.

Raises:

AttributeError – if domain.domid is not found in domainlist.nml.

pycif.plugins.domains.chimere.utils.make_domainlist.make_domainlist(domain)[source]#
pycif.plugins.domains.chimere.utils.make_hcoord.make_hcoord(domain)[source]#

Build the CHIMERE horizontal coordinate arrays and write HCOORD files.

Supports three grid types controlled by domain.type:

  • 'deg' — regular lat-lon grid defined by xmin, xmax, ymin, ymax, dx, dy (in degrees). An optional buffer region of coarser resolution can be added with add_buffer.

  • 'km' — rotated conformal grid centred on (xcenter, ycenter) with cell size dx × dy in kilometres, projected from an oblique Mercator CRS to GPS coordinates via pyproj.

  • 'precomputed' — reads pre-existing COORD_{domid} and COORDcorner_{domid} text files from coord_precomputed_dir.

After building the coordinate arrays the function:

  1. Computes cell areas with domain.calc_areas().

  2. Saves a PNG map of cell areas and grid mesh for visual inspection.

  3. Writes COORD_{domid} (centres) and COORDcorner_{domid} (corners + areas) to {workdir}/domain/HCOORD/.

Sets on domain: nlon, nlat, zlon, zlat, zlonc, zlatc.

Parameters:

domain – CHIMERE domain plugin instance with all geometry parameters set.

Raises:

Exception – if the domain dimensions are not consistent with dx/ dy ('deg' type) or if domain.type is unrecognised.

pycif.plugins.domains.chimere.utils.make_hcoord.add_buffer_region(xmax, xmin, ymax, ymin, nzo, nme, dx, dy, zlonc, zlatc, x_buffer_left, x_buffer_right, y_buffer_down, y_buffer_up, dx_buffer, dy_buffer)[source]#

Extend a lat-lon domain with a coarser-resolution buffer frame.

Surrounds the inner high-resolution grid with buffer strips of width dx_buffer × dy_buffer on each side, then recomputes the full cell-centre and corner arrays for the combined grid.

Parameters:
  • xmax (float) – east longitude of the inner domain.

  • xmin (float) – west longitude of the inner domain.

  • ymax (float) – north latitude of the inner domain.

  • ymin (float) – south latitude of the inner domain.

  • nzo (float) – number of inner cells in the zonal direction.

  • nme (float) – number of inner cells in the meridional direction.

  • dx (float) – inner cell size in degrees (zonal).

  • dy (float) – inner cell size in degrees (meridional).

  • zlonc (np.ndarray) – corner longitudes of the inner domain.

  • zlatc (np.ndarray) – corner latitudes of the inner domain.

  • x_buffer_left (float) – buffer width on the west side (degrees).

  • x_buffer_right (float) – buffer width on the east side (degrees).

  • y_buffer_down (float) – buffer height on the south side (degrees).

  • y_buffer_up (float) – buffer height on the north side (degrees).

  • dx_buffer (float) – buffer cell size in degrees (zonal).

  • dy_buffer (float) – buffer cell size in degrees (meridional).

Returns:

(zlon_buffer, zlat_buffer, zlonc_buffer, zlatc_buffer, nzo, nme) for the combined inner + buffer domain.

Return type:

tuple

pycif.plugins.domains.chimere.utils.make_hcoord.create_2Dpolygons(x_corner, y_corner, dim)[source]#

Build a list of Shapely Polygon objects from corner-coordinate arrays.

For each cell (i, j) in the grid, constructs a quadrilateral polygon from the four surrounding corner points. Used to create a GeoDataFrame for diagnostic area maps.

Parameters:
  • x_corner (np.ndarray) – 2-D array of corner longitudes, shape (nlat+1, nlon+1).

  • y_corner (np.ndarray) – 2-D array of corner latitudes, shape (nlat+1, nlon+1).

  • dim (tuple[int, int]) – (nlat, nlon) — number of cells (not corners) in each direction.

Returns:

one polygon per grid cell, in row-major order.

Return type:

list[shapely.geometry.Polygon]

pycif.plugins.domains.chimere.utils.make_landuse.make_landuse(domain)[source]#
pycif.plugins.domains.chimere.utils.make_vcoord.make_vcoord(domain)[source]#