xpublish-community / xpublish

Publish Xarray Datasets via a REST API.
https://xpublish.readthedocs.io
Apache License 2.0
167 stars 23 forks source link

Encode coords for zarr router #178

Closed mpiannucci closed 1 year ago

mpiannucci commented 1 year ago

See #175

Previously, the coordinates of each DataArray were not encoded, only the dims were. So we couldnt plot this how it is shown below.

Tested with:

# We can access our API using fsspec's HTTPFileSystem
fs = HTTPFileSystem()

# The http mapper gives us a dict-like interface to the API
http_map = fs.get_mapper("http://0.0.0.0:8090/datasets/dbofs")

ds = xr.open_zarr(http_map, consolidated=True)
ds.temp.isel(ocean_time=0, s_rho=0).plot(x='lon_rho', y='lat_rho', cmap='jet')

image

mpiannucci commented 1 year ago

The only thing missing is a test case. I will circle back to that, probably have to modify the create_dataset function in the test utils to make something with differing coords and dims.

mpiannucci commented 1 year ago

Added a simple test case, lemme know if we need something more comprehensive