Definitions of coordinates.

In this module:

A CF auxiliary coordinate.

classiris.coords.AuxCoord(points,standard_name=None,long_name=None,var_name=None,units='1',bounds=None,attributes=None,coord_system=None)¶Bases:

iris.coords.CoordConstructs a single coordinate.

Args:

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

Kwargs:

- standard_name:
CF standard name of coordinate

- long_name:
Descriptive name of coordinate

- var_name:
CF variable name of coordinate

- units
The

Unitof 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)

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

- coord_system
A

CoordSystem, e.g. aGeogCSfor a longitude Coord.

cell(index)¶Return the single

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

If iris.FUTURE.cell_datetime_objects is True, then this method will return Cell objects whose points and bounds attributes contain either datetime.datetime instances or netcdftime.datetime instances (depending on the calendar).

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.

Note

You cannot partially collapse a multi-dimensional coordinate. See

cube.collapsedfor more information.

contiguous_bounds()¶Returns the N+1 bound values for a contiguous bounded coordinate of length N.

Note

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

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

For example, if a coordinate’s

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

unitsattribute to degrees and multiply each value inpointsandboundsby 180.0/.

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.

staticfrom_coord(coord)¶Create a new AuxCoord 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.

Note

If iris.FUTURE.clip_latitudes is True, then this method will clip the coordinate bounds to the range [-90, 90] when:

- it is a latitude or grid_latitude coordinate,
- the units are degrees,
- all the points are in the range [-90, 90].

has_bounds()¶

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_systemandiris.coords.Coord.attributesthat are present in both objects.Args:

- other:
An instance of

iris.coords.Coordoriris.coords.CoordDefn.

- 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.

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.

name(default='unknown')¶Returns a human-readable name.

First it tries

standard_name, then ‘long_name’, then ‘var_name’ before falling back to the value of default (which itself defaults to ‘unknown’).

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 tolong_name.

xml_element(doc)¶Return a DOM element describing this Coord.

attributes¶

bounds¶Property containing the bound 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, ).

dtype¶Abstract property which returns the Numpy data type of the Coordinate.

nbounds¶Return the number of bounds that this coordinate has (0 for no bounds).

ndim¶Return the number of dimensions of the coordinate (not including the bounded dimension).

points¶Property containing the points values as a numpy array

shape¶The fundamental shape of the Coord, expressed as a tuple.

standard_name¶The standard name for the Cube’s data.

units¶The

Unitinstance of the object.

var_name¶The CF 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:

n < cell

n == cell

n > cell

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)¶Bases:

iris.coords.CellConstruct a Cell from point or point-and-bound information.

contains_point(point)¶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) → integer -- return number of occurrences of value¶

index(value[,start[,stop]]) → integer -- 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='1',attributes=None,measure=None)¶Bases:

iris._cube_coord_common.CFVariableMixinConstructs a single cell measure.

Args:

- data:
The values of the measure for each cell.

Kwargs:

- standard_name:
CF standard name of coordinate

- long_name:
Descriptive name of coordinate

- var_name:
CF variable name of coordinate

- units
The

Unitof 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. ‘area’ and ‘volume’ are the only valid entries.

copy(data=None)¶Returns a copy of this CellMeasure.

Kwargs:

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

name(default='unknown')¶Returns a human-readable name.

First it tries

standard_name, then ‘long_name’, then ‘var_name’ before falling back to the value of default (which itself defaults to ‘unknown’).

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 tolong_name.

attributes¶Other attributes, including user specified attributes that have no meaning to Iris.

data¶Property containing the data values as a numpy array

long_name= None¶Descriptive name of the coordinate.

measure¶

ndim¶Return the number of dimensions of the cell measure.

shape¶The fundamental shape of the Cell Measure, expressed as a tuple.

standard_name¶CF standard name of the quantity that the coordinate represents.

units¶Unit of the quantity that the coordinate represents.

var_name¶The CF variable name for the coordinate.

Represents a sub-cell pre-processing operation.

classiris.coords.CellMethod(method,coords=None,intervals=None,comments=None)¶Bases:

iris.util._OrderedHashableArgs:

- method:
The name of the operation.

Kwargs:

- coords:
A single instance or sequence of

Coordinstances 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)¶Return a dom element describing itself

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 superclass for coordinates.

classiris.coords.Coord(points,standard_name=None,long_name=None,var_name=None,units='1',bounds=None,attributes=None,coord_system=None)¶Bases:

iris._cube_coord_common.CFVariableMixinConstructs a single coordinate.

Args:

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

Kwargs:

- standard_name:
CF standard name of coordinate

- long_name:
Descriptive name of coordinate

- var_name:
CF variable name of coordinate

- units
The

Unitof 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)

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

- coord_system
A

CoordSystem, e.g. aGeogCSfor a longitude Coord.

cell(index)¶Return the single

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

If iris.FUTURE.cell_datetime_objects is True, then this method will return Cell objects whose points and bounds attributes contain either datetime.datetime instances or netcdftime.datetime instances (depending on the calendar).

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.

Note

You cannot partially collapse a multi-dimensional coordinate. See

cube.collapsedfor more information.

contiguous_bounds()¶Returns the N+1 bound values for a contiguous bounded coordinate of length N.

Note

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

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

For example, if a coordinate’s

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

unitsattribute to degrees and multiply each value inpointsandboundsby 180.0/.

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.

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.

