Skip to content

Commit

Permalink
Update circular_index to index_with_360
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Sep 26, 2022
1 parent fa1e239 commit 4214f91
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions xcdat/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,17 @@ def _swap_lon_axis(coords: xr.DataArray, to: Tuple[float, float]) -> xr.DataArra
# value of 0 (360 % 360 is 0) back to 360. This case usually happens
# if the coordinate are already on the (0, 360) axis orientation.
# Example with 360 coords: [60, 150, 0] -> [60, 150, 360]
circular_index = np.where(coords == 360)
index_with_360 = np.where(coords == 360)

if len(circular_index) > 0:
if len(index_with_360) > 0:
# Must load lazy, multidimensional Dask arrays into into eager,
# in-memory NumPy arrays before manipulating its values. Otherwise,
# it raises `NotImplementedError xarray can't set arrays with
# multiple array indices to dask yet`.
if isinstance(new_coords.data, Array) and new_coords.ndim > 1:
new_coords.load()

new_coords[circular_index] = 360
new_coords[index_with_360] = 360
else:
raise ValueError(
"Currently, only (-180, 180) and (0, 360) are supported longitude axis "
Expand Down

0 comments on commit 4214f91

Please sign in to comment.