Bases: cf.utils.Dict
A CF coordinate reference construct.
A coordinate reference construct relates the field’s coordinate values to locations in a planetary reference frame.
The coordinate reference object is associated with a coordinate system and contains links to the dimension or auxiliary coordinate constructs to which it applies; and any additional terms, such as parameter values and field objects which define a datum and coordinate conversion, i.e. a formula for converting coordinate values taken from the dimension or auxiliary coordinate objects to a different coordinate system.
Accessing terms
The coordinate reference object behaves like a dictionary when it comes to accessing its terms and their values: For example:
>>> c = cf.CoordinateReference('azimuthal_equidistant',
... longitude_of_projection_origin=80.5,
... latitude_of_projection_origin=5,
... false_easting=cf.Data(-200, 'km'),
... false_northing=cf.Data(-100, 'km'))
>>> c.keys()
['false_easting',
'latitude_of_projection_origin',
'false_northing',
'longitude_of_projection_origin']
>>> c.items()
[('false_easting', <CF Data: -200 km>),
('latitude_of_projection_origin', 5),
('false_northing', <CF Data: -100 km>),
('longitude_of_projection_origin', 80.5)]
>>> c['latitude_of_projection_origin']
5
>>> c['latitude_of_projection_origin'] = -75.25
>>> c['latitude_of_projection_origin']
-75.25
Attributes
Attribute | Description |
---|---|
name | The identity of the coordinate reference. |
type | The CF type of the coordinate reference. |
coords | The identities of the dimension and auxiliary coordinate objects of the which apply to this coordinate reference. |
coord_terms | The terms of the coordinate conversion which refer to dimension or auxiliary coordinate objects. |
Initialization
Parameters: |
|
---|
Initialization
Parameters: |
|
---|
Methods
__init__([name, crtype, coords, coord_terms]) | Initialization |
canonical_units(term) | Return the canonical units for a standard CF coordinate conversion term. |
change_coord_identities(coord_map) | Change the idientifier of all coordinates. |
clear(() -> None. Remove all items from D.) | |
close() | Close all files referenced by coordinate conversion term values. |
copy([domain]) | Return a deep copy. |
default_value(term) | Return the default value for an unset standard CF coordinate conversion term. |
dump([complete, display, _level, domain]) | Return a string containing a full description of the coordinate reference. |
equals(other[, rtol, atol, ...]) | True if two instances are equal, False otherwise. |
equivalent(other[, atol, rtol, traceback]) | True if two coordinate references are logically equal, False otherwise. |
get((k[,d]) -> D[k] if k in D, ...) | |
has_key(key) | |
identity([default]) | Return the identity of the coordinate reference. |
inspect() | Inspect the attributes. |
items(() -> list of D’s (key, value) pairs, ...) | |
iteritems(() -> an iterator over the (key, ...) | |
iterkeys(() -> an iterator over the keys of D) | |
itervalues(...) | |
keys(() -> list of D’s keys) | |
match([match, exact, match_all, inverse]) | Test whether or not the coordinate reference satisfies the given conditions. |
pop((k[,d]) -> v, ...) | If key is not found, d is returned if given, otherwise KeyError is raised. |
popitem(() -> (k, v), ...) | as a 2-tuple; but raise KeyError if D is empty. |
remove_all_coords() | Remove all links to coordinate objects. |
set(term, value) | |
setcoord(term, value) | |
setdefault((k[,d]) -> D.get(k,d), ...) | |
structural_signature([rtol, atol]) | |
update(([E, ...) | If E present and has a .keys() method, does: for k in E: D[k] = E[k] |
values(() -> list of D’s values) |
Attributes
T | False. |
X | Returns False. |
Y | Returns False. |
Z | Returns False. |
hasbounds | False |
Return the canonical units for a standard CF coordinate conversion term.
Parameters: |
|
---|---|
Returns: |
|
Examples: |
>>> cf.CoordinateReference.canonical_units('perspective_point_height')
<CF Units: m>
>>> cf.CoordinateReference.canonical_units('ptop')
None
Change the idientifier of all coordinates.
If a coordinate identifier is not in the provided mapping then it is set to None and thus effectively removed from the coordinate reference.
Parameters: |
|
---|---|
Returns: | None |
Examples: |
>>> r = cf.CoordinateReference('atmosphere_hybrid_height_coordinate',
... coord_terms=['a', 'b'],
... a='ncvar:ak',
... b='ncvar:bk')
>>> r.coords
{'atmosphere_hybrid_height_coordinate', 'ncvar:ak', 'ncvar:bk'}
>>> r.change_coord_identitiers({'atmosphere_hybrid_height_coordinate', 'dim1',
... 'ncvar:ak': 'aux0'})
>>> r.coords
{'dim1', 'aux0'}
Close all files referenced by coordinate conversion term values.
Returns: | None |
---|---|
Examples: |
>>> c.close()
Return a deep copy.
c.copy() is equivalent to copy.deepcopy(c).
Returns: |
|
---|---|
Examples: |
>>> d = c.copy()
Return the default value for an unset standard CF coordinate conversion term.
The default values are stored in the file cf/etc/coordinate_reference/default_values.txt.
Parameters: |
|
---|---|
Returns: |
|
Examples: |
>>> cf.CoordinateReference.default_value('ptop')
0.0
>>> print cf.CoordinateReference.default_value('north_pole_grid_latitude')
None
Return a string containing a full description of the coordinate reference.
Parameters: | complete : bool, optional
domain : cf.Domain, optional |
---|---|
Returns: |
|
Examples: |
True if two instances are equal, False otherwise.
Parameters: |
|
---|---|
Returns: |
|
Examples: |
True if two coordinate references are logically equal, False otherwise.
Parameters: |
|
---|---|
Returns: |
|
Examples: |
>>>
Return the identity of the coordinate reference.
The identity is the standard_name of a formula_terms-type coordinate reference or the grid_mapping_name of grid_mapping-type coordinate reference.
Parameters: |
|
---|---|
Returns: |
|
Examples: |
>>> c.identity()
'rotated_latitude_longitude'
>>> c.identity()
'atmosphere_hybrid_height_coordinate'
Test whether or not the coordinate reference satisfies the given conditions.
Returns: |
|
---|---|
Examples: |
If key is not found, d is returned if given, otherwise KeyError is raised.
as a 2-tuple; but raise KeyError if D is empty.
Remove all links to coordinate objects.
All terms linked to coordinate objects are set to None.
Returns: | None |
---|---|
Examples: |
>>> c.remove_all_coords()
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
False.
Provides compatibility with the cf.Coordinate API.
See also
cf.Coordinate.T, X, Y, Z
Examples: |
---|
>>> c.T
False
Returns False.
Provides compatibility with the cf.Coordinate API.
See also
cf.Coordinate.X, T, Y, Z
Examples: |
---|
>>> c.X
False
Returns False.
Provides compatibility with the cf.Coordinate API.
See also
cf.Coordinate.Y, T, X, Z
Examples: |
---|
>>> c.Y
False
Returns False.
Provides compatibility with the cf.Coordinate API.
See also
cf.Coordinate.Z, T, X, Y
Examples: |
---|
>>> c.Z
False
False
Examples: |
---|
>>> c.hasbounds
False