home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1525774670

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/7790#issuecomment-1525774670 https://api.github.com/repos/pydata/xarray/issues/7790 1525774670 IC_kwDOAMm_X85a8XlO 14983768 2023-04-27T14:13:58Z 2023-04-27T14:13:58Z NONE

Interestingly, xarray is also perfectly happy to read a numpy.datetime64 array out of a zarr store as long as the xarray metadata is present. xarray even helpfully creates an '_FillValue" attribute for the array so there is no confusion:

```

Create a zarr store directly with numpy.datetime64 type

location_zarr_direct = "from_zarr.zarr" root = zarr.open(location_zarr_direct,mode='w') z_time_array = root.create_dataset( "time",data=time,shape=time.shape,chunks=time.shape,dtype=time.dtype, fill_value=time_fill_value )

Add xarray metadata

z_time_array.attrs["_ARRAY_DIMENSIONS"] = ["time"] zarr.convenience.consolidate_metadata(location_zarr_direct)

Use xarray to read this data out

xr_read_from_zarr = xr.open_zarr(location_zarr_direct) print(xr_read_from_zarr["time"]) <xarray.DataArray 'time' (time: 2)> array([ 'NaT', '2023-01-02T00:00:00.000000000'], dtype='datetime64[ns]') Coordinates: * time (time) datetime64[ns] NaT 2023-01-02 Attributes: _FillValue: NaT ```

So I am extremely confused as to why xarray encodes time arrays so strangely when it creates the zarr store itself! (Hence https://github.com/pydata/xarray/discussions/7776)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1685803922
Powered by Datasette · Queries took 156.6ms · About: xarray-datasette