Skip to content

Restore TT2000 typing for integer epoch attributes - #349

Merged
bryan-harter merged 1 commit into
lasp:mainfrom
leowerneck:348---bug-all-time-typed-variables-skipped-in-xarray_to_cdf
Oct 20, 2026
Merged

bryan-harter merged 1 commit into
lasp:mainfrom
leowerneck:348---bug-all-time-typed-variables-skipped-in-xarray_to_cdf

Conversation

@leowerneck

@leowerneck leowerneck commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Closes #348. Closes IMAP-Science-Operations-Center/imap_processing#3579.

Description

#344 stopped casting FILLVAL, VALIDMIN, and VALIDMAX to the variable's type for all time-typed variables (CDF_EPOCH, CDF_EPOCH16, CDF_TIME_TT2000). That was only needed for non-integer values that can't be represented as TT2000 and overflow on read-back. Integer attributes, the usual case for TT2000 variables, are now written as CDF_INT8 instead of CDF_TIME_TT2000, breaking ISTP compliance.

This PR skips the cast for time-typed variables only when the attribute value is not an integer. Integer values are cast to the variable's type as they were before #344, and non-integer values are still left alone, so the #343 fix is kept.

Two regression tests are added to tests/test_xarray_reader_writer.py:

  • test_xarray_to_cdf_casts_istp_integer_epoch_attributes_to_tt2000: integer attributes on a TT2000 variable are written as CDF_TIME_TT2000, and integer attributes on a non-time variable stay CDF_INT8. Fails on main.
  • test_xarray_to_cdf_preserves_istp_float_epoch_attributes: float attributes on a TT2000 variable are not cast to TT2000 and round-trip through cdf_to_xarray without overflowing. Fails if the cast is applied unconditionally, as it was before Fix datetime conversion failures observed with NumPy 2.5 #344.

Testing

Running:

uv run pytest --remote-data

results in 113 passed.

@leowerneck leowerneck changed the title Fix issue 348 Restore TT2000 typing for integer epoch attributes Oct 20, 2026
@bryan-harter
bryan-harter merged commit e40784a into lasp:main Oct 20, 2026
12 of 13 checks passed
@leowerneck
leowerneck deleted the 348---bug-all-time-typed-variables-skipped-in-xarray_to_cdf branch October 20, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG - All time-typed variables skipped in xarray_to_cdf BUG - EPOCH attributes with wrong type

2 participants