cfdm.Constructs


class cfdm.Constructs(auxiliary_coordinate=None, dimension_coordinate=None, domain_ancillary=None, field_ancillary=None, cell_measure=None, coordinate_reference=None, domain_axis=None, domain_topology=None, cell_connectivity=None, cell_method=None, source=None, copy=True, _use_data=True, _view=False, _ignore=())[source]

Bases: cfdm.mixin.container.Container, cfdm.core.constructs.Constructs

A container for metadata constructs.

The container has similarities to a dict in that it presents the metadata constructs as key/value pairs, where the key is the unique identifier that corresponds to a metadata construct value; is indexable by metadata construct identifier; and provides a subset of the usual dictionary methods: get, items, keys, and values. The number of constructs (which may be zero) can be found via the Python len function. The container can be converted to an actual dict with the todict method.

Filtering

A subset of the metadata constructs can be defined and returned in a new Constructs instance by using the various filter methods. See filter for more details.

Calling

Calling a Constructs instance also creates a new Constructs instance that contains a subset of the metadata constructs, primarily selecting by construct identity. For instance, selecting constructs that have an identity of ‘latitude’ could be done by either x = c('latitude') or x = c.filter_by_identity('latitude'). More generally, c(*identities, **filter_kwargs) is equivalent to c.filter(filter_by_identity=identities, **filter_kwargs).

Metadata constructs

The following metadata constructs can be included:

  • domain axis constructs

  • dimension coordinate constructs

  • auxiliary coordinate constructs

  • coordinate reference constructs

  • domain ancillary constructs

  • cell measure constructs

  • domain topology constructs

  • cell connectivity constructs

  • cell method constructs

  • field ancillary constructs

New in version (cfdm): 1.7.0

Initialisation

Parameters
auxiliary_coordinate: str, optional

The base name for keys of auxiliary coordinate constructs.

Parameter example:

auxiliary_coordinate='auxiliarycoordinate'

dimension_coordinate: str, optional

The base name for keys of dimension coordinate constructs.

Parameter example:

dimension_coordinate='dimensioncoordinate'

domain_ancillary: str, optional

The base name for keys of domain ancillary constructs.

Parameter example:

domain_ancillary='domainancillary'

field_ancillary: str, optional

The base name for keys of field ancillary constructs.

Parameter example:

field_ancillary='fieldancillary'

cell_measure: str, optional

The base name for keys of cell measure constructs.

Parameter example:

cell_measure='cellmeasure'

coordinate_reference: str, optional

The base name for keys of coordinate reference constructs.

Parameter example:

coordinate_reference='coordinatereference'

domain_axis: str, optional

The base name for keys of domain axis constructs.

Parameter example:

domain_axis='domainaxis'

domain_topology: str, optional

The base name for keys of domain topology constructs.

Parameter example:

'domaintopology'

New in version (cfdm): 1.11.0.0

cell_connectivity: str, optional

The base name for keys of cell connectivity constructs.

Parameter example:

'cellconnectivity'

New in version (cfdm): 1.11.0.0

cell_method: str, optional

The base name for keys of cell method constructs.

Parameter example:

cell_method='cellmethod'

source: optional

Convert source, which can be any type of object, to a Constructs instance.

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the Constructs API. Any parameters that can not be retrieved from source in this way are assumed to have their default value.

Note that if x is also a Constructs instance then cfdm.Constructs(source=x) is equivalent to x.copy().

copy: bool, optional

If True (the default) then deep copy metadata constructs from those of source prior to initialisation, else they are not deep copied.

_ignore: sequence of str, optional

Ignores the given construct types.

Parameter example:

_ignore=('cell_method', 'field_ancillary')

Filtering

Methods

filter_by_identity

Select metadata constructs by identity.

filter_by_property

Select metadata constructs by property.

filter_by_measure

Select cell measure constructs by measure.

filter_by_method

Select cell method constructs by method.

filter_by_cell

Select domain topology constructs by cell type.

filter_by_connectivity

Select cell connectivity constructs by connectivity type.

filter_by_axis

Select metadata constructs by axes spanned by their data.

filter_by_naxes

Selects constructs by the number of axes their data spans.

filter_by_size

Select domain axis constructs by size.

filter_by_data

Selects metadata constructs that could contain data.

filter_by_type

Select metadata constructs by type.

filter_by_key

Select metadata constructs by key.

filter_by_ncdim

Select domain axis constructs by netCDF dimension name.

filter_by_ncvar

Select domain axis constructs by netCDF variable name.

filter

Select metadata constructs by a chain of filters.

domain_axes

Return domain axis constructs.

filters_applied

A history of filters that have been applied.

clear_filters_applied

Remove the history of filters that have been applied.

inverse_filter

Return the inverse of previous filters.

unfilter

Return the constructs that existed prior to previous filters.

Constructs and identifiers

Methods

key

Return the construct key of the sole metadata construct.

value

Return the sole metadata construct.

construct_type

Return the type of a construct for a given key.

construct_types

Return all of the construct types for all keys.

domain_axis_identity

Return the canonical identity for a domain axis construct.

new_identifier

Return a new, unused construct key.

Data axes

Methods

data_axes

Returns the axes spanned by the data.

get_data_axes

Return the keys of the axes spanned by a construct’s data.

Miscellaneous

Methods

copy

Return a deep copy.

shallow_copy

Return a shallow copy.

equals

Whether two Constructs instances are the same.

replace

Replace one metadata construct with another.

todict

Return a dictionary of the metadata constructs.

ordered

Return the constructs in their predetermined order.

Dictionary-access methods

Methods

get

Returns the construct for the key, else default.

items

Return the items as (construct key, construct) pairs.

keys

Return all of the construct keys, in arbitrary order.

values

Return all of the metadata constructs, in arbitrary order.

__getitem__

Return a construct with the given key.

Special

Methods

__call__

Select metadata constructs by identity.

__contains__

Implements membership test operators for construct keys.

__copy__

Called by the copy.copy standard library function.

__deepcopy__

Called by the copy.deepcopy standard library function.

__getitem__

Return a construct with the given key.

__iter__

Called when an iterator is required.

__len__

Return the number of constructs.

__repr__

Called by the repr built-in function.

__str__

Called by the str built-in function.

Docstring substitutions

Methods

_docstring_special_substitutions

Return the special docstring substitutions.

_docstring_substitutions

Returns the substitutions that apply to methods of the class.

_docstring_package_depth

Returns the class {{package}} substitutions package depth.

_docstring_method_exclusions

Returns method names excluded in the class substitutions.