pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.62k stars 1.09k forks source link

Easy way to set the compression level for all dataarrays in a datatree? #9352

Open keewis opened 3 months ago

keewis commented 3 months ago

What is your issue?

Question Is there an easy/convenient way to set the compression level for all DataArrays in a datatree? I've been using the solution here when saving xarray.Datasets, but this solution doesn't seem to map conveniently to datatree. Maybe I'm missing something?

Background I often deal with multiple datasets, each on the order of 10 GBs, and this fills up harddrives fast. Typically when I write xarray.Datasets to file, I like to use gzip compression with level around 5, and this tends to reduce the file size by around 50%.

Thanks!

Edit: Or is recommended practice to update the compression info for each DataArray? (The second answer to the above link)

Originally posted by @jwbrooks0 in https://github.com/xarray-contrib/datatree/issues/58#issue-1103938449