xcdat.swap_lon_axis

Contents

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.

Note, based on how datasets are chunked, swapping the longitude dimension and sorting might raise PerformanceWarning: Slicing is producing a large chunk. To accept the large chunk and silence this warning, set the option.... This function uses xarray’s arithmetic to swap orientations, so this warning seems potentially unavoidable.

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 include:

    • (-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.