Skip to content

Commit

Permalink
Handle non dask arrays (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci authored Mar 25, 2024
1 parent cbd287a commit ba22a86
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions xpublish_wms/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,22 @@ def project(self, da: xr.DataArray, crs: str) -> xr.DataArray:
)
y_chunks = da.cf["latitude"].chunks if da.cf["latitude"].chunks else y.shape

if da.chunks:
x_coord_array = dask_array.from_array(x, chunks=x_chunks)
y_coord_array = dask_array.from_array(y, chunks=y_chunks)
else:
x_coord_array = x
y_coord_array = y

da = da.assign_coords(
{
"x": (
da.cf["longitude"].dims,
dask_array.from_array(x, chunks=x_chunks),
x_coord_array,
),
"y": (
da.cf["latitude"].dims,
dask_array.from_array(y, chunks=y_chunks),
y_coord_array,
),
},
)
Expand Down

0 comments on commit ba22a86

Please sign in to comment.