src.data_model module

Classes to describe “abstract” properties of model data: aspects that are independent of any model, experiment, or hosting protocol.

This is based on the CF standard terminology.

class src.data_model.AbstractDMCoordinate[source]

Bases: ABC

Defines interface (set of attributes) for DMCoordinate objects.

abstract property name

Coordinate name (str).

abstract property standard_name

Coordinate CF standard name (str).

abstract property units

Coordinate units (str, or Units).

abstract property axis

Coordinate axis identifier (str, ‘X’, ‘Y’, ‘Z’, ‘T’).

abstract property bounds

Associated bounds variable for the coordinate, if present (else None.)

abstract property value

If a scalar coordinate, value of the coordinate in units given by units().

abstract property is_scalar

Whether the coordinate is a scalar coordinate (bool).

abstract property has_bounds

Whether the coordinate has an associated bounds variable (bool).

class src.data_model.AbstractDMDependentVariable[source]

Bases: ABC

Defines interface (set of attributes) for “dependent variables” (data defined as a function of one or more dimension coordinates), which inherit from DMDimensions in this implementation.

abstract property name

Variable name (str).

abstract property standard_name

Variable CF standard name (str).

abstract property units

Variable units (str, or Units).

abstract property dims
abstract property scalar_coords
abstract property axes
abstract property all_axes
abstract property X

X axis coordinate of variable, if defined.

abstract property Y

Y axis coordinate of variable, if defined.

abstract property Z

Z axis coordinate of variable, if defined.

abstract property T

T axis coordinate of variable, if defined.

abstract property is_static

Whether the variable has time dependence (bool).

class src.data_model.AbstractDMCoordinateBounds[source]

Bases: AbstractDMDependentVariable

Defines interface (set of attributes) for DMCoordinateBounds objects.

abstract property coord

DMCoordinate object which this object is the bounds of.

abstract property T

T axis coordinate of variable, if defined.

abstract property X

X axis coordinate of variable, if defined.

abstract property Y

Y axis coordinate of variable, if defined.

abstract property Z

Z axis coordinate of variable, if defined.

abstract property all_axes
abstract property axes
abstract property dims
abstract property is_static

Whether the variable has time dependence (bool).

abstract property name

Variable name (str).

abstract property scalar_coords
abstract property standard_name

Variable CF standard name (str).

abstract property units

Variable units (str, or Units).

class src.data_model.DMBoundsDimension(name: str = sentinel.Mandatory)[source]

Bases: object

Placeholder object to represent the bounds dimension of a DMCoordinateBounds object. Not a dimension coordinate, and strictly speaking we should make another set of classes for dimensions.

name: str = sentinel.Mandatory
standard_name = 'bounds'
units = <src.units.Units object>
axis = 'BOUNDS'
bounds = None
value = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool). Always False for this class.

property is_scalar

Whether the coordinate is a scalar coordinate (bool). Always False for this class.

class src.data_model.DMCoordinate(standard_name: str = sentinel.Mandatory, units: Units = sentinel.Mandatory, axis: str = 'OTHER', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory)[source]

Bases: _DMCoordinateShared

Class to describe a single coordinate variable (dimension coordinate or scalar coordinate, in the sense used by the CF conventions).

name: str = sentinel.Mandatory

Coordinate name.

standard_name: str = sentinel.Mandatory

Coordinate CF standard name.

units: Units = sentinel.Mandatory

Coordinate units (str or Units).

axis: str = 'OTHER'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMLongitudeCoordinate(standard_name: str = sentinel.Mandatory, units: Units = 'degrees_east', axis: str = 'X', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory)[source]

Bases: _DMCoordinateShared

Class to describe a longitude dimension coordinate.

name: str = sentinel.Mandatory

Coordinate name.

standard_name: str = sentinel.Mandatory

Coordinate CF standard name.

units: Units = 'degrees_east'

Coordinate units (str or Units).

axis: str = 'X'

Coordinate axis identifier. Always ‘X’ for this coordinate.

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMLatitudeCoordinate(standard_name: str = sentinel.Mandatory, units: Units = 'degrees_north', axis: str = 'Y', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory)[source]

Bases: _DMCoordinateShared

Class to describe a latitude dimension coordinate.

name: str = sentinel.Mandatory

Coordinate name; defaults to ‘lat’.

standard_name: str = sentinel.Mandatory

Coordinate CF standard name.

units: Units = 'degrees_north'

Coordinate units (str or Units).

