Repository navigation
Fix xarray compression handling for SPDF epoch-like time variables - #332
Merged
bryan-harter merged 1 commit intoMay 21, 2026
Merged
Conversation
Expand the xarray writer's automatic compression skip logic so it better matches the SPDF Java checker’s notion of an ISTP epoch variable. Previously, xarray_to_cdf only disabled compression for variables named `epoch` or `epoch_N`. That was too narrow for ISTP validation. In particular, time-typed support variables such as IDEX `on_off_times` were still being written with gzip compression even though the SPDF validator treats them as epoch-like time variables that should not be compressed. Update the compression predicate to treat a variable as SPDF epoch-like when it: - has a CDF time datatype (`CDF_EPOCH`, `CDF_EPOCH16`, or `CDF_TIME_TT2000`) - is not `range_epoch` - and either: - is scalar in final CDF terms and record-varying, or - is an xarray time coordinate over its own dimension Keep the previous `epoch` / `epoch_N` behavior intact so existing ISTP epoch variables continue to be written without compression. Also add focused regression coverage to verify that: - `epoch` and `epoch_1` are still written uncompressed by default - an `on_off_times`-style TT2000 variable is now written uncompressed - `range_epoch` remains compressible - explicit `compression_skip_vars` still works as expected Validated locally with: - `/home/david/.virtualenvs/imap/bin/python -m pytest -q tests/test_xarray_reader_writer.py -k 'compression'`
Member
|
Thanks for that! |
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.
Summary
This PR broadens
cdflib's automatic compression-skip logic for time variables so it better matches the SPDF Java ISTP checker.Previously,
xarray_to_cdf()only disabled compression for variables namedepochorepoch_N. That was too narrow for ISTP validation. In particular, time-typed support variables such as IDEXon_off_timeswere still being written with gzip compression even though the SPDF validator treats them as epoch-like variables that should not be compressed.What Changed
The xarray writer now treats a variable as SPDF epoch-like for compression purposes when it:
CDF_EPOCHCDF_EPOCH16CDF_TIME_TT2000range_epochThe previous
epoch/epoch_Nbehavior is preserved, so existing ISTP epoch variables continue to be written without compression.This change is intentionally scoped to the xarray writer’s compression policy. It does not change the lower-level CDF writer behavior more broadly.
Why
The SPDF Java checker does not key this rule only off the variable name
epoch. Its epoch compliance logic identifies the file’s ISTP epoch variable based on time datatype and variable shape/variance, then enforces that it not be compressed.This PR brings
cdflibcloser to that behavior so local CDF generation aligns better with SPDF validation.Testing
Added regression coverage to verify that:
epochis still written uncompressed by defaultepoch_1is still written uncompressed by defaulton_off_times-style TT2000 variable is written uncompressedrange_epochremains compressiblecompression_skip_varsstill works as expectedValidated locally with: