cf.CellMethods

class cf.CellMethods(cell_methods=None)[source]

Bases: _abcoll.MutableSequence

A CF cell methods object to describe the characteristic of a field that is represented by cell values.

Each cell method is stored in a dictionary and these dictionaries are stored in a list-like object. Similarly to a CF cell_methods string, the order of cell methods in the list is important.

The dictionary representing each cell method recognizes the following keys (where all keys are optional; the referenced sections are from the NetCDF Climate and Forecast (CF) Metadata Conventions and words in double quotes (”...”) refer to CF cell_methods components in the referenced sections):

Statistics for a combination of axes

The names of the dimensions involved in a combination of axes are given as a list (although their order is immaterial), with corresponding dimension identifiers:

>>> c
<CF CellMethods: latitude: longitude: mean>
>>> list(c)
[{'method'   : 'mean',
  'name'     : ['latitude', 'longitude'],     
  'dim'      : ['dim2, 'dim3']}]

If the string ‘area’ is used to indicate variation over horizontal area, then the corresponding dimension is None:

>>> c
<CF CellMethods: area: mean>
>>> list(c)
[{'method'   : 'mean',
  'name'     : ['area'],     
  'dim'      : [None]}]

Cell methods when there are no coordinates

These have name strings which are standard names or the string ‘area’, with corresponding dimension identifiers of None:

>>> c
<CF CellMethods: time: max>
>>> list(c)
[{'method'   : 'max',
  'name'     : ['time'],     
  'dim'      : [None]}]
>>> c
<CF CellMethods: lat: longitude: mean>
>>> list(c)
[{'method'   : 'mean',
  'name'     : ['lat', 'longitude','],     
  'dim'      : ['dim1', None]}]
>>> c
<CF CellMethods: area: mean>
>>> list(c)
[{'method'   : 'minimum',
  'name'     : ['area'],     
  'dim'      : [None]}]

In the case of ‘area’, there is no distinction between this cell method and one for which there appropriate dimensions exist, but the two cases may be discerned by inspection of the field’s domain.

Initialization

Parameters :
string : str, optional

Initialize new instance from a CF-netCDF-like cell methods string. See the parse method for details. By default an empty cell methods is created.

Examples

>>> c = CellMethods()
>>> c = CellMethods('time: max: height: mean')

CellMethods methods

Undocumented methods behave exactly as their counterparts in a built-in list.

copy Return a deep copy.
dump Return a string containing a full description of the instance.
equals True if two cell methods are equal, False otherwise.
equivalent True if two cell methods are equivalent, False otherwise.
has_cellmethod Return True if and only if this cell methods is a super set of another.
netcdf_translation Translate netCDF variable names.
parse Parse a CF cell_methods string into this CellMethods instance in
strings Return a list of a CF-netCDF-like string of each cell method.

CellMethods list-like methods

These methods provide functionality exactly as their counterparts in a built-in list.

append
count
extend
index
insert
pop
remove
reverse

Table Of Contents

Previous topic

cf.CellMeasure.transpose

Next topic

cf.CellMethods.copy

This Page