axis: str = 'Y'

Coordinate axis identifier. Always ‘Y’ for this coordinate.

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMVerticalCoordinate(standard_name: str = sentinel.Mandatory, units: Units = '1', axis: str = 'Z', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory, positive: str = sentinel.Mandatory)[source]

Bases: _DMCoordinateShared

Class to describe a non-parametric vertical coordinate (height or depth), following the CF conventions.

name: str = sentinel.Mandatory

Coordinate name.

standard_name: str = sentinel.Mandatory

Coordinate CF standard name.

units: Units = '1'

Coordinate units (str or Units).

axis: str = 'Z'

Coordinate axis identifier. Always ‘Z’ for this coordinate.

positive: str = sentinel.Mandatory
property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMParametricVerticalCoordinate(standard_name: str = sentinel.Mandatory, units: Units = '1', axis: str = 'Z', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory, positive: str = sentinel.Mandatory, computed_standard_name: str = '', long_name: str = '', formula_terms: str = None)[source]

Bases: DMVerticalCoordinate

Class to describe parametric vertical coordinates. Note that the variable names appearing in formula_terms aren’t parsed here, in order to keep the class hashable.

computed_standard_name: str = ''

Coordinate CF standard name.

long_name: str = ''
formula_terms: str = None
axis: str = 'Z'

Coordinate axis identifier. Always ‘Z’ for this coordinate.

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

name: str = sentinel.Mandatory

Coordinate name.

positive: str = sentinel.Mandatory
standard_name: str = sentinel.Mandatory

Coordinate CF standard name.

units: Units = '1'

Coordinate units (str or Units).

value: int | float = None
class src.data_model.DMGenericTimeCoordinate(standard_name: str = 'time', units: Units = '', axis: str = 'T', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'time', calendar: str = '', range: Any = None)[source]

Bases: _DMCoordinateShared

Applies to collections of variables, which may be at different time frequencies (or other attributes).

name: str = 'time'

Coordinate name; defaults to ‘time’.

standard_name: str = 'time'

Coordinate CF standard name.

units: Units = ''

Coordinate units (str or Units).

axis: str = 'T'

Coordinate axis identifier. Always ‘T’ for this coordinate.

calendar: str = ''

CF standard calendar for time data.

range: Any = None
property is_static

Check for time-independent data (‘fx’ in CMIP6 DRS.) Do the comparison by checking date_range against the placeholder value because that’s unique – we may be using a different DateFrequency depending on the data source.

classmethod from_instances(*t_coords)[source]

Create new instance from “union” of attributes of one or more t_coords.

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMTimeCoordinate(standard_name: str = 'time', units: src.units.Units = sentinel.Mandatory, axis: str = 'T', bounds_var: src.data_model.AbstractDMCoordinateBounds = None, value: int | float = None, name: str = sentinel.Mandatory, calendar: str = '', range: src.util.datelabel.AbstractDateRange = None, frequency: src.util.datelabel.AbstractDateFrequency = None)[source]

Bases: DMGenericTimeCoordinate

name: str = sentinel.Mandatory

Coordinate name.

standard_name: str = 'time'

Coordinate CF standard name.

units: Units = sentinel.Mandatory

Coordinate units (str or Units).

axis: str = 'T'

Coordinate axis identifier. Always ‘T’ for this coordinate.

calendar: str = ''

CF standard calendar for time data.

range: AbstractDateRange = None

Date range of coordinate.

frequency: AbstractDateFrequency = None

Sampling frequency of coordinate.

classmethod from_instances(*t_coords)[source]

Create new instance from “union” of attributes of one or more t_coords.

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

property is_static

Check for time-independent data (‘fx’ in CMIP6 DRS.) Do the comparison by checking date_range against the placeholder value because that’s unique – we may be using a different DateFrequency depending on the data source.

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
src.data_model.coordinate_from_struct(d, class_dict=None, **kwargs)[source]

Attempt to instantiate the correct DMCoordinate class based on information in dict d (read from JSON file).

class_dict is an optional dict mapping axes identifiers to the DMCoordinate child classes to instantiate. Default is to use DMLongitudeCoordinate for ‘X’, etc.

TODO: implement full cf_xarray/MetPy heuristics.

class src.data_model.DMPlaceholderCoordinate(standard_name: str = NotImplemented, units: Units = NotImplemented, axis: str = 'OTHER', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'PLACEHOLDER_COORD')[source]

Bases: _DMCoordinateShared, _DMPlaceholderCoordinateBase