Note

If iris.FUTURE.clip_latitudes is True, then this method will clip the coordinate bounds to the range [-90, 90] when:

- it is a latitude or grid_latitude coordinate,
- the units are degrees,
- all the points are in the range [-90, 90].

has_bounds()¶

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_systemandiris.coords.Coord.attributesthat are present in both objects.Args:

- other:
An instance of

iris.coords.Coordoriris.coords.CoordDefn.

- 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.

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.

name(default='unknown')¶Returns a human-readable name.

First it tries

standard_name, then ‘long_name’, then ‘var_name’ before falling back to the value of default (which itself defaults to ‘unknown’).

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 tolong_name.

xml_element(doc)¶Return a DOM element describing this Coord.

attributes¶Other attributes, including user specified attributes that have no meaning to Iris.

bounds¶Property containing the bound values as a numpy array

coord_system= None¶Relevant CoordSystem (if any).

dtype¶Abstract property which returns the Numpy data type of the Coordinate.

long_name= None¶Descriptive name of the coordinate.

nbounds¶Return the number of bounds that this coordinate has (0 for no bounds).

ndim¶Return the number of dimensions of the coordinate (not including the bounded dimension).

points¶Property containing the points values as a numpy array

shape¶The fundamental shape of the Coord, expressed as a tuple.

standard_name¶CF standard name of the quantity that the coordinate represents.

units¶Unit of the quantity that the coordinate represents.

var_name¶The CF variable name for the coordinate.

Criterion for identifying a specific type of `DimCoord` or
`AuxCoord` based on its metadata.

classiris.coords.CoordDefn(_cls,standard_name,long_name,var_name,units,attributes,coord_system)¶Bases:

iris.coords.CoordDefnCreate new instance of CoordDefn(standard_name, long_name, var_name, units, attributes, coord_system)

count(value) → integer -- return number of occurrences of value¶

index(value[,start[,stop]]) → integer -- return first index of value.¶Raises ValueError if the value is not present.

name(default='unknown')¶Returns a human-readable name.

First it tries self.standard_name, then it tries the ‘long_name’ attribute, then the ‘var_name’ attribute, before falling back to the value of default (which itself defaults to ‘unknown’).

attributes¶Alias for field number 4

coord_system¶Alias for field number 5

long_name¶Alias for field number 1

standard_name¶Alias for field number 0

units¶Alias for field number 3

var_name¶Alias for field number 2

Defines a range of values for a coordinate.

classiris.coords.CoordExtent(name_or_coord,minimum,maximum,min_inclusive=True,max_inclusive=True)¶Bases:

iris.coords._CoordExtentCreate 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) → integer -- return number of occurrences of value¶

index(value[,start[,stop]]) → integer -- 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, numeric, and strictly monotonic.

classiris.coords.DimCoord(points,standard_name=None,long_name=None,var_name=None,units='1',bounds=None,attributes=None,coord_system=None,circular=False)¶Bases:

iris.coords.CoordCreate a 1D, numeric, and strictly monotonic

Coordwith read-only points and bounds.

cell(index)¶Return the single

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

If iris.FUTURE.cell_datetime_objects is True, then this method will return Cell objects whose points and bounds attributes contain either datetime.datetime instances or netcdftime.datetime instances (depending on the calendar).

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

For example:

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

collapsed(dims_to_collapse=None)¶

contiguous_bounds()¶Returns the N+1 bound values for a contiguous bounded coordinate of length N.

Note

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

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

For example, if a coordinate’s

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

unitsattribute to degrees and multiply each value inpointsandboundsby 180.0/.

copy(points=None,bounds=None)¶

staticfrom_coord(coord)¶Create a new DimCoord from the given coordinate.

classmethodfrom_regular(zeroth,step,count,standard_name=None,long_name=None,var_name=None,units='1',attributes=None,coord_system=None,circular=False,with_bounds=False)¶Create a

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

Coord.__init__(), 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.

Note

If iris.FUTURE.clip_latitudes is True, then this method will clip the coordinate bounds to the range [-90, 90] when:

- it is a latitude or grid_latitude coordinate,
- the units are degrees,
- all the points are in the range [-90, 90].

has_bounds()¶

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_systemandiris.coords.Coord.attributesthat are present in both objects.Args:

- other:
An instance of

iris.coords.Coordoriris.coords.CoordDefn.

- 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.

Args:

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

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

- Returns:
- Boolean.

is_monotonic()¶

name(default='unknown')¶Returns a human-readable name.

standard_name, then ‘long_name’, then ‘var_name’ before falling back to the value of default (which itself defaults to ‘unknown’).

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 tolong_name.

xml_element(doc)¶Return DOM element describing this

iris.coords.DimCoord.

attributes¶

bounds¶The bounds values as a read-only NumPy array, or None if no bounds have been set.

circular= None¶Whether the coordinate wraps by

coord.units.modulus.

dtype¶Abstract property which returns the Numpy data type of the Coordinate.

nbounds¶Return the number of bounds that this coordinate has (0 for no bounds).

ndim¶Return the number of dimensions of the coordinate (not including the bounded dimension).

points¶The local points values as a read-only NumPy array.

shape¶The fundamental shape of the Coord, expressed as a tuple.

standard_name¶The standard name for the Cube’s data.

units¶The

Unitinstance of the object.

var_name¶The CF variable name for the object.