Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added add_cyclic to API reference and What's new Version 0.21 #2189

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/reference/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Longitude wrapping
:toctree: generated/

util.add_cyclic_point
util.add_cyclic


LinearRing/LineString projection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions docs/source/whatsnew/v0.21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ Features

plt.show()

* Matthias Cuntz added a new convenience utility function
:func:~cartopy.util.add_cyclic. This is an extension of
:func:~cartopy.util.add_cyclic_point for 2-dimensional coordinates lat and
lon. (:pull:1753)

Deprecations
------------

Expand Down
5 changes: 5 additions & 0 deletions lib/cartopy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def add_cyclic(data, x=None, y=None, axis=-1,
--------
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(data)
Expand All @@ -280,6 +281,7 @@ def add_cyclic(data, x=None, y=None, axis=-1,
[0. 1. 2. 3. 4. 5. 0.]]

Adding a cyclic point to a data array and an associated x-coordinate.

>>> lons = np.arange(0, 360, 60)
>>> cyclic_data, cyclic_lons = add_cyclic(data, x=lons)
>>> print(cyclic_data) # doctest: +NORMALIZE_WHITESPACE
Expand All @@ -293,6 +295,7 @@ def add_cyclic(data, x=None, y=None, axis=-1,

Adding a cyclic point to a data array and an associated 2-dimensional
x-coordinate.

>>> lons = np.arange(0, 360, 60)
>>> lats = np.arange(-90, 90, 180/5)
>>> lon2d, lat2d = np.meshgrid(lons, lats)
Expand All @@ -312,6 +315,7 @@ def add_cyclic(data, x=None, y=None, axis=-1,

Adding a cyclic point to a data array and the associated 2-dimensional
x- and y-coordinates.

>>> lons = np.arange(0, 360, 60)
>>> lats = np.arange(-90, 90, 180/5)
>>> lon2d, lat2d = np.meshgrid(lons, lats)
Expand All @@ -337,6 +341,7 @@ def add_cyclic(data, x=None, y=None, axis=-1,
[ 54. 54. 54. 54. 54. 54. 54.]]

Not adding a cyclic point if cyclic point detected in x.

>>> lons = np.arange(0, 361, 72)
>>> lats = np.arange(-90, 90, 180/5)
>>> lon2d, lat2d = np.meshgrid(lons, lats)
Expand Down