Skip to content

Utility Functions

This section contains miscellaneous utility functions that are used throughout the package.

Longitude Conversion

ocstrack.utils.convert_longitude(lon, mode=1)

Convert longitudes between common geographic conventions.

Parameters:

Name Type Description Default
lon Union[float, ndarray]

array-like of longitudes

required
mode int

conversion mode: - 1: Convert from [-180, 180] (Greenwich at 0°) → [0, 360] (Greenwich at 0°) - 2: Convert from [0, 360] (Greenwich at 0°) → [-180, 180] (Greenwich at 0°) - 3: Convert from [-180, 180] (Greenwich at 0°) → [0, 360] (Greenwich at 180°) - 4: Convert from [0, 360] (Greenwich at 0°) → [0, 360] (Greenwich at 180°) - 5: Convert from [0, 360] (Greenwich at 180°) → [0, 360] (Greenwich at 0°)

1

Returns:

Type Description
ndarray

np.ndarray of converted longitudes