Dummy base class for placeholder coordinates. Placeholder coordinates are only used in instantiating FieldlistEntry objects: they’re replaced by the appropriate translated coordinates when that object is used to create a TranslatedVarlistEntry object.

name: str = 'PLACEHOLDER_COORD'

Coordinate name; defaults to ‘PLACEHOLDER_COORD’ since this is a temporary object.

standard_name: str = NotImplemented

Coordinate CF standard name.

units: Units = NotImplemented

Coordinate units (str or Units).

axis: str = 'OTHER'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMPlaceholderXCoordinate(standard_name: str = NotImplemented, units: Units = NotImplemented, axis: str = 'X', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'PLACEHOLDER_X_COORD')[source]

Bases: _DMCoordinateShared, _DMPlaceholderCoordinateBase

Dummy base class for placeholder X axis coordinates. Placeholder coordinates are only used in instantiating FieldlistEntry objects: they’re replaced by the appropriate translated coordinates when that object is used to create a TranslatedVarlistEntry object.

name: str = 'PLACEHOLDER_X_COORD'

Coordinate name; defaults to ‘PLACEHOLDER_X_COORD’ since this is a temporary object.

standard_name: str = NotImplemented

Coordinate CF standard name.

units: Units = NotImplemented

Coordinate units (str or Units).

axis: str = 'X'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMPlaceholderYCoordinate(standard_name: str = NotImplemented, units: Units = NotImplemented, axis: str = 'Y', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'PLACEHOLDER_Y_COORD')[source]

Bases: _DMCoordinateShared, _DMPlaceholderCoordinateBase

Dummy base class for placeholder Y axis coordinates. Placeholder coordinates are only used in instantiating FieldlistEntry objects: they’re replaced by the appropriate translated coordinates when that object is used to create a TranslatedVarlistEntry object.

name: str = 'PLACEHOLDER_Y_COORD'

Coordinate name; defaults to ‘PLACEHOLDER_Y_COORD’ since this is a temporary object.

standard_name: str = NotImplemented

Coordinate CF standard name.

units: Units = NotImplemented

Coordinate units (str or Units).

axis: str = 'Y'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMPlaceholderZCoordinate(standard_name: str = NotImplemented, units: Units = NotImplemented, axis: str = 'Z', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'PLACEHOLDER_Z_COORD', positive: str = NotImplemented)[source]

Bases: _DMCoordinateShared, _DMPlaceholderCoordinateBase

Dummy base class for placeholder Z axis coordinates. Placeholder coordinates are only used in instantiating FieldlistEntry objects: they’re replaced by the appropriate translated coordinates when that object is used to create a TranslatedVarlistEntry object.

name: str = 'PLACEHOLDER_Z_COORD'

Coordinate name; defaults to ‘PLACEHOLDER_Z_COORD’ since this is a temporary object.

standard_name: str = NotImplemented

Coordinate CF standard name.

units: Units = NotImplemented

Coordinate units (str or Units).

axis: str = 'Z'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

positive: str = NotImplemented
property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
class src.data_model.DMPlaceholderTCoordinate(standard_name: str = NotImplemented, units: Units = NotImplemented, axis: str = 'T', bounds_var: AbstractDMCoordinateBounds = None, value: int | float = None, name: str = 'PLACEHOLDER_T_COORD', calendar: str = NotImplemented, range: Any = None)[source]

Bases: _DMCoordinateShared, _DMPlaceholderCoordinateBase

Dummy base class for placeholder T axis coordinates. Placeholder coordinates are only used in instantiating FieldlistEntry objects: they’re replaced by the appropriate translated coordinates when that object is used to create a TranslatedVarlistEntry object.

name: str = 'PLACEHOLDER_T_COORD'

Coordinate name; defaults to ‘PLACEHOLDER_T_COORD’ since this is a temporary object.

standard_name: str = NotImplemented

Coordinate CF standard name.

units: Units = NotImplemented

Coordinate units (str or Units).

axis: str = 'T'

Coordinate axis identifier (‘X’, ‘Y’, etc.)

property bounds

The bounds_var attribute is stored as a pointer to the actual object representing the bounds variable for this coordinate, but in order to parallel xarray’s syntax define ‘bounds’ to return the name of this variable, not the variable itself.

bounds_var: AbstractDMCoordinateBounds = None
calendar: str = NotImplemented

CF standard calendar for time data.

property has_bounds

Whether the coordinate has an associated bounds variable (bool).

