iris.analysis.trajectory#

Defines a Trajectory class, and a routine to extract a sub-cube along a trajectory.

class iris.analysis.trajectory.Trajectory(waypoints, sample_count=10)[source]#

Bases: object

A series of given waypoints with pre-calculated sample points.

Define a trajectory using a sequence of waypoints.

Parameters
  • waypoints – A sequence of dictionaries, mapping coordinate names to values.

  • sample_count (int, default=10) – The number of sample positions to use along the trajectory.

Examples

waypoints = [{'latitude': 45, 'longitude': -60},
             {'latitude': 45, 'longitude': 0}]
Trajectory(waypoints)

Note

All the waypoint dictionaries must contain the same coordinate names.

interpolate(cube, method=None)[source]#

Interpolate cube on the defined trajectory.

Call interpolate() to interpolate cube on the defined trajectory.

Assumes that the coordinate names supplied in the waypoints dictionaries match to coordinate names in cube, and that points are supplied in the same coord_system as in cube, where appropriate (i.e. for horizontal coordinate points).

Parameters
  • cube – The source Cube to interpolate.

  • method (optional) – The interpolation method to use; “linear” (default) or “nearest”. Only nearest is available when specifying multi-dimensional coordinates.

class iris.analysis.trajectory.UnstructuredNearestNeigbourRegridder(src_cube, target_grid_cube)[source]#

Bases: object

Encapsulate the operation of iris.analysis.trajectory.interpolate().

Encapsulate the operation of iris.analysis.trajectory.interpolate() with given source and target grids.

This is the type used by the UnstructuredNearest regridding scheme.

Nearest-neighbour regridder.

A nearest-neighbour regridder to perform regridding from the source grid to the target grid.

This can then be applied to any source data with the same structure as the original ‘src_cube’.

Parameters
  • src_cube (Cube) – The Cube defining the source grid. The X and Y coordinates can have any shape, but must be mapped over the same cube dimensions.

  • target_grid_cube (Cube) – A Cube, whose X and Y coordinates specify a desired target grid. The X and Y coordinates must be one-dimensional dimension coordinates, mapped to different dimensions. All other cube components are ignored.

Returns

A callable object with the interface:

result_cube = regridder(data)

where data is a cube with the same grid as the original src_cube, that is to be regridded to the target_grid_cube.

Return type

regridder (object)

Notes

Note

For latitude-longitude coordinates, the nearest-neighbour distances are computed on the sphere, otherwise flat Euclidean distances are used.

The source and target X and Y coordinates must all have the same coordinate system, which may also be None. If any X and Y coordinates are latitudes or longitudes, they all must be. Otherwise, the corresponding X and Y coordinates must have the same units in the source and grid cubes.

iris.analysis.trajectory.interpolate(cube, sample_points, method=None)[source]#

Extract a sub-cube at the given n-dimensional points.

Parameters
  • cube – The source Cube.

  • sample_points – A sequence of coordinate (name) - values pairs.

  • method (optional) – Request “linear” interpolation (default) or “nearest” neighbour. Only nearest neighbour is available when specifying multi-dimensional coordinates.

Examples

sample_points = [('latitude', [45, 45, 45]),
('longitude', [-60, -50, -40])]
interpolated_cube = interpolate(cube, sample_points)

Notes

This function does not maintain laziness when called; it realises data. See more at Real and Lazy Data.