pydata / pydata/xarray

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

Open
#9,352 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement topic-DataTree
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin by examining how datatree writes xarray.Datasets and how DataArray encoding is passed through; compare that with the linked per-variable encoding approach. Done means documenting or providing a convenient, consistent way to set gzip compression around level 5 across all DataArrays, or clearly stating the recommended per-DataArray practice.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.