clouddrift.sphere.recast_lon

Contents

clouddrift.sphere.recast_lon#

clouddrift.sphere.recast_lon(lon: ndarray, lon0: float = -180) ndarray[source]#

Recast (convert) longitude values to a selected range of 360 degrees starting from lon0.

Parameters#

lonnp.ndarray or float

An N-d array of longitudes in degrees

lon0float, optional

Starting longitude of the recasted range (default -180).

Returns#

np.ndarray or float

Converted longitudes in the range [lon0, lon0+360[

Examples#

By default, recast_lon converts longitude values to the range [-180, 180[:

>>> recast_lon(200)
-160
>>> recast_lon(180)
-180

The range of the output longitude is controlled by lon0. For example, with lon0 = 0, the longitude values are converted to the range [0, 360[.

>>> recast_lon(200, -180)
-160

With lon0 = 20, longitude values are converted to range [20, 380], which can be useful to avoid cutting the major ocean basins.

>>> recast_lon(10, 20)
370

See Also#

recast_lon360(), recast_lon180()