# iris.coords#

Definitions of coordinates and other dimensional metadata.

In this module:

Superclass for dimensional metadata.

classiris.coords.AncillaryVariable(data,standard_name=None,long_name=None,var_name=None,units=None,attributes=None)[source]#Constructs a single ancillary variable.

Args:

- data:
The values of the ancillary variable.

Kwargs:

- standard_name:
CF standard name of the ancillary variable.

- long_name:
Descriptive name of the ancillary variable.

- var_name:
The netCDF variable name for the ancillary variable.

- units
The

`Unit`

of the ancillary variable’s values. Can be a string, which will be converted to a Unit object.

- attributes
A dictionary containing other cf and user-defined attributes.

- __binary_operator__(
other,mode_constant)#Common code which is called by add, sub, mul and div

Mode constant is one of ADD, SUB, MUL, DIV, RDIV

Note

The unit is

notchanged when doing scalar operations on a metadata object. This means that a metadata object which represents “10 meters” when multiplied by a scalar i.e. “1000” would result in a metadata object of “10000 meters”. An alternative approach could be taken to multiply theunitby 1000 and the resultant metadata object would represent “10 kilometers”.

- __getitem__(
keys)#Returns a new dimensional metadata whose values are obtained by conventional array indexing.

Note

Indexing of a circular coordinate results in a non-circular coordinate if the overall shape of the coordinate changes after indexing.

- convert_units(
unit)#Change the units, converting the values of the metadata.

- copy(
values=None)#Returns a copy of this dimensional metadata object.

Kwargs:

- values
An array of values for the new dimensional metadata object. This may be a different shape to the original values array being copied.

- core_data()[source]#
The data array at the core of this ancillary variable, which may be a NumPy array or a dask array.

- cube_dims(
cube)[source]#Return the cube dimensions of this AncillaryVariable.

Equivalent to “cube.ancillary_variable_dims(self)”.

- has_bounds()#
Return a boolean indicating whether the current dimensional metadata object has a bounds array.

- has_lazy_data()[source]#
Return a boolean indicating whether the ancillary variable’s data array is a lazy dask array or not.

- is_compatible(
other,ignore=None)#Return whether the current dimensional metadata object is compatible with another.

- lazy_data()[source]#
Return a lazy array representing the ancillary variable’s data.

Accessing this method will never cause the data values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the ancillary variable to have loaded data.

If the data have already been loaded for the ancillary variable, the returned Array will be a new lazy array wrapper.

- Returns
A lazy array, representing the ancillary variable data array.

- name(
default=None,token=False)#Returns a string name representing the identity of the metadata.

First it tries standard name, then it tries the long name, then the NetCDF variable name, before falling-back to a default value, which itself defaults to the string ‘unknown’.

Kwargs:

- default:
The fall-back string representing the default name. Defaults to the string ‘unknown’.

- token:
If True, ensures that the name returned satisfies the criteria for the characters required by a valid NetCDF name. If it is not possible to return a valid name, then a ValueError exception is raised. Defaults to False.

- Returns
String.

- rename(
name)#Changes the human-readable name.

If ‘name’ is a valid standard name it will assign it to

`standard_name`

, otherwise it will assign it to`long_name`

.

- summary(
shorten=False,max_values=None,edgeitems=2,linewidth=None,precision=None,convert_dates=True,_section_indices=None)#Make a printable text summary.

- Parameters

