pycif.plugins.domains.gridded_NetCDF — API reference#
Configuration reference: gridded_NetCDF plugin
- pycif.plugins.domains.gridded_NetCDF.read_domain.read_vcoord(domain)[source]#
Read vertical coordinate information from a NetCDF file into the domain.
Behaviour depends on whether
domain.vertical_coordis set:Not set — creates a single surface level (
sigma_b = [1],sigma_a = [0],nlev = 1).Set to ``’mids’`` — reads level mid-point values for
sigma_a/sigma_b(sigma pressure) orheights(metres).Set to ``’bounds’`` — reads level boundary values and derives
nlev = len(sigma_b) - 1.
The vertical coordinate file is
{dir}/{file}by default, or{dir_vcoord}/{file_vcoord}if the latter is explicitly provided.Levels are automatically reordered so that pressure decreases upward (surface at index 0). Units are validated against
'Pa','hPa', or'm'.Sets on domain:
nlev,pressure_unit, and one ofsigma_a_mid/sigma_b_mid,sigma_a/sigma_b,heights_mid, orheightsdepending onvertical_coordandvertical_dim_type.- Parameters:
domain – gridded_NetCDF domain plugin instance with
dir,file, and optionalvertical_coord,vertical_dim_type,file_vcoord,dir_vcoord,pressure_unitset.- Raises:
ValueError – for unrecognised pressure units, non-monotone level ordering, or unexpected
vertical_coordvalues.Exception – for unrecognised
vertical_dim_type.
- pycif.plugins.domains.gridded_NetCDF.read_domain.read_grid(domain, **kwargs)[source]#
Read horizontal and vertical grid coordinates from a NetCDF file.
Locates latitude and longitude variables by their
standard_name/long_nameattributes (or bylatitude_varname/longitude_varnameoverrides), then derives cell corners either from aboundsattribute or from the coordinate spacing.Handles:
Automatically flipping non-increasing coordinate arrays.
Fixed-spacing corners via
delta_lat/delta_lon.Corner-as-centre mode (
use_corners = True) with optional extension by one cell.Force-centred cell midpoints via
force_centered_lat/force_centered_lon.Cyclic zonal unwrapping when
lon_cyclicis detected.
Delegates vertical coordinate reading to
read_vcoord().Sets on domain:
nlon,nlat,zlon,zlat,zlonc,zlatc,lon_cyclic, and all vertical attributes fromread_vcoord().- Parameters:
domain – gridded_NetCDF domain plugin instance with
dir,file, and all grid / vcoord arguments set.**kwargs – unused.
- Raises:
IOError – if the NetCDF file cannot be opened with xarray.
AssertionError – if coordinates are not strictly increasing after optional flipping.
- pycif.plugins.domains.gridded_NetCDF.utils.get_bounds(ds: Dataset, coord_name: str, flip_coord: bool, min_bound: float, max_bound: float, regular_extent: bool) ndarray[source]#
Get the bounds of a given coordinates.