Compress datasets exported to netcdf - #8367
Draft
jenshnielsen wants to merge 1 commit into
Draft
Conversation
Datasets exported to netcdf were written without any compression. Enable the deflate (gzip) compression built into netcdf4/HDF5 when exporting. The encoding is tuned rather than using the defaults, since the defaults leave a large part of the achievable compression unused: * HDF5 auto chunking picks chunks of about 20 kB. Each chunk is compressed independently so this compresses noticeably worse than using chunks of a few MB. Chunks are now sized to about 4 MB. * The shuffle filter is only enabled for non complex data. Complex numbers are stored as an HDF5 compound type of two floats and shuffling the bytes of such a compound type roughly halves the compression ratio, while shuffling is what gives most of the gain for real valued data. * Dask backed datasets are rechunked to match the HDF5 chunks before writing. Otherwise every dask block triggers a read, decompress, update and recompress cycle of the same HDF5 chunk in the delayed writer. For typical QCoDeS data this reduces the file size by a factor of 1.9 for gridded data, 3.0 for complex data and 3.3 for non gridded data, without slowing down the export. The compression is lossless and the files remain regular netcdf files readable by any netcdf client. The level is configurable via the new config option `dataset.export_netcdf_compression_level` which defaults to 4 and can be set to 0 to write uncompressed files. Higher levels are slower with almost no additional size reduction. The temporary per row files written by the chunked export of large datasets are written uncompressed since they are immediately recombined into the final file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8fa733cd-3f15-4e38-ab87-43a0fc14cbf8
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8367 +/- ##
==========================================
+ Coverage 71.09% 71.13% +0.04%
==========================================
Files 305 305
Lines 31913 31977 +64
==========================================
+ Hits 22687 22746 +59
- Misses 9226 9231 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Datasets exported to netcdf were written without any compression. Enable the deflate (gzip) compression built into netcdf4/HDF5 when exporting.
The encoding is tuned rather than using the defaults, since the defaults leave a large part of the achievable compression unused:
For typical QCoDeS data this reduces the file size by a factor of 1.9 for gridded data, 3.0 for complex data and 3.3 for non gridded data, without slowing down the export. The compression is lossless and the files remain regular netcdf files readable by any netcdf client.
The level is configurable via the new config option
dataset.export_netcdf_compression_levelwhich defaults to 4 and can be set to 0 to write uncompressed files. Higher levels are slower with almost no additional size reduction.The temporary per row files written by the chunked export of large datasets are written uncompressed since they are immediately recombined into the final file.