property is_scalar

Whether the coordinate is a scalar coordinate (bool).

make_scalar(new_value)

Returns a copy of the coordinate, converted to a scalar coordinate at value new_value (and coordinate’s current units.)

value: int | float = None
range: Any = None

Date range of coordinate.

property is_static

Check for time-independent data (‘fx’ in CMIP6 DRS.) Do the comparison by checking date_range against the placeholder value because that’s unique – we may be using a different DateFrequency depending on the data source.

class src.data_model.DMDependentVariable(coords: InitVar = None, name: str = sentinel.Mandatory, standard_name: str = sentinel.Mandatory, units: Units = '', modifier: str = '', component: str = '', associated_files: str = '', rename_coords: bool = True)[source]

Bases: _DMDimensionsMixin

Base class for any “dependent variable”: all non-dimension-coordinate information that depends on one or more dimension coordinates.

property T

Return T axis dimension coordinate if defined, else None.

property X

Return X axis dimension coordinate if defined, else None.

property Y

Return Y axis dimension coordinate if defined, else None.

property Z

Return Z axis dimension coordinate if defined, else None.

build_axes(*coords, verify=True)

Constructs a dict mapping axes labels to dimension coordinates (of type AbstractDMCoordinate.)

change_coord(ax_name, new_class=None, **kwargs)

Replace attributes on a given coordinate, but also optionally cast them to new classes.

Parameters:
  • ax_name – Name of the coordinate to modify.

  • new_class (optional) – new class to cast the returned coordinate to.

  • kwargs – Set of attribute names and values to replace on the returned copy.

coords: InitVar = None
property dim_axes

Retrun dict mapping axes labels (‘X’, ‘Y’, etc.) to corresponding dimension coordinate objects.

property dim_axes_set

Return frozenset of dimension coordinate axes labels.

get_scalar(ax_name)

If the axis label ax_name is a scalar coordinate, return the corresponding AbstractDMCoordinate object, otherwise return None.

property is_static

Whether the variable has time dependence (bool).

dims: list
scalar_coords: list
name: str = sentinel.Mandatory
standard_name: str = sentinel.Mandatory
units: Units = ''
modifier: str = ''
component: str = ''
associated_files: str = ''
rename_coords: bool = True
property full_name

Object’s full name, to be used in logging and debugging. Preferred because it eliminates irrelevant information in repr(), which is lengthy.

property axes

Superset of the dim_axes() dict (whose values contain coordinate dimensions only) that includes axes corresponding to scalar coordinates.

property axes_set

Superset of the dim_axes_set() frozenset (which contains axes labels corresponding to coordinate dimensions only) that includes axes labels corresponding to scalar coordinates.

add_scalar(ax, ax_value, **kwargs)[source]

Metadata operation corresponding to taking a slice of a higher-dimensional variable (extracting its values at axis ax = ax_value). The coordinate corresponding to ax is removed from the list of coordinate dimensions and added to the list of scalar coordinates.

remove_scalar(ax, position=-1, **kwargs)[source]

Metadata operation that’s the inverse of add_scalar(). Given an axis label ax that’s currently a scalar coordinate, remove the slice value and add it to the list of dimension coordinates at position (default end of the list.)

class src.data_model.DMAuxiliaryCoordinate(coords: InitVar = None, name: str = sentinel.Mandatory, standard_name: str = sentinel.Mandatory, units: Units = '', modifier: str = '', component: str = '', associated_files: str = '', rename_coords: bool = True)[source]

Bases: DMDependentVariable

Class to describe auxiliary coordinate variables, as defined in the CF conventions. An example would be lat or lon for data presented in a tripolar grid projection.

property T

Return T axis dimension coordinate if defined, else None.

property X

Return X axis dimension coordinate if defined, else None.

property Y

Return Y axis dimension coordinate if defined, else None.

property Z

Return Z axis dimension coordinate if defined, else None.

add_scalar(ax, ax_value, **kwargs)

Metadata operation corresponding to taking a slice of a higher-dimensional variable (extracting its values at axis ax = ax_value). The coordinate corresponding to ax is removed from the list of coordinate dimensions and added to the list of scalar coordinates.

associated_files: str = ''
property axes

Superset of the dim_axes() dict (whose values contain coordinate dimensions only) that includes axes corresponding to scalar coordinates.

property axes_set

Superset of the dim_axes_set() frozenset (which contains axes labels corresponding to coordinate dimensions only) that includes axes labels corresponding to scalar coordinates.

