pygetm.output.operators package

Module contents

class pygetm.output.operators.Base(expression: str, shape: Iterable[int], dims: Iterable[str], dtype: DTypeLike, fill_value=None, time_varying: TimeVarying | Literal[False] = TimeVarying.MICRO, attrs: Mapping[str, Any] = {})[source]

Bases: object

attrs
coordinates: list[str]
property coords: Iterable[Base]
property default_name: str
dims
dtype
expression
fill_value
gather() Base[source]
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property grid_info: GridInfo | None
property mask: ndarray
ndim
classmethod parameterize(**kwargs) T[source]
shape
time_varying
property updatable: bool
property updater: Callable | None
class pygetm.output.operators.Field(array: Array, dtype: DTypeLike | None = None)[source]

Bases: Base

array
collection
property default_name: str
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property grid_info: GridInfo
property mask: ndarray
class pygetm.output.operators.FieldCollection(available_fields: Mapping[str, Array], default_dtype: DTypeLike | None = None, sub: bool = False)[source]

Bases: Mapping[str, Base]

add_coordinates()[source]
request(*fields: str | Array, output_name: str | None = None, dtype: DTypeLike | None = None, mask: bool | None = None, time_average: bool = False, grid: Grid | None = None, z: None | Literal[1] | Literal[2] | float | Iterable[float] = None, generate_unique_name: bool = False, transforms: Iterable[type[UnivariateTransform]] = ()) tuple[str, ...][source]

Add one or more arrays to this field collection.

Parameters:
  • *fields – names of arrays or array objects to add. When names are provided, they will be looked up in the field manager.

  • output_name – name to use for this field. This can only be provided if a single field is requested.

  • dtype – data type of the field to use. Array values will be cast to this data type whenever the field is saved

  • mask – whether to explicitly set masked values to the array’s fill value when saving. If this argument is not provided, masking behavior is determined by the array’s _mask_output flag.

  • time_average – whether to time-average the field

  • grid – if provided, the field will be regridded to this grid before saving

  • z – if provided, the field will be interpolated to these z levels before saving. This can be CENTERS or INTERFACES to indicate interpolation to the center or interfaces of the model grid, a 1D array of custom z levels, or a single float indicating the z level to interpolate to. Note that z levels are negative downward, with the bottom being -H.

  • generate_unique_name – whether to generate a unique output name for requested fields if a field with the same name has previously been added to the collection. If this is not set and a field with this name was added previously, an exception will be raised.

Returns:

tuple with names of the newly added fields

require(field: Base) str[source]

Ensure that the specified variable (or expression of variables) is included in the field collection. This is typically used to add coordinate variables.

Parameters:

expression – variable name or expression of variable(s)

update(macro: bool = False)[source]
class pygetm.output.operators.Gather(source: Base)[source]

Bases: UnivariateTransform

property coords: Iterable[Base]
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property grid_info: None
root_has_global_values
class pygetm.output.operators.GridInfo(grid, z, on_boundary)[source]

Bases: NamedTuple

Create new instance of GridInfo(grid, z, on_boundary)

get_coords(ndim: int) Iterable[Base][source]
grid: Grid

Alias for field number 0

on_boundary: bool

Alias for field number 2

z: Literal[1, 2] | None

Alias for field number 1

class pygetm.output.operators.IndexXY(source: Base, x: ArrayLike, y: ArrayLike, coordinate_type: CoordinateType = CoordinateType.IJ, dims: tuple[str, ...] = (), coords: Mapping[str, Base | ArrayLike] = {})[source]

Bases: UnivariateTransform

property coords: Iterable[Base]
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property grid_info: None
property mask: ndarray
class pygetm.output.operators.InterpZ(source: Base, z: ArrayLike, dim: str, edges: EdgeTreatment = EdgeTreatment.MISSING)[source]

Bases: UnivariateTransformWithData

Interpolate in the vertical. The vertical dimension must be the first dimension of the source array. The source array must have a vertical coordinate with axis attribute equal to Z. This coordinate must have the same shape as the source array.

property coords: Iterable[Base]
edges
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property mask: ndarray
z_dim
z_src
z_tgt
class pygetm.output.operators.Mask(source: Field)[source]

Bases: UnivariateTransformWithData

get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
values
class pygetm.output.operators.Regrid(source: Base, grid: Grid | None = None, z: Literal[None, 1, 2] | None = None)[source]

Bases: UnivariateTransformWithData

get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property grid_info: GridInfo
interpolate
property mask: ndarray
class pygetm.output.operators.TimeAverage(source: Field)[source]

Bases: UnivariateTransformWithData

property coords: Iterable[Base]
property default_name: str
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
property updatable: bool
update()[source]
property updater: Callable | None
class pygetm.output.operators.UnivariateTransform(source: Base, shape: tuple[int, ...] | None = None, dims: Iterable[str] | None = None, dtype: DTypeLike | None = None, expression: str | None = None, inherit_grid_info: bool = True)[source]

Bases: Base

property coords: Iterable[Base]
property default_name: str
property grid_info: GridInfo | None
property mask: ndarray
property updatable: bool
property updater: Callable | None
class pygetm.output.operators.UnivariateTransformWithData(*args, **kwargs)[source]

Bases: UnivariateTransform

get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
values
class pygetm.output.operators.Updatable(*values)[source]

Bases: Enum

ALWAYS = 1
MACRO_ONLY = 2
class pygetm.output.operators.WrappedArray(values: ndarray, name: str, dims: tuple[str, ...], global_field: Base | None = None, **kwargs)[source]

Bases: Base

property coords: Iterable[Base]
property default_name: str
gather() Base[source]
get(out: ArrayLike | None = None, slice_spec: tuple[int, ...] = ()) ArrayLike[source]
values