shorten(bool,default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.

max_values(intorNone,default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if`shorten`

=True, or 15 otherwise. This overrides`numpy.get_printoptions['threshold']`

.

linewidth(intorNone,default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to`numpy.get_printoptions['linewidth']`

.

edgeitems(int = 2) – Controls truncated array output. Overrides`numpy.getprintoptions['edgeitems']`

.

precision(intorNone,default = None) – Controls number decimal formatting. When`shorten`

=True this is defaults to 3, in which case it overrides`numpy.get_printoptions()['precision']`

.

convert_dates(bool,default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.- Returns

result– Output text, with embedded newlines when`shorten`

=False.- Return type
Note

Arrays are formatted using

`numpy.array2string()`

. Some aspects of the array formatting are controllable in the usual way, via`numpy.printoptions()`

, but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.

- xml_element(
doc)#Create the

`xml.dom.minidom.Element`

that describes this`_DimensionalMetadata`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that will describe this`_DimensionalMetadata`

.

propertyattributes#

propertydata#

propertydtype#The NumPy dtype of the current dimensional metadata object, as specified by its values.

propertylong_name#The CF Metadata long name for the object.

propertymetadata#

propertyndim#Return the number of dimensions of the current dimensional metadata object.

propertyshape#The fundamental shape of the metadata, expressed as a tuple.

propertystandard_name#The CF Metadata standard name for the object.

propertyunits#The S.I. unit of the object.

propertyvar_name#The NetCDF variable name for the object.

A CF auxiliary coordinate.

classiris.coords.AuxCoord(*args,**kwargs)[source]#Create a coordinate with

mutablepoints and bounds.Args:

- points:
The values (or value in the case of a scalar coordinate) for each cell of the coordinate.

Kwargs:

- standard_name:
CF standard name of the coordinate.

- long_name:
Descriptive name of the coordinate.

- var_name:
The netCDF variable name for the coordinate.

- units
The

`Unit`

of the coordinate’s values. Can be a string, which will be converted to a Unit object.

- bounds
An array of values describing the bounds of each cell. Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1D coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2) Note if the data is a climatology, climatological should be set.

- attributes
A dictionary containing other CF and user-defined attributes.

- coord_system
A

`CoordSystem`

representing the coordinate system of the coordinate, e.g., a`GeogCS`

for a longitude coordinate.

- climatological (bool):
When True: the coordinate is a NetCDF climatological time axis. When True: saving in NetCDF will give the coordinate variable a ‘climatology’ attribute and will create a boundary variable called ‘<coordinate-name>_climatology’ in place of a standard bounds attribute and bounds variable. Will set to True when a climatological time axis is loaded from NetCDF. Always False if no bounds exist.

- __binary_operator__(
other,mode_constant)#Common code which is called by add, sub, mul and div

Mode constant is one of ADD, SUB, MUL, DIV, RDIV

Note

The unit is

notchanged when doing scalar operations on a metadata object. This means that a metadata object which represents “10 meters” when multiplied by a scalar i.e. “1000” would result in a metadata object of “10000 meters”. An alternative approach could be taken to multiply theunitby 1000 and the resultant metadata object would represent “10 kilometers”.

- __getitem__(
keys)#Returns a new dimensional metadata whose values are obtained by conventional array indexing.

Note

Indexing of a circular coordinate results in a non-circular coordinate if the overall shape of the coordinate changes after indexing.

- cell(
index)#Return the single

`Cell`

instance which results from slicing the points/bounds with the given index.

- cells()#
Returns an iterable of Cell instances for this Coord.

For example:

for cell in self.cells(): ...

- collapsed(
dims_to_collapse=None)#Returns a copy of this coordinate, which has been collapsed along the specified dimensions.

Replaces the points & bounds with a simple bounded region.

- contiguous_bounds()#
Returns the N+1 bound values for a contiguous bounded 1D coordinate of length N, or the (N+1, M+1) bound values for a contiguous bounded 2D coordinate of shape (N, M).

Only 1D or 2D coordinates are supported.

Note

If the coordinate has bounds, this method assumes they are contiguous.

If the coordinate is 1D and does not have bounds, this method will return bounds positioned halfway between the coordinate’s points.

If the coordinate is 2D and does not have bounds, an error will be raised.

- convert_units(
unit)#Change the coordinate’s units, converting the values in its points and bounds arrays.

For example, if a coordinate’s

`units`

attribute is set to radians then:coord.convert_units('degrees')will change the coordinate’s

`units`

attribute to degrees and multiply each value in`points`

and`bounds`

by 180.0/\(\pi\).

- copy(
points=None,bounds=None)#Returns a copy of this coordinate.

Kwargs:

- points: A points array for the new coordinate.
This may be a different shape to the points of the coordinate being copied.

- bounds: A bounds array for the new coordinate.
Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1d coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2).

Note

If the points argument is specified and bounds are not, the resulting coordinate will have no bounds.

- core_bounds()#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- core_points()#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- cube_dims(
cube)#Return the cube dimensions of this Coord.

Equivalent to “cube.coord_dims(self)”.

classmethodfrom_coord(coord)#Create a new Coord of this type, from the given coordinate.

- guess_bounds(
bound_position=0.5)#Add contiguous bounds to a coordinate, calculated from its points.

Puts a cell boundary at the specified fraction between each point and the next, plus extrapolated lowermost and uppermost bound points, so that each point lies within a cell.

With regularly spaced points, the resulting bounds will also be regular, and all points lie at the same position within their cell. With irregular points, the first and last cells are given the same widths as the ones next to them.

Kwargs:

- bound_position:
The desired position of the bounds relative to the position of the points.

Note

An error is raised if the coordinate already has bounds, is not one-dimensional, or is not monotonic.

Note

Unevenly spaced values, such from a wrapped longitude range, can produce unexpected results : In such cases you should assign suitable values directly to the bounds property, instead.

- has_bounds()#
Return a boolean indicating whether the coord has a bounds array.

- has_lazy_bounds()#
Return a boolean indicating whether the coord’s bounds array is a lazy dask array or not.

- has_lazy_points()#
Return a boolean indicating whether the coord’s points array is a lazy dask array or not.

- intersect(
other,return_indices=False)#Returns a new coordinate from the intersection of two coordinates.

Both coordinates must be compatible as defined by

`is_compatible()`

.Kwargs:

- return_indices:
If True, changes the return behaviour to return the intersection indices for the “self” coordinate.

- is_compatible(
other,ignore=None)#Return whether the coordinate is compatible with another.

Compatibility is determined by comparing

`iris.coords.Coord.name()`

,`iris.coords.Coord.units`

,`iris.coords.Coord.coord_system`

and`iris.coords.Coord.attributes`

that are present in both objects.Args:

- other:
An instance of

`iris.coords.Coord`

,`iris.common.CoordMetadata`

or`iris.common.DimCoordMetadata`

.

- ignore:
A single attribute key or iterable of attribute keys to ignore when comparing the coordinates. Default is None. To ignore all attributes, set this to other.attributes.

- Returns
Boolean.

- is_contiguous(
rtol=1e-05,atol=1e-08)#Return True if, and only if, this Coord is bounded with contiguous bounds to within the specified relative and absolute tolerances.

1D coords are contiguous if the upper bound of a cell aligns, within a tolerance, to the lower bound of the next cell along.

2D coords, with 4 bounds, are contiguous if the lower right corner of each cell aligns with the lower left corner of the cell to the right of it, and the upper left corner of each cell aligns with the lower left corner of the cell above it.

Args:

- rtol:
The relative tolerance parameter (default is 1e-05).

- atol:
The absolute tolerance parameter (default is 1e-08).

- Returns
Boolean.

- is_monotonic()#
Return True if, and only if, this Coord is monotonic.

- lazy_bounds()#
Return a lazy array representing the coord bounds.

Accessing this method will never cause the bounds values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded bounds.

If the data have already been loaded for the coord, the returned Array will be a new lazy array wrapper.

- Returns
A lazy array representing the coord bounds array or None if the coord does not have bounds.

- lazy_points()#
Return a lazy array representing the coord points.

Accessing this method will never cause the points values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded points.

If the data have already been loaded for the coord, the returned Array will be a new lazy array wrapper.

- Returns
A lazy array, representing the coord points array.

- name(
default=None,token=False)#Returns a string name representing the identity of the metadata.

First it tries standard name, then it tries the long name, then the NetCDF variable name, before falling-back to a default value, which itself defaults to the string ‘unknown’.

Kwargs:

- default:
The fall-back string representing the default name. Defaults to the string ‘unknown’.

- token:
If True, ensures that the name returned satisfies the criteria for the characters required by a valid NetCDF name. If it is not possible to return a valid name, then a ValueError exception is raised. Defaults to False.

- Returns
String.

- nearest_neighbour_index(
point)#Returns the index of the cell nearest to the given point.

Only works for one-dimensional coordinates.

For example:

>>> cube = iris.load_cube(iris.sample_data_path('ostia_monthly.nc')) >>> cube.coord('latitude').nearest_neighbour_index(0) 9 >>> cube.coord('longitude').nearest_neighbour_index(10) 12Note

If the coordinate contains bounds, these will be used to determine the nearest neighbour instead of the point values.

Note

For circular coordinates, the ‘nearest’ point can wrap around to the other end of the values.

- rename(
name)#Changes the human-readable name.

If ‘name’ is a valid standard name it will assign it to

`standard_name`

, otherwise it will assign it to`long_name`

.

- summary(
shorten=False,max_values=None,edgeitems=2,linewidth=None,precision=None,convert_dates=True,_section_indices=None)#Make a printable text summary.

- Parameters

shorten(bool,default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.

max_values(intorNone,default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if`shorten`

=True, or 15 otherwise. This overrides`numpy.get_printoptions['threshold']`

.

linewidth(intorNone,default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to`numpy.get_printoptions['linewidth']`

.

edgeitems(int = 2) – Controls truncated array output. Overrides`numpy.getprintoptions['edgeitems']`

.

precision(intorNone,default = None) – Controls number decimal formatting. When`shorten`

=True this is defaults to 3, in which case it overrides`numpy.get_printoptions()['precision']`

.

convert_dates(bool,default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.- Returns

result– Output text, with embedded newlines when`shorten`

=False.- Return type
Note

Arrays are formatted using

`numpy.array2string()`

. Some aspects of the array formatting are controllable in the usual way, via`numpy.printoptions()`

, but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.

- xml_element(
doc)#Create the

`xml.dom.minidom.Element`

that describes this`Coord`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that will describe this`DimCoord`

.

propertyattributes#

propertybounds#The coordinate bounds values, as a NumPy array, or None if no bound values are defined.

Note

The shape of the bound array should be:

`points.shape + (n_bounds, )`

.

propertybounds_dtype#The NumPy dtype of the coord’s bounds. Will be None if the coord does not have bounds.

propertyclimatological#A boolean that controls whether the coordinate is a climatological time axis, in which case the bounds represent a climatological period rather than a normal period.

Always reads as False if there are no bounds. On set, the input value is cast to a boolean, exceptions raised if units are not time units or if there are no bounds.

propertycoord_system#The coordinate-system of the coordinate.

propertydtype#The NumPy dtype of the current dimensional metadata object, as specified by its values.

propertylong_name#The CF Metadata long name for the object.

propertymetadata#

propertynbounds#Return the number of bounds that this coordinate has (0 for no bounds).

propertyndim#Return the number of dimensions of the current dimensional metadata object.

propertypoints#The coordinate points values as a NumPy array.

propertyshape#The fundamental shape of the metadata, expressed as a tuple.

propertystandard_name#The CF Metadata standard name for the object.

propertyunits#The S.I. unit of the object.

propertyvar_name#The NetCDF variable name for the object.

An immutable representation of a single cell of a coordinate, including the sample point and/or boundary position.

Notes on cell comparison:

Cells are compared in two ways, depending on whether they are compared to another Cell, or to a number/string.

Cell-Cell comparison is defined to produce a strict ordering. If two cells are not exactly equal (i.e. including whether they both define bounds or not) then they will have a consistent relative order.

Cell-number and Cell-string comparison is defined to support Constraint matching. The number/string will equal the Cell if, and only if, it is within the Cell (including on the boundary). The relative comparisons (lt, le, ..) are defined to be consistent with this interpretation. So for a given value n and Cell cell, only one of the following can be true:

Similarly, n <= cell implies either n < cell or n == cell. And n >= cell implies either n > cell or n == cell.

classiris.coords.Cell(point=None,bound=None)[source]#Construct a Cell from point or point-and-bound information.

- __common_cmp__(
other,operator_method)[source]#Common method called by the rich comparison operators. The method of checking equality depends on the type of the object to be compared.

Cell vs Cell comparison is used to define a strict order. Non-Cell vs Cell comparison is used to define Constraint matching.

static__new__(cls,point=None,bound=None)[source]#Construct a Cell from point or point-and-bound information.

- contains_point(
point)[source]#For a bounded cell, returns whether the given point lies within the bounds.

Note

The test carried out is equivalent to min(bound) <= point <= max(bound).

- count(
value,/)#Return number of occurrences of value.

- index(
value,start=0,stop=9223372036854775807,/)#Return first index of value.

Raises ValueError if the value is not present.

- bound#
Alias for field number 1

- point#
Alias for field number 0

A CF Cell Measure, providing area or volume properties of a cell where these cannot be inferred from the Coordinates and Coordinate Reference System.

classiris.coords.CellMeasure(data,standard_name=None,long_name=None,var_name=None,units=None,attributes=None,measure=None)[source]#Constructs a single cell measure.

Args:

- data:
The values of the measure for each cell. Either a ‘real’ array (

`numpy.ndarray`

) or a ‘lazy’ array (`dask.array.Array`

).Kwargs:

- standard_name:
CF standard name of the coordinate.

- long_name:
Descriptive name of the coordinate.

- var_name:
The netCDF variable name for the coordinate.

- units
The

`Unit`

of the coordinate’s values. Can be a string, which will be converted to a Unit object.

- attributes
A dictionary containing other CF and user-defined attributes.

- measure
A string describing the type of measure. Supported values are ‘area’ and ‘volume’. The default is ‘area’.

- __binary_operator__(
other,mode_constant)#Common code which is called by add, sub, mul and div

Mode constant is one of ADD, SUB, MUL, DIV, RDIV

Note

The unit is

notchanged when doing scalar operations on a metadata object. This means that a metadata object which represents “10 meters” when multiplied by a scalar i.e. “1000” would result in a metadata object of “10000 meters”. An alternative approach could be taken to multiply theunitby 1000 and the resultant metadata object would represent “10 kilometers”.

- __getitem__(
keys)#Returns a new dimensional metadata whose values are obtained by conventional array indexing.

Note

Indexing of a circular coordinate results in a non-circular coordinate if the overall shape of the coordinate changes after indexing.

- convert_units(
unit)#Change the units, converting the values of the metadata.

- copy(
values=None)#Returns a copy of this dimensional metadata object.

Kwargs:

- values
An array of values for the new dimensional metadata object. This may be a different shape to the original values array being copied.

- core_data()#
The data array at the core of this ancillary variable, which may be a NumPy array or a dask array.

- cube_dims(
cube)[source]#Return the cube dimensions of this CellMeasure.

Equivalent to “cube.cell_measure_dims(self)”.

- has_bounds()#
Return a boolean indicating whether the current dimensional metadata object has a bounds array.

- has_lazy_data()#
Return a boolean indicating whether the ancillary variable’s data array is a lazy dask array or not.

- is_compatible(
other,ignore=None)#Return whether the current dimensional metadata object is compatible with another.

- lazy_data()#
Return a lazy array representing the ancillary variable’s data.

Accessing this method will never cause the data values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the ancillary variable to have loaded data.

If the data have already been loaded for the ancillary variable, the returned Array will be a new lazy array wrapper.

- Returns
A lazy array, representing the ancillary variable data array.

- name(
default=None,token=False)#Returns a string name representing the identity of the metadata.

First it tries standard name, then it tries the long name, then the NetCDF variable name, before falling-back to a default value, which itself defaults to the string ‘unknown’.

Kwargs:

- default:
The fall-back string representing the default name. Defaults to the string ‘unknown’.

- token:
If True, ensures that the name returned satisfies the criteria for the characters required by a valid NetCDF name. If it is not possible to return a valid name, then a ValueError exception is raised. Defaults to False.

- Returns
String.

- rename(
name)#Changes the human-readable name.

If ‘name’ is a valid standard name it will assign it to

`standard_name`

, otherwise it will assign it to`long_name`

.

- summary(
shorten=False,max_values=None,edgeitems=2,linewidth=None,precision=None,convert_dates=True,_section_indices=None)#Make a printable text summary.

- Parameters

shorten(bool,default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.

max_values(intorNone,default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if`shorten`

=True, or 15 otherwise. This overrides`numpy.get_printoptions['threshold']`

.

linewidth(intorNone,default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to`numpy.get_printoptions['linewidth']`

.

edgeitems(int = 2) – Controls truncated array output. Overrides`numpy.getprintoptions['edgeitems']`

.

precision(intorNone,default = None) – Controls number decimal formatting. When`shorten`

=True this is defaults to 3, in which case it overrides`numpy.get_printoptions()['precision']`

.

convert_dates(bool,default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.- Returns

result– Output text, with embedded newlines when`shorten`

=False.- Return type
Note

Arrays are formatted using

`numpy.array2string()`

. Some aspects of the array formatting are controllable in the usual way, via`numpy.printoptions()`

, but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.

- xml_element(
doc)[source]#Create the

`xml.dom.minidom.Element`

that describes this`CellMeasure`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that describes this`CellMeasure`

.

propertyattributes#

propertydata#

propertydtype#The NumPy dtype of the current dimensional metadata object, as specified by its values.

propertylong_name#The CF Metadata long name for the object.

propertymeasure#String naming the measure type.

propertymetadata#

propertyndim#Return the number of dimensions of the current dimensional metadata object.

propertyshape#The fundamental shape of the metadata, expressed as a tuple.

propertystandard_name#The CF Metadata standard name for the object.

propertyunits#The S.I. unit of the object.

propertyvar_name#The NetCDF variable name for the object.

Represents a sub-cell pre-processing operation.

classiris.coords.CellMethod(method,coords=None,intervals=None,comments=None)[source]#Args:

- method:
The name of the operation.

Kwargs:

- coords:
A single instance or sequence of

`Coord`

instances or coordinate names.

- intervals:
A single string, or a sequence strings, describing the intervals within the cell method.

- comments:
A single string, or a sequence strings, containing any additional comments.

- xml_element(
doc)[source]#Create the

`xml.dom.minidom.Element`

that describes this`CellMethod`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that describes this`CellMethod`

.

- comments
= None#Additional comments.

- coord_names
= None#The tuple of coordinate names over which the operation was applied.

- intervals
= None#A description of the original intervals over which the operation was applied.

- method
= None#The name of the operation that was applied. e.g. “mean”, “max”, etc.

Abstract base class for coordinates.

classiris.coords.Coord(points,standard_name=None,long_name=None,var_name=None,units=None,bounds=None,attributes=None,coord_system=None,climatological=False)[source]#Coordinate abstract base class. As of

`v3.0.0`

youcannotcreate an instance of`Coord`

.Args:

- points:
The values (or value in the case of a scalar coordinate) for each cell of the coordinate.

Kwargs:

- standard_name:
CF standard name of the coordinate.

- long_name:
Descriptive name of the coordinate.

- var_name:
The netCDF variable name for the coordinate.

- units
The

`Unit`

of the coordinate’s values. Can be a string, which will be converted to a Unit object.

- bounds
An array of values describing the bounds of each cell. Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1D coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2) Note if the data is a climatology, climatological should be set.

- attributes
A dictionary containing other CF and user-defined attributes.

- coord_system
A

`CoordSystem`

representing the coordinate system of the coordinate, e.g., a`GeogCS`

for a longitude coordinate.

- climatological (bool):
When True: the coordinate is a NetCDF climatological time axis. When True: saving in NetCDF will give the coordinate variable a ‘climatology’ attribute and will create a boundary variable called ‘<coordinate-name>_climatology’ in place of a standard bounds attribute and bounds variable. Will set to True when a climatological time axis is loaded from NetCDF. Always False if no bounds exist.

- __binary_operator__(
other,mode_constant)#Common code which is called by add, sub, mul and div

Mode constant is one of ADD, SUB, MUL, DIV, RDIV

Note

notchanged when doing scalar operations on a metadata object. This means that a metadata object which represents “10 meters” when multiplied by a scalar i.e. “1000” would result in a metadata object of “10000 meters”. An alternative approach could be taken to multiply theunitby 1000 and the resultant metadata object would represent “10 kilometers”.

- __getitem__(
keys)#Returns a new dimensional metadata whose values are obtained by conventional array indexing.

Note

- cell(
index)[source]#Return the single

`Cell`

instance which results from slicing the points/bounds with the given index.

- cells()[source]#
Returns an iterable of Cell instances for this Coord.

For example:

for cell in self.cells(): ...

- collapsed(
dims_to_collapse=None)[source]#Returns a copy of this coordinate, which has been collapsed along the specified dimensions.

Replaces the points & bounds with a simple bounded region.

- contiguous_bounds()[source]#
Returns the N+1 bound values for a contiguous bounded 1D coordinate of length N, or the (N+1, M+1) bound values for a contiguous bounded 2D coordinate of shape (N, M).

Only 1D or 2D coordinates are supported.

Note

If the coordinate has bounds, this method assumes they are contiguous.

If the coordinate is 1D and does not have bounds, this method will return bounds positioned halfway between the coordinate’s points.

If the coordinate is 2D and does not have bounds, an error will be raised.

- convert_units(
unit)[source]#Change the coordinate’s units, converting the values in its points and bounds arrays.

For example, if a coordinate’s

`units`

attribute is set to radians then:coord.convert_units('degrees')will change the coordinate’s

`units`

attribute to degrees and multiply each value in`points`

and`bounds`

by 180.0/\(\pi\).

- copy(
points=None,bounds=None)[source]#Returns a copy of this coordinate.

Kwargs:

- points: A points array for the new coordinate.
This may be a different shape to the points of the coordinate being copied.

- bounds: A bounds array for the new coordinate.
Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1d coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2).

Note

If the points argument is specified and bounds are not, the resulting coordinate will have no bounds.

- core_bounds()[source]#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- core_points()[source]#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- cube_dims(
cube)[source]#Return the cube dimensions of this Coord.

Equivalent to “cube.coord_dims(self)”.

- guess_bounds(
bound_position=0.5)[source]#Add contiguous bounds to a coordinate, calculated from its points.

Puts a cell boundary at the specified fraction between each point and the next, plus extrapolated lowermost and uppermost bound points, so that each point lies within a cell.

With regularly spaced points, the resulting bounds will also be regular, and all points lie at the same position within their cell. With irregular points, the first and last cells are given the same widths as the ones next to them.

Kwargs:

- bound_position:
The desired position of the bounds relative to the position of the points.

Note

An error is raised if the coordinate already has bounds, is not one-dimensional, or is not monotonic.

Note

Unevenly spaced values, such from a wrapped longitude range, can produce unexpected results : In such cases you should assign suitable values directly to the bounds property, instead.

- has_lazy_bounds()[source]#
Return a boolean indicating whether the coord’s bounds array is a lazy dask array or not.

- has_lazy_points()[source]#
Return a boolean indicating whether the coord’s points array is a lazy dask array or not.

- intersect(
other,return_indices=False)[source]#Returns a new coordinate from the intersection of two coordinates.

Both coordinates must be compatible as defined by

`is_compatible()`

.Kwargs:

- return_indices:
If True, changes the return behaviour to return the intersection indices for the “self” coordinate.

- is_compatible(
other,ignore=None)[source]#Return whether the coordinate is compatible with another.

Compatibility is determined by comparing

`iris.coords.Coord.name()`

,`iris.coords.Coord.units`

,`iris.coords.Coord.coord_system`

and`iris.coords.Coord.attributes`

that are present in both objects.Args:

- other:
An instance of

`iris.coords.Coord`

,`iris.common.CoordMetadata`

or`iris.common.DimCoordMetadata`

.

- ignore:
A single attribute key or iterable of attribute keys to ignore when comparing the coordinates. Default is None. To ignore all attributes, set this to other.attributes.

- Returns
Boolean.

- is_contiguous(
rtol=1e-05,atol=1e-08)[source]#Return True if, and only if, this Coord is bounded with contiguous bounds to within the specified relative and absolute tolerances.

1D coords are contiguous if the upper bound of a cell aligns, within a tolerance, to the lower bound of the next cell along.

2D coords, with 4 bounds, are contiguous if the lower right corner of each cell aligns with the lower left corner of the cell to the right of it, and the upper left corner of each cell aligns with the lower left corner of the cell above it.

Args:

- rtol:
The relative tolerance parameter (default is 1e-05).

- atol:
The absolute tolerance parameter (default is 1e-08).

- Returns
Boolean.

- lazy_bounds()[source]#
Return a lazy array representing the coord bounds.

Accessing this method will never cause the bounds values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded bounds.

If the data have already been loaded for the coord, the returned Array will be a new lazy array wrapper.

- Returns
A lazy array representing the coord bounds array or None if the coord does not have bounds.

- lazy_points()[source]#
Return a lazy array representing the coord points.

Accessing this method will never cause the points values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded points.

- Returns
A lazy array, representing the coord points array.

- name(
default=None,token=False)#Returns a string name representing the identity of the metadata.

Kwargs:

- default:
The fall-back string representing the default name. Defaults to the string ‘unknown’.

- token:

- Returns
String.

- nearest_neighbour_index(
point)[source]#Returns the index of the cell nearest to the given point.

Only works for one-dimensional coordinates.

For example:

>>> cube = iris.load_cube(iris.sample_data_path('ostia_monthly.nc')) >>> cube.coord('latitude').nearest_neighbour_index(0) 9 >>> cube.coord('longitude').nearest_neighbour_index(10) 12Note

If the coordinate contains bounds, these will be used to determine the nearest neighbour instead of the point values.

Note

For circular coordinates, the ‘nearest’ point can wrap around to the other end of the values.

- rename(
name)#Changes the human-readable name.

`standard_name`

, otherwise it will assign it to`long_name`

.

shorten=False,max_values=None,edgeitems=2,linewidth=None,precision=None,convert_dates=True,_section_indices=None)#Make a printable text summary.

- Parameters

shorten(bool,default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.

max_values(intorNone,default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if`shorten`

=True, or 15 otherwise. This overrides`numpy.get_printoptions['threshold']`

.

linewidth(intorNone,default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to`numpy.get_printoptions['linewidth']`

.

edgeitems(int = 2) – Controls truncated array output. Overrides`numpy.getprintoptions['edgeitems']`

.

precision(intorNone,default = None) – Controls number decimal formatting. When`shorten`

=True this is defaults to 3, in which case it overrides`numpy.get_printoptions()['precision']`

.

convert_dates(bool,default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.- Returns

result– Output text, with embedded newlines when`shorten`

=False.- Return type
Note

`numpy.array2string()`

. Some aspects of the array formatting are controllable in the usual way, via`numpy.printoptions()`

, but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.

- xml_element(
doc)[source]#Create the

`xml.dom.minidom.Element`

that describes this`Coord`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that will describe this`DimCoord`

.

propertyattributes#

propertybounds#The coordinate bounds values, as a NumPy array, or None if no bound values are defined.

Note

The shape of the bound array should be:

`points.shape + (n_bounds, )`

.

propertybounds_dtype#The NumPy dtype of the coord’s bounds. Will be None if the coord does not have bounds.

propertyclimatological#A boolean that controls whether the coordinate is a climatological time axis, in which case the bounds represent a climatological period rather than a normal period.

Always reads as False if there are no bounds. On set, the input value is cast to a boolean, exceptions raised if units are not time units or if there are no bounds.

propertycoord_system#Relevant coordinate system (if any).

propertydtype#The NumPy dtype of the current dimensional metadata object, as specified by its values.

propertylong_name#The CF Metadata long name for the object.

propertymetadata#

propertynbounds#Return the number of bounds that this coordinate has (0 for no bounds).

propertyndim#Return the number of dimensions of the current dimensional metadata object.

propertypoints#The coordinate points values as a NumPy array.

propertyshape#The fundamental shape of the metadata, expressed as a tuple.

propertystandard_name#The CF Metadata standard name for the object.

propertyunits#The S.I. unit of the object.

propertyvar_name#The NetCDF variable name for the object.

Defines a range of values for a coordinate.

classiris.coords.CoordExtent(name_or_coord,minimum,maximum,min_inclusive=True,max_inclusive=True)[source]#Create a CoordExtent for the specified coordinate and range of values.

Args:

- name_or_coord
Either a coordinate name or a coordinate, as defined in

`iris.cube.Cube.coords()`

.

- minimum
The minimum value of the range to select.

- maximum
The maximum value of the range to select.

Kwargs:

- min_inclusive
If True, coordinate values equal to minimum will be included in the selection. Default is True.

- max_inclusive
If True, coordinate values equal to maximum will be included in the selection. Default is True.

static__new__(cls,name_or_coord,minimum,maximum,min_inclusive=True,max_inclusive=True)[source]#Create a CoordExtent for the specified coordinate and range of values.

Args:

- name_or_coord
Either a coordinate name or a coordinate, as defined in

`iris.cube.Cube.coords()`

.

- minimum
The minimum value of the range to select.

- maximum
The maximum value of the range to select.

Kwargs:

- min_inclusive
If True, coordinate values equal to minimum will be included in the selection. Default is True.

- max_inclusive
If True, coordinate values equal to maximum will be included in the selection. Default is True.

- count(
value,/)#Return number of occurrences of value.

- index(
value,start=0,stop=9223372036854775807,/)#Return first index of value.

Raises ValueError if the value is not present.

- max_inclusive#
Alias for field number 4

- maximum#
Alias for field number 2

- min_inclusive#
Alias for field number 3

- minimum#
Alias for field number 1

- name_or_coord#
Alias for field number 0

A coordinate that is 1D, and numeric, with values that have a strict monotonic ordering. Missing values are not
permitted in a `DimCoord`

.

classiris.coords.DimCoord(points,standard_name=None,long_name=None,var_name=None,units=None,bounds=None,attributes=None,coord_system=None,circular=False,climatological=False)[source]#Create a 1D, numeric, and strictly monotonic coordinate with

immutablepoints and bounds.Missing values are not permitted.

Args:

- points:
1D numpy array-like of values (or single value in the case of a scalar coordinate) for each cell of the coordinate. The values must be strictly monotonic and masked values are not allowed.

Kwargs:

- standard_name:
CF standard name of the coordinate.

- long_name:
Descriptive name of the coordinate.

- var_name:
The netCDF variable name for the coordinate.

- units:
The

`Unit`

of the coordinate’s values. Can be a string, which will be converted to a Unit object.

- bounds:
An array of values describing the bounds of each cell. Given n bounds and m cells, the shape of the bounds array should be (m, n). For each bound, the values must be strictly monotonic along the cells, and the direction of monotonicity must be consistent across the bounds. For example, a DimCoord with 100 points and two bounds per cell would have a bounds array of shape (100, 2), and the slices

`bounds[:, 0]`

and`bounds[:, 1]`

would be monotonic in the same direction. Masked values are not allowed. Note if the data is a climatology, climatological should be set.

- attributes:
A dictionary containing other CF and user-defined attributes.

- coord_system:
A

`CoordSystem`

representing the coordinate system of the coordinate, e.g., a`GeogCS`

for a longitude coordinate.

- circular (bool):
Whether the coordinate wraps by the

`modulus`

i.e., the longitude coordinate wraps around the full great circle.

- climatological (bool):
When True: the coordinate is a NetCDF climatological time axis. When True: saving in NetCDF will give the coordinate variable a ‘climatology’ attribute and will create a boundary variable called ‘<coordinate-name>_climatology’ in place of a standard bounds attribute and bounds variable. Will set to True when a climatological time axis is loaded from NetCDF. Always False if no bounds exist.

- __binary_operator__(
other,mode_constant)#Common code which is called by add, sub, mul and div

Mode constant is one of ADD, SUB, MUL, DIV, RDIV

Note

notchanged when doing scalar operations on a metadata object. This means that a metadata object which represents “10 meters” when multiplied by a scalar i.e. “1000” would result in a metadata object of “10000 meters”. An alternative approach could be taken to multiply theunitby 1000 and the resultant metadata object would represent “10 kilometers”.

- cell(
index)#Return the single

`Cell`

instance which results from slicing the points/bounds with the given index.

- cells()#
Returns an iterable of Cell instances for this Coord.

For example:

for cell in self.cells(): ...

- collapsed(
dims_to_collapse=None)[source]#Returns a copy of this coordinate, which has been collapsed along the specified dimensions.

Replaces the points & bounds with a simple bounded region.

- contiguous_bounds()#
Returns the N+1 bound values for a contiguous bounded 1D coordinate of length N, or the (N+1, M+1) bound values for a contiguous bounded 2D coordinate of shape (N, M).

Only 1D or 2D coordinates are supported.

Note

If the coordinate has bounds, this method assumes they are contiguous.

If the coordinate is 1D and does not have bounds, this method will return bounds positioned halfway between the coordinate’s points.

If the coordinate is 2D and does not have bounds, an error will be raised.

- convert_units(
unit)#Change the coordinate’s units, converting the values in its points and bounds arrays.

For example, if a coordinate’s

`units`

attribute is set to radians then:coord.convert_units('degrees')will change the coordinate’s

`units`

attribute to degrees and multiply each value in`points`

and`bounds`

by 180.0/\(\pi\).

- copy(
points=None,bounds=None)[source]#Returns a copy of this coordinate.

Kwargs:

- points: A points array for the new coordinate.
This may be a different shape to the points of the coordinate being copied.

- bounds: A bounds array for the new coordinate.
Given n bounds for each cell, the shape of the bounds array should be points.shape + (n,). For example, a 1d coordinate with 100 points and two bounds per cell would have a bounds array of shape (100, 2).

Note

If the points argument is specified and bounds are not, the resulting coordinate will have no bounds.

- core_bounds()#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- core_points()#
The points array at the core of this coord, which may be a NumPy array or a dask array.

- cube_dims(
cube)#Return the cube dimensions of this Coord.

Equivalent to “cube.coord_dims(self)”.

classmethodfrom_coord(coord)#Create a new Coord of this type, from the given coordinate.

classmethodfrom_regular(zeroth,step,count,standard_name=None,long_name=None,var_name=None,units=None,attributes=None,coord_system=None,circular=False,climatological=False,with_bounds=False)[source]#Create a

`DimCoord`

with regularly spaced points, and optionally bounds.The majority of the arguments are defined as for

`Coord`

, but those which differ are defined below.Args:

- zeroth:
The value

priorto the first point value.

- step:
The numeric difference between successive point values.

- count:
The number of point values.

Kwargs:

- with_bounds:
If True, the resulting DimCoord will possess bound values which are equally spaced around the points. Otherwise no bounds values will be defined. Defaults to False.

- guess_bounds(
bound_position=0.5)#Add contiguous bounds to a coordinate, calculated from its points.

Puts a cell boundary at the specified fraction between each point and the next, plus extrapolated lowermost and uppermost bound points, so that each point lies within a cell.

With regularly spaced points, the resulting bounds will also be regular, and all points lie at the same position within their cell. With irregular points, the first and last cells are given the same widths as the ones next to them.

Kwargs:

- bound_position:
The desired position of the bounds relative to the position of the points.

Note

An error is raised if the coordinate already has bounds, is not one-dimensional, or is not monotonic.

Note

Unevenly spaced values, such from a wrapped longitude range, can produce unexpected results : In such cases you should assign suitable values directly to the bounds property, instead.

- has_bounds()#
Return a boolean indicating whether the coord has a bounds array.

- has_lazy_bounds()#
Return a boolean indicating whether the coord’s bounds array is a lazy dask array or not.

- has_lazy_points()#
Return a boolean indicating whether the coord’s points array is a lazy dask array or not.

- intersect(
other,return_indices=False)#Returns a new coordinate from the intersection of two coordinates.

Both coordinates must be compatible as defined by

`is_compatible()`

.Kwargs:

- return_indices:
If True, changes the return behaviour to return the intersection indices for the “self” coordinate.

- is_compatible(
other,ignore=None)#Return whether the coordinate is compatible with another.

Compatibility is determined by comparing

`iris.coords.Coord.name()`

,`iris.coords.Coord.units`

,`iris.coords.Coord.coord_system`

and`iris.coords.Coord.attributes`

that are present in both objects.Args:

- other:
An instance of

`iris.coords.Coord`

,`iris.common.CoordMetadata`

or`iris.common.DimCoordMetadata`

.

- ignore:
A single attribute key or iterable of attribute keys to ignore when comparing the coordinates. Default is None. To ignore all attributes, set this to other.attributes.

- Returns
Boolean.

- is_contiguous(
rtol=1e-05,atol=1e-08)#Return True if, and only if, this Coord is bounded with contiguous bounds to within the specified relative and absolute tolerances.

1D coords are contiguous if the upper bound of a cell aligns, within a tolerance, to the lower bound of the next cell along.

2D coords, with 4 bounds, are contiguous if the lower right corner of each cell aligns with the lower left corner of the cell to the right of it, and the upper left corner of each cell aligns with the lower left corner of the cell above it.

Args:

- rtol:
The relative tolerance parameter (default is 1e-05).

- atol:
The absolute tolerance parameter (default is 1e-08).

- Returns
Boolean.

- lazy_bounds()#
Return a lazy array representing the coord bounds.

Accessing this method will never cause the bounds values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded bounds.

- Returns
A lazy array representing the coord bounds array or None if the coord does not have bounds.

- lazy_points()#
Return a lazy array representing the coord points.

Accessing this method will never cause the points values to be loaded. Similarly, calling methods on, or indexing, the returned Array will not cause the coord to have loaded points.

- Returns
A lazy array, representing the coord points array.

- name(
default=None,token=False)#Returns a string name representing the identity of the metadata.

Kwargs:

- default:
The fall-back string representing the default name. Defaults to the string ‘unknown’.

- token:

- Returns
String.

- nearest_neighbour_index(
point)#Returns the index of the cell nearest to the given point.

Only works for one-dimensional coordinates.

For example:

>>> cube = iris.load_cube(iris.sample_data_path('ostia_monthly.nc')) >>> cube.coord('latitude').nearest_neighbour_index(0) 9 >>> cube.coord('longitude').nearest_neighbour_index(10) 12Note

If the coordinate contains bounds, these will be used to determine the nearest neighbour instead of the point values.

Note

For circular coordinates, the ‘nearest’ point can wrap around to the other end of the values.

- rename(
name)#Changes the human-readable name.

`standard_name`

, otherwise it will assign it to`long_name`

.

shorten=False,max_values=None,edgeitems=2,linewidth=None,precision=None,convert_dates=True,_section_indices=None)#Make a printable text summary.

- Parameters

shorten(bool,default = False) – If True, produce an abbreviated one-line summary. If False, produce a multi-line summary, with embedded newlines.

max_values(intorNone,default = None) – If more than this many data values, print truncated data arrays instead of full contents. If 0, print only the shape. The default is 5 if`shorten`

=True, or 15 otherwise. This overrides`numpy.get_printoptions['threshold']`

.

linewidth(intorNone,default = None) – Character-width controlling line splitting of array outputs. If unset, defaults to`numpy.get_printoptions['linewidth']`

.

edgeitems(int = 2) – Controls truncated array output. Overrides`numpy.getprintoptions['edgeitems']`

.

precision(intorNone,default = None) – Controls number decimal formatting. When`shorten`

=True this is defaults to 3, in which case it overrides`numpy.get_printoptions()['precision']`

.

convert_dates(bool,default = True) – If the units has a calendar, then print array values as date strings instead of the actual numbers.- Returns

result– Output text, with embedded newlines when`shorten`

=False.- Return type
Note

`numpy.array2string()`

. Some aspects of the array formatting are controllable in the usual way, via`numpy.printoptions()`

, but others are overridden as detailed above. Control of those aspects is still available, but only via the call arguments.

- xml_element(
doc)[source]#Create the

`xml.dom.minidom.Element`

that describes this`DimCoord`

.Args:

- doc:
The parent

`xml.dom.minidom.Document`

.

- Returns
The

`xml.dom.minidom.Element`

that describes this`DimCoord`

.

propertyattributes#

propertybounds#The coordinate bounds values, as a NumPy array, or None if no bound values are defined.

Note

The shape of the bound array should be:

`points.shape + (n_bounds, )`

.

propertybounds_dtype#The NumPy dtype of the coord’s bounds. Will be None if the coord does not have bounds.

propertycircular#Whether the coordinate wraps by

`coord.units.modulus`

.

propertyclimatological#A boolean that controls whether the coordinate is a climatological time axis, in which case the bounds represent a climatological period rather than a normal period.

Always reads as False if there are no bounds. On set, the input value is cast to a boolean, exceptions raised if units are not time units or if there are no bounds.

propertycoord_system#The coordinate-system of the coordinate.

propertydtype#The NumPy dtype of the current dimensional metadata object, as specified by its values.

propertylong_name#The CF Metadata long name for the object.

propertymetadata#

propertynbounds#Return the number of bounds that this coordinate has (0 for no bounds).

propertyndim#Return the number of dimensions of the current dimensional metadata object.

propertypoints#The coordinate points values as a NumPy array.

propertyshape#The fundamental shape of the metadata, expressed as a tuple.

propertystandard_name#The CF Metadata standard name for the object.

propertyunits#The S.I. unit of the object.

propertyvar_name#The NetCDF variable name for the object.