Bases: cf.space.CfDict
A CF grid object defining a space’s dimensionality, coordinates, cell measures and transformations in a dictionary-like object.
Parameters: |
|
---|
Overloaded operators
The in (set membership) operator is overloaded to use numerically tolerant equality.
Attribute | (type) Description |
---|---|
dimension_sizes | (dict) See the ‘Grid dimensionality’ section. |
dimensions | (dict) See the ‘Grid dimensionality’ section. |
nc_dimensions | (dict) Optional. The netCDF dimension name for each dimension in the dimension_sizes attribute. If present when the grid is written to a netCDF file, then used for output netCDF dimension names. |
transform | (dict) Optional. A cf dictionary of Transform objects referred to by grid coordinates with a transform attribute. See the ‘Transforms’ section for more details. |
_atol | (NoneType or float) Optional. Absolute tolerance for numeric equality. Unset is equivalent to None, which implies a default value. Refer to cf. |
_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 |
---|---|
clear() | As for a built-in dict. |
coord() | Return a coordinate identified by its name. |
copy() | Create a deep copy. |
equals() | Determine whether two instances are congruent with each other. |
get() | As for a built-in dict. |
get_keys() | Return grid keys which match a` pattern. |
has_key() | As for a built-in dict but using numerically tolerant equality. |
items() | As for a built-in dict. |
iteritems() | As for a built-in dict. |
iterkeys() | As for a built-in dict. |
itervalues() | As for a built-in dict. |
keys() | As for a built-in dict. |
pop() | As for a built-in dict. |
popitem() | As for a built-in dict. |
properties() | Return a set of writable, public attributes. |
setdefault() | As for a built-in dict. |
update() | As for a built-in dict. |
values() | As for a built-in dict. |
Find a coordinate of the grid by name.
The given name argument is an abbreviation for (or equal to if the exact parameter is True) its standard_name attribute. If the key parameter is True then return the coordinate’s grid key name. If a coordinate does not have standard_name attribute, then its ncvar attribute is used.
Note that the returned coordinate is an object identity to the coordinate stored in the grid so, for example, a coordinate’s attributes may be changed in-place as follows:
>>> g.coord('height').long_name
AttributeError: 'Coordinate' object has no attribute 'long_name'
>>> g.coord('hei').long_name = 'HEIGHT'
>>> g.coord('heigh').long_name
'HEIGHT'
Or a deep copy may be made with the coordinate’s copy() method:
>>> h = g.coord('height').copy()
Parameters: |
|
---|---|
Returns: | If a coordinate has been identified, return either a Coordinate instance or, if the keys parameter is True, a grid key name string. otherwise, return None. |
Examples
>>> g.coord('lon')
<CF Coordinate: longitude(128)>
>>> g.coord('lon', key=True)
'dim2'
>>> g.coord('lonX', key=True)
None
>>> g.coord('lon', exact=True)
None
>>> g.coord('longitude', exact=True)
<CF Coordinate: longitude(128)>
Return a string containing a full description of the grid.
Parameters: |
|
---|---|
Returns: | A string containing the description of the grid. |
See also
Return True if two instances are congruent in that, for each group of grid component types (dimension coordinate, auxiliary coordinate, cell measures, etc.) there are an equal number of keys and each key’s value equals a value in the other grid. Note that within a group of component types, the key names need not be the same.
Equality of numbers is to within a tolerance. Refer to cf for details.
Parameters: |
|
---|---|
Returns: | True if the two objects are congruent, False otherwise. |
Return a list of the cf dictionary’s key names which, at their beginning, match the given regular expression.
Parameters: | regex (str) – The regular expression with which to identify key names. A leading ‘^’ special character is assumed if not given. |
---|---|
Returns: | A list of keys names. |
Examples
>>> d.keys()
['dim2', 'dim0', 'dim1', 'aux0', 'cm0']
>>> d.get_keys('dim')
['dim2', 'dim0', 'dim1']
>>> d.get_keys('aux|dim')
['dim2', 'dim0', 'dim1', 'aux0']
>>> d.get_keys('dim[12]')
['dim2', 'dim1']
Returns: | True if the key exists, using numerically tolerant equality. |
---|
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. |