This module contains utilities that are useful in conjunction with cartopy.
Add a cyclic point to an array and optionally a corresponding coordinate.
Args:
An n-dimensional array of data to add a cyclic point to.
Kwargs:
A 1-dimensional array which specifies the coordinate values for the dimension the cyclic point is to be added to. The coordinate values must be regularly spaced.
Specifies the axis of the data array to add the cyclic point to. Defaults to the right-most axis.
Returns:
The data array with a cyclic point added.
The coordinate with a cyclic point, only returned if the coord keyword was supplied.
Examples:
Adding a cyclic point to a data array, where the cyclic dimension is the right-most dimension
>>> import numpy as np
>>> data = np.ones([5, 6]) * np.arange(6)
>>> cyclic_data = add_cyclic_point(data)
>>> print(cyclic_data)
[[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]]
Adding a cyclic point to a data array and an associated coordinate
>>> lons = np.arange(0, 360, 60)
>>> cyclic_data, cyclic_lons = add_cyclic_point(data, coord=lons)
>>> print(cyclic_data)
[[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]
[ 0. 1. 2. 3. 4. 5. 0.]]
>>> print(cyclic_lons)
[ 0 60 120 180 240 300 360]