Bases: cf.space.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 NetCDF Climate and Forecast (CF) Metadata Conventions Version 1.5; and words in double quotes (”...”) refer to CF cell_methods components in the referenced sections):
Key | Value |
---|---|
method | A “method” component. Refer to section 7.3. |
name | A list of all of the “name” components involved with the “method” component. Each element is either:
Option 3. only occurs if the cell method’s dimension either has no dimension coordinate or has a dimension coordinate with no standard_name. This is a deviation from the “name” components as described in sections 7.3, 7.3.1 and 7.3.4, in that standard_names are stored whenever possible, rather than only in the special cases described in section 7.3.4. Inspection of the ‘no_coords’ list retains the information required to fully interpret the cell method. |
dim | A list of space dimension names corresponding to the ‘name’ list. A ‘name’ list value of ‘area’ always corresponds to a ‘dim’ list value of None. |
no_coords | A list of booleans, corresponding to the ‘name’ list, indicating whether or not a particular cell method is relevant to the data in a way which may not be precisely defined by the corresponding dimension or dimensions. Refer to section 7.3.4. |
interval | A list of “interval” component values corresponding to the ‘name’ list. Refer to section 7.3.2. |
units | A list of “interval” component units corresponding to the ‘interval’ list. Refer to section 7.3.2. |
comment | A “comment” or non-standardised information, component. Refer to sections 7.3.2 and 7.4 |
within | A “within” climatology component. Refer to section 7.4. |
over | An “over” cell portion or “over” climatology component. Refer to sections 7.3.3 and 7.4. |
where | A “where” component. Refer to section 7.3.3. |
Note that the above table assumes that the cell methods have been constructed in the context of a space, the only way in which the ‘dim’ and ‘no_coords’ keys may take sensible values. If this is not the case, as would happen if the parse() method were called without its space keyword, then elements of the ‘dim’ key default to False and elements of the ‘no_coords’ key default to None.
Parameters: | sequence (sequence) – Optional. Initialize new list from sequence’s items. |
---|
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)
>>> list(c)
[
{'method' : 'minimum',
'name' : ['time'],
'dim' : [False],
'no_coords': [None],
'within' : 'years'
},
{'method' : 'mean'
'name' : ['time'],
'dim' : [False],
'no_coords': [None],
'comment' : 'ENSO years',
'over' : 'years'
}
]
>>> c = c.parse('lat: lon: standard_deviation')
>>> list(c)
[
{'dim' : [False, False],
'method' : 'standard_deviation'
'name' : ['lat', 'lon'],
'no_coords': [None, None],
}
]
Overloaded operators
Refer to CfList.
Attribute | (type) Description |
---|---|
_atol | (NoneType or float) Optional. Absolute tolerance for numeric equality. Unset is equivalent to None, which implies a default value. Refer to cf. |
_elements_atts | (bool) If True then do not raise an exception when requesting a non-existent attribute, but broadcast the request to each element of the list. |
_rtol | (NoneType or float) Optional. Relative tolerance for numeric equality. Unset is equivalent to None, which implies a default value. Refer to cf. |
Method | Description |
---|---|
append() | As for a built-in list. |
copy() | Create a deep copy. |
count() | As for a built-in list but using numerically tolerant equality. |
dump() | Return a string containing a full description of the object. |
equals() | Determine whether two lists are congruent element-wise. |
extend() | As for a built-in list. |
index() | As for a built-in list but using numerically tolerant equality. |
insert() | As for a built-in list. |
parse() | Parse a netCDF(CF) cell_methods string. |
pop() | As for a built-in list. |
properties() | Return a set of writable, public attributes. |
remove() | As for a built-in list. |
reverse() | As for a built-in list. |
sort() | As for a built-in list. |
strings() | Convert each element to a string. |
Create a deep copy of the list. Equivalent to calling copy.deepcopy on the list.
Returns: | A deep copy of the list. |
---|
Returns: | The number of occurrences of value using numerically tolerant equality. |
---|
Return a string containing a full description of the cell methods.
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: | A string containing the description of the cell methods. |
See also
Return True if two instances are congruent in that each pair of their elements are equal.
Equality of numbers is to within a tolerance. Refer to cf for details.
Parameters: |
|
---|---|
Returns: | True if the two objects are congruent, False otherwise. |
Returns: | The first index of value using numerically tolerant equality. Restrict the search to the slice start:stop. If stop is None then the slice is :obj:`start:`cf. |
---|
L.insert(index, object) – insert object before index
Parse a CF cell_methods string into this CellMethods instance.
Parameters: |
|
---|---|
Returns: | A cell methods list. |
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 set of writable, public attribute names, excluding methods.
An attribute created by assigning directly to the __dict__ dictionary (as opposed to using setattr()) will not appear in this set.
Parameters: | nc (bool) – If False then exclude attributes whose names begin “nc”. |
---|---|
Returns: | A set of attribute names. |
Convert each element of the cell methods list to a netCDF(CF) cell_methods-like string.
Note that if the intention is to concatenate the output list into a string for creating a netCDF(CF) cell_methods attribute, then the cell methods “name” components may need to be modified, where appropriate, to reflect netCDF variable names. This is done automatically by the write() function when creating a file on disk.
Returns: | A built-in list of cell method strings. |
---|
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)
>>> c.strings()
['time: minimum within years',
'time: mean over years (ENSO years)']