Skip to content
Open
24 changes: 5 additions & 19 deletions xpublish_wms/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,29 +553,15 @@ def mask(
return da.where(np_mask.mask == 0)

def project(self, da: xr.DataArray, crs: str) -> Any:
da = self.mask(da)
# da = self.mask(da)

# create 2 separate DataArrays where points lng>180 are put at the beginning of the array
mask_0 = xr.where(da.cf["longitude"] <= 180, 1, 0)
temp_da_0 = da.where(mask_0.compute() == 1, drop=True)
da_0 = xr.DataArray(
data=temp_da_0,
dims=temp_da_0.dims,
name=temp_da_0.name,
coords=temp_da_0.coords,
attrs=temp_da_0.attrs,
)
computedMask = mask_0.compute()
da_0 = da.where(computedMask == 1, drop=True)

mask_1 = xr.where(da.cf["longitude"] > 180, 1, 0)
temp_da_1 = da.where(mask_1.compute() == 1, drop=True)
temp_da_1.cf["longitude"][:] = temp_da_1.cf["longitude"][:] - 360
da_1 = xr.DataArray(
data=temp_da_1,
dims=temp_da_1.dims,
name=temp_da_1.name,
coords=temp_da_1.coords,
attrs=temp_da_1.attrs,
)
da_1 = da.where(computedMask != 1, drop=True)
da_1.cf["longitude"][:] = da_1.cf["longitude"][:] - 360

# put the 2 DataArrays back together in the proper order
da = xr.concat([da_1, da_0], dim="X")
Expand Down
5 changes: 5 additions & 0 deletions xpublish_wms/wms/get_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def get_map(self, ds: xr.Dataset, query: dict) -> StreamingResponse:

# Select data according to request
da = self.select_layer(ds)
if ds.gridded.name == "hycom":
da = da[
0:,
:-1,
] # Drop lng>500 on HYCOM Grid. This has to be done before select_time(da) is ran.
da = self.select_time(da)
da = self.select_elevation(ds, da)
# da = self.select_custom_dim(da)
Expand Down