Skip to content

Commit

Permalink
Merge pull request #2189 from mcuntz/add_cyclic_docs
Browse files Browse the repository at this point in the history
Added add_cyclic to API reference and What's new Version 0.21
  • Loading branch information
greglucas authored Jul 12, 2023
2 parents c4858e4 + 159e056 commit 6ead89b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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

0 comments on commit 6ead89b

Please sign in to comment.