You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Xarray maintains the encoding of datasets read from most of its supported backend formats (e.g. NetCDF, Zarr, etc.). This is very useful when you want to perfectly roundtrip but it often gets in the way, causing conflicts when writing a modified dataset or when appending to another dataset. Most of the time, the solution is to just remove the encoding from the dataset and continue on. The following code sample is found in a number of issues that reference this problem.
In many cases, the solution to these problems is to leave the original dataset encoding behind and either use Xarray's default encoding (or the backends default) or to specify one's own encoding options. Both cases would benefit from a convenience method to reset the original encoding. Something like would serve this process:
ds=xr.open_dataset(...).reset_encoding()
Describe alternatives you've considered
Variations on the API above could also be considered:
Is your feature request related to a problem?
Xarray maintains the encoding of datasets read from most of its supported backend formats (e.g. NetCDF, Zarr, etc.). This is very useful when you want to perfectly roundtrip but it often gets in the way, causing conflicts when writing a modified dataset or when appending to another dataset. Most of the time, the solution is to just remove the encoding from the dataset and continue on. The following code sample is found in a number of issues that reference this problem.
A sample of issues that show variants of this problem.
to_zarr
#5219to_zarr(append_dim="time")
appends incorrect datetimes #5969to_zarr
with append or region mode and_FillValue
doesnt work #6329Describe the solution you'd like
In many cases, the solution to these problems is to leave the original dataset encoding behind and either use Xarray's default encoding (or the backends default) or to specify one's own encoding options. Both cases would benefit from a convenience method to reset the original encoding. Something like would serve this process:
Describe alternatives you've considered
Variations on the API above could also be considered:
or even:
We can/should also do a better job of surfacing inconsistent encoding in our backends (e.g.
to_netcdf
).Additional context
No response
The text was updated successfully, but these errors were encountered: