class cf.CoordinateReference(name=None, crtype=None, coordinates=None, ancillaries=None, parameters=None, datum=None)[source]

Bases: 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 scalar 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()
>>> 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']
>>> c['latitude_of_projection_origin'] = -75.25
>>> c['latitude_of_projection_origin']


Attribute Description
name The identity of the coordinate reference.
type The CF type of the coordinate reference.
coordinates The identities of the dimension and auxiliary coordinate objects of the which apply to this coordinate reference.


name: str, optional

A name which describes the nature of the coordinate conversion. This is usually a CF grid_mapping name or the standard name of a CF dimensionless vertical coordinate, but is not restricted to these.

Example: To create a polar stereographic coordinate reference: name='polar_stereographic'. To create coordinate reference for an ocean sigma over z coordinate: name='ocean_sigma_z_coordinate'. To create new type of coordinate reference: name='my_new_type'.

crtype: str, optional

The CF type of the coordinate reference. This is either 'grid_mapping' or 'formula_terms'. By default the type is inferred from the name, if possible. For example:

>>> c = cf.CoordinateReference('transverse_mercator')
>>> c.type
>>> c = cf.CoordinateReference('my_new_type', crtype='formula_terms')
>>> c.type
>>> c = cf.CoordinateReference('my_new_type')
>>> print c.type
>>> c = cf.CoordinateReference('my_new_type', crtype='grid_mapping')
>>> print c.type
coordinates: sequence of str, optional

Identify the dimension and auxiliary coordinate objects which apply to this coordinate reference. By default the standard names of those expected by the CF conventions are used. For example:

>>> c = cf.CoordinateReference('transverse_mercator')
>>> c.coordinates
{'latitude', 'longitude', 'projection_x_coordinate', 'projection_y_coordinate'}
>>> c = cf.CoordinateReference('transverse_mercator', coordinates=['ncvar%lat'])
>>> c.coordinates
{'ncvar%lat', 'latitude', 'longitude', 'projection_x_coordinate', 'projection_y_coordinate'}
kwargs: optional

The terms of the coordinate conversion and their values. A term’s value may be one of the following:

  • A number or size one numeric array.
  • A string containing a coordinate object’s identity.
  • A Field.
  • None, indicating that the term exists but is unset.

For example:

>>> c = cf.CoordinateReference('orthographic', 
...                            grid_north_pole_latitude=70,
...                            grid_north_pole_longitude=cf.Data(120, 'degreesE'))
>>> c['grid_north_pole_longitude']
<CF Data: 120 degreesE>
>>> orog_field
<CF Field: surface_altitude(latitude(73), longitude(96)) m>
>>> c = cf.CoordinateReference('atmosphere_hybrid_height_coordinate',
...                            a='long_name:ak',
...                            b='long_name:bk',
...                            orog=orog_field)


T False.
X False.
Y False.
Z False.
hasbounds False.


canonical_units(term) Return the canonical units for a standard CF coordinate conversion term.
clear([coordinates, parameters, ancillaries])
close() Close all files referenced by coordinate conversion term values.
copy() Return a deep copy.
default_value(term) Return the default value for an unset standard CF coordinate conversion term.
dump([display, omit, field, key, _level, _title]) Return a string containing a full description of the coordinate reference object.
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.
identity([default]) Return the identity of the coordinate reference.
inspect() Inspect the attributes.
match([match, exact, match_all, inverse]) Test whether or not the coordinate reference satisfies the given conditions.
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
structural_signature([rtol, atol])
update([E, ]**F) 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 in F: D[k] = F[k]