Skip to content

Improve support for NetCDF fill value and valid range attributes#1956

Merged
axelboc merged 2 commits intomainfrom
nc-valid-range
Feb 4, 2026
Merged

Improve support for NetCDF fill value and valid range attributes#1956
axelboc merged 2 commits intomainfrom
nc-valid-range

Conversation

@axelboc
Copy link
Contributor

@axelboc axelboc commented Feb 3, 2026

Part of #1918

A while back, we added basic support for NetCDF's _FillValue attribute.

In this PR, I go a step further by implementing the spec more accurately, and by supporting three additional NetCDF attributes: valid_min, valid_max and valid_range. These attributes are documented here: https://docs.unidata.ucar.edu/netcdf-c/current/attribute_conventions.html — the section on the valid_range attribute actually talks about the order in which the attributes should be used. It also explains that _FillValue acts as an (invalid) upper or lower bound depending on if it's positive or negative.

So in this PR:

  • I add support for valid_min, valid_max and valid_range.
  • I add support for valid_min/max/range and _FillValue to the NX Line and NX Heatmap visualizations.
  • I make sure _FillValue acts as an invalid upper or lower bound (instead of just as an invalid exact value).
  • I bring the floating point equality check for _FillValue in line with the spec (i.e. difference lower than two epsilons).
  • I add mock datasets and tests.
  • I create a new netcdf visualization pack for the new code.
image

@axelboc axelboc force-pushed the nc-valid-range branch 2 times, most recently from 2393bd2 to aa82dea Compare February 3, 2026 15:35
@axelboc
Copy link
Contributor Author

axelboc commented Feb 4, 2026

/approve

@axelboc axelboc requested a review from loichuder February 4, 2026 08:37
Copy link
Member

@loichuder loichuder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fell swoop 👏

@axelboc axelboc merged commit c4d51de into main Feb 4, 2026
13 checks passed
@axelboc axelboc deleted the nc-valid-range branch February 4, 2026 14:27
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.

2 participants