cf.Field.coordinate_reference

Field.coordinate_reference(identity=None, default=ValueError(), key=False)[source]

Return a coordinate reference construct, or its key.

New in version 3.0.0.

Parameters
identity: optional

Select the coordinate reference construct by one of:

  • None. This is the default, which selects the coordinate reference construct when there is only one of them.

  • The identity or key of a coordinate reference construct.

A construct identity is specified by a string (e.g. 'grid_mapping_name:latitude_longitude', 'latitude_longitude', 'ncvar%lat_lon', etc.); a Query object (e.g. cf.eq('latitude_longitude')); or a compiled regular expression (e.g. re.compile('^atmosphere')) that selects the relevant constructs whose identities match via re.search.

Each construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its identities method. In the following example, the construct x has two identities:

>>> x.identities()
['grid_mapping_name:latitude_longitude', 'ncvar%lat_lon']

A identity’s prefix of 'grid_mapping_name:' or 'standard_name:' may be omitted (e.g. 'standard_name:atmosphere_hybrid_height_coordinate' and 'atmosphere_hybrid_height_coordinate' are both acceptable identities).

A construct key may optionally have the 'key%' prefix. For example 'coordinatereference2' and 'key%coordinatereference2' are both acceptable keys.

Note that in the output of a print call or dump method, a construct is always described by one of its identities, and so this description may always be used as an identity argument.

Parameter example:

identity='standard_name:atmosphere_hybrid_height_coordinate'

Parameter example:

identity='grid_mapping_name:rotated_latitude_longitude'

Parameter example:

identity='transverse_mercator'

Parameter example:

identity='coordinatereference1'

Parameter example:

identity='key%coordinatereference1'

Parameter example:

identity='ncvar%lat_lon'

key: bool, optional

If True then return the selected construct key. By default the construct itself is returned.

default: optional

Return the value of the default parameter if a construct can not be found. If set to an Exception instance then it will be raised instead.

Returns
CoordinateReference or str

The selected coordinate reference construct, or its key.

Examples:

TODO