xcdat.swap_lon_axis#

xcdat.swap_lon_axis(dataset, to, sort_ascending=True)[source]#

Swaps the orientation of a dataset’s longitude axis.

This method also swaps the axis orientation of the longitude bounds if it exists. Afterwards, it sorts longitude and longitude bounds values in ascending order.

Parameters
  • dataset (xr.Dataset) – The Dataset containing a longitude axis.

  • to (Tuple[float, float]) – The orientation to swap the Dataset’s longitude axis to.

    Supported orientations:

    • (-180, 180): represents [-180, 180) in math notation

    • (0, 360): represents [0, 360) in math notation

  • sort_ascending (bool) – After swapping, sort in ascending order (True), or keep existing order (False).

Returns

xr.Dataset – The Dataset with swapped lon axes orientation.