build_axes(*coords, verify=True)

Constructs a dict mapping axes labels to dimension coordinates (of type AbstractDMCoordinate.)

change_coord(ax_name, new_class=None, **kwargs)

Replace attributes on a given coordinate, but also optionally cast them to new classes.

Parameters:
  • ax_name – Name of the coordinate to modify.

  • new_class (optional) – new class to cast the returned coordinate to.

  • kwargs – Set of attribute names and values to replace on the returned copy.

component: str = ''
coords: InitVar = None
property dim_axes

Retrun dict mapping axes labels (‘X’, ‘Y’, etc.) to corresponding dimension coordinate objects.

property dim_axes_set

Return frozenset of dimension coordinate axes labels.

property full_name

Object’s full name, to be used in logging and debugging. Preferred because it eliminates irrelevant information in repr(), which is lengthy.

get_scalar(ax_name)

If the axis label ax_name is a scalar coordinate, return the corresponding AbstractDMCoordinate object, otherwise return None.

property is_static

Whether the variable has time dependence (bool).

modifier: str = ''
name: str = sentinel.Mandatory
remove_scalar(ax, position=-1, **kwargs)

Metadata operation that’s the inverse of add_scalar(). Given an axis label ax that’s currently a scalar coordinate, remove the slice value and add it to the list of dimension coordinates at position (default end of the list.)

rename_coords: bool = True
standard_name: str = sentinel.Mandatory
units: Units = ''
dims: list
scalar_coords: list
class src.data_model.DMCoordinateBounds(coords: InitVar = None, name: str = sentinel.Mandatory, standard_name: str = sentinel.Mandatory, units: Units = '', modifier: str = '', component: str = '', associated_files: str = '', rename_coords: bool = True)[source]

Bases: DMAuxiliaryCoordinate

Class describing bounds on a dimension coordinate.

property T

Return T axis dimension coordinate if defined, else None.

property X

Return X axis dimension coordinate if defined, else None.

property Y

Return Y axis dimension coordinate if defined, else None.

property Z

Return Z axis dimension coordinate if defined, else None.

add_scalar(ax, ax_value, **kwargs)

Metadata operation corresponding to taking a slice of a higher-dimensional variable (extracting its values at axis ax = ax_value). The coordinate corresponding to ax is removed from the list of coordinate dimensions and added to the list of scalar coordinates.

associated_files: str = ''
property axes

Superset of the dim_axes() dict (whose values contain coordinate dimensions only) that includes axes corresponding to scalar coordinates.

property axes_set

Superset of the dim_axes_set() frozenset (which contains axes labels corresponding to coordinate dimensions only) that includes axes labels corresponding to scalar coordinates.

build_axes(*coords, verify=True)

Constructs a dict mapping axes labels to dimension coordinates (of type AbstractDMCoordinate.)

change_coord(ax_name, new_class=None, **kwargs)

Replace attributes on a given coordinate, but also optionally cast them to new classes.

Parameters:
  • ax_name – Name of the coordinate to modify.

  • new_class (optional) – new class to cast the returned coordinate to.

  • kwargs – Set of attribute names and values to replace on the returned copy.

component: str = ''
coords: InitVar = None
property dim_axes

Retrun dict mapping axes labels (‘X’, ‘Y’, etc.) to corresponding dimension coordinate objects.

property dim_axes_set

Return frozenset of dimension coordinate axes labels.

property full_name

Object’s full name, to be used in logging and debugging. Preferred because it eliminates irrelevant information in repr(), which is lengthy.

get_scalar(ax_name)

If the axis label ax_name is a scalar coordinate, return the corresponding AbstractDMCoordinate object, otherwise return None.

property is_static

Whether the variable has time dependence (bool).

modifier: str = ''
name: str = sentinel.Mandatory
remove_scalar(ax, position=-1, **kwargs)

Metadata operation that’s the inverse of add_scalar(). Given an axis label ax that’s currently a scalar coordinate, remove the slice value and add it to the list of dimension coordinates at position (default end of the list.)

rename_coords: bool = True
standard_name: str = sentinel.Mandatory
units: Units = ''
dims: list
scalar_coords: list
property coord

CF dimension coordinate for which this is the bounds.

classmethod from_coordinate(coord, bounds_dim)[source]

Create instance from a coordinate object coord.

