Bases: cf.utils.CfList
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 space.
Initialization
Parameters : |
|
---|
Examples
>>> c = CellMethods()
>>> c = CellMethods('time: max: height: mean')
CellMethods methods (undocumented methods behave exactly as their counterparts in a built-in list)
append | |
copy | Return a deep copy. |
count | Return the number of occurrences of a given value. |
dump | Return a string containing a full description of the instance. |
equals | True if two cell methods are equal, False otherwise. |
extend | |
has_cellmethods | Return True if and only if this cell methods is a super set of another. |
index | Return the first index of a given value. |
insert | Insert an object before the given index in place. |
netCDF_translation | Translate netCDF variable names. |
parse | Parse a CF cell_methods string into this CellMethods instance in |
pop | |
remove | |
reverse | |
strings | Return a list of a CF-netCDF-like string of each cell method. |
Return a deep copy.
Equivalent to copy.deepcopy(s).
Returns : |
|
---|
Examples
>>> s.copy()
Return the number of occurrences of a given value.
Uses numerically tolerant equality where appropriate.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> s
[1, 2, 3, 2, 4, 2]
>>> s.count(1)
1
>>> s.count(2)
3
Return a string containing a full description of the instance.
If a cell methods ‘name’ is followed by a ‘*’ then that cell method is relevant to the data in a way which may not be precisely defined its corresponding dimension or dimensions.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> x = c.dump()
>>> print c.dump()
>>> print c.dump(id='cellmethods1')
True if two cell methods are equal, False otherwise.
The dim attribute is ignored in the comparison.
Parameters : |
|
---|---|
Returns : |
|
Examples
True if two cell methods are equivalent, False otherwise.
The dim attribute is ignored in the comparison.
Parameters : |
|
---|---|
Returns : |
|
Examples
Return True if and only if this cell methods is a super set of another.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> c = cf.CellMethods('time: mean height: mean area: mean')
>>> d = cf.CellMethods('area: mean time: mean')
>>> c.has_cellmethods(d)
True
Return the first index of a given value.
Uses numerically tolerant equality where appropriate.
Parameters : |
|
---|---|
Returns : | out : int |
Raises : |
|
Examples
>>> s
[1, 2, 3, 2, 4, 2]
>>> s.index(1)
1
>>> s.index(2, 2)
3
>>> s.index(2, start=2, stop=5)
3
>>> s.index(6)
ValueError: CfList doesn't contain: 6
Insert an object before the given index in place.
Parameters : | index : int item : |
---|---|
Returns : | None |
Examples
>>> s
[1, 2, 3]
>>> s.insert(1, 'A')
>>> s
[1, 'A', 2, 3]
>>> s.insert(100, 'B')
[1, 'A', 2, 3, 'B']
>>> s.insert(100, 'B')
[1, 'A', 2, 3, 'B']
>>> s.insert(-2, 'C')
[1, 'A', 2, 'C', 3, 'B']
>>> s.insert(-100, 'D')
['D', 1, 'A', 2, 'C', 3, 'B']
Translate netCDF variable names.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> c = CellMethods('time: mean lon: mean')
>>> d = c.netCDF_translation(f)
Parse a CF cell_methods string into this CellMethods instance in place.
Parameters : |
|
---|---|
Returns : | None |
Examples
>>> c = cf.CellMethods()
>>> c = c.parse('time: minimum within years time: mean over years (ENSO years)')
>>> print c
Cell methods : time: minimum within years
time: mean over years (ENSO years)
Return a list of a CF-netCDF-like string of each cell method.
Note that if the intention is to concatenate the output list into a string for creating a CF-netCDF cell_methods attribute, then the cell methods “name” components may need to be modified, where appropriate, to reflect netCDF variable names.
Returns : |
|
---|
Examples
>>> c = cf.CellMethods('time: minimum within years time: mean over years (ENSO years)')
>>> c.strings()
['time: minimum within years',
'time: mean over years (ENSO years)']