Reorder Xarray coordinates

PHOTO EMBED

Sun Sep 03 2023 00:40:02 GMT+0000 (Coordinated Universal Time)

Saved by @ktyle #python #xarray

SLP = SLP.assign_coords(longitude=(((SLP.longitude + 180) % 360) -180))
Z = Z.assign_coords(longitude=(((Z.longitude + 180) % 360) -180))
SLP = SLP.sortby(SLP['longitude'])
Z = Z.sortby(Z['longitude'])
content_copyCOPY

This snippet rorders longitudes in a DataArray so they go from -180 to 180 rather than 0 to 360 (as occurs in ERA-5 grids served by RDA)