class src.data_model.DMVariable(coords: InitVar = None, name: str = sentinel.Mandatory, standard_name: str = sentinel.Mandatory, units: Units = '', modifier: str = '', component: str = '', associated_files: str = '', rename_coords: bool = True)[source]

Bases: DMDependentVariable

Class to describe general properties of data variables.

property T

Return T axis dimension coordinate if defined, else None.

property X

Return X axis dimension coordinate if defined, else None.

property Y

Return Y axis dimension coordinate if defined, else None.

property Z

Return Z axis dimension coordinate if defined, else None.

add_scalar(ax, ax_value, **kwargs)

Metadata operation corresponding to taking a slice of a higher-dimensional variable (extracting its values at axis ax = ax_value). The coordinate corresponding to ax is removed from the list of coordinate dimensions and added to the list of scalar coordinates.

associated_files: str = ''
property axes

Superset of the dim_axes() dict (whose values contain coordinate dimensions only) that includes axes corresponding to scalar coordinates.

property axes_set

Superset of the dim_axes_set() frozenset (which contains axes labels corresponding to coordinate dimensions only) that includes axes labels corresponding to scalar coordinates.

build_axes(*coords, verify=True)

Constructs a dict mapping axes labels to dimension coordinates (of type AbstractDMCoordinate.)

change_coord(ax_name, new_class=None, **kwargs)

Replace attributes on a given coordinate, but also optionally cast them to new classes.

Parameters:
  • ax_name – Name of the coordinate to modify.

  • new_class (optional) – new class to cast the returned coordinate to.

  • kwargs – Set of attribute names and values to replace on the returned copy.

component: str = ''
coords: InitVar = None
property dim_axes

Retrun dict mapping axes labels (‘X’, ‘Y’, etc.) to corresponding dimension coordinate objects.

property dim_axes_set

Return frozenset of dimension coordinate axes labels.

property full_name

Object’s full name, to be used in logging and debugging. Preferred because it eliminates irrelevant information in repr(), which is lengthy.

get_scalar(ax_name)

If the axis label ax_name is a scalar coordinate, return the corresponding AbstractDMCoordinate object, otherwise return None.

property is_static

Whether the variable has time dependence (bool).

modifier: str = ''
name: str = sentinel.Mandatory
remove_scalar(ax, position=-1, **kwargs)

Metadata operation that’s the inverse of add_scalar(). Given an axis label ax that’s currently a scalar coordinate, remove the slice value and add it to the list of dimension coordinates at position (default end of the list.)

rename_coords: bool = True
standard_name: str = sentinel.Mandatory
units: Units = ''
dims: list
scalar_coords: list
class src.data_model.DMDataSet(coords: InitVar = None, contents: InitVar = sentinel.Mandatory)[source]

Bases: _DMDimensionsMixin

Class to describe a collection of one or more variables sharing a set of common dimensions.

property T

Return T axis dimension coordinate if defined, else None.

property X

Return X axis dimension coordinate if defined, else None.

property Y

Return Y axis dimension coordinate if defined, else None.

property Z

Return Z axis dimension coordinate if defined, else None.

build_axes(*coords, verify=True)

Constructs a dict mapping axes labels to dimension coordinates (of type AbstractDMCoordinate.)

coords: InitVar = None
property dim_axes

Retrun dict mapping axes labels (‘X’, ‘Y’, etc.) to corresponding dimension coordinate objects.

property dim_axes_set

Return frozenset of dimension coordinate axes labels.

get_scalar(ax_name)

If the axis label ax_name is a scalar coordinate, return the corresponding AbstractDMCoordinate object, otherwise return None.

property is_static

Whether the variable has time dependence (bool).

dims: list
scalar_coords: list
contents: InitVar = sentinel.Mandatory

All members of the collection (input).

vars: list

List of dependent variables in the collection.

coord_bounds: list

List of bounds coordinates referenced by variables in the collection.

aux_coords: list

List of auxiliary coordinates referenced by variables in the collection.

iter_contents()[source]

Generator iterating over the full contents of the DataSet (variables, auxiliary coordinates and coordinate bounds.)

iter_vars()[source]

Generator iterating over variables and auxiliary coordinates but excluding coordinate bounds.

add_contents(*vars_)[source]
change_coord(ax_name, new_class=None, **kwargs)[source]

Replace attributes on a given coordinate (ax_name), but also optionally cast them to new classes.

Parameters:
  • ax_name – Name of the coordinate to modify.

  • new_class (optional) – new class to cast the returned coordinate to.

  • kwargs – Set of attribute names and values to replace on the returned copy.