Skip to content

Fix silent loss of CF-conformant NetCDF grids - #130

Merged
mikebartles merged 1 commit into
masterfrom
HMS-5051-Read-and-write-CF-1.11-conformant-NetCDF-grids
Sep 18, 2026
Merged

mikebartles merged 1 commit into
masterfrom
HMS-5051-Read-and-write-CF-1.11-conformant-NetCDF-grids

Conversation

@mikebartles

Copy link
Copy Markdown
Collaborator

A NetCDF variable that declares its statistic the way CF requires, as "time: mean", resolved to UNDEFINED and fell through to type inference. Inference then typed the record INSTANTANEOUS despite a non-zero interval, and the instantaneous index holds only records whose start and end times are equal, so every record was skipped. The reader reported no time range and every read came back empty. Callers received a null grid with nothing to explain it.

NetcdfDataReader now extracts the method applied to the time coordinate before mapping it to a data type. VortexDataType.fromString stays a plain token mapper because it is shared with the DSS path. The entry may be keyed on either the literal "time" or the file's own time axis name, both of which CF permits. Bare tokens still resolve as they did, so files vortex wrote itself are unaffected.

Inference no longer returns a point type for a record that spans a period. A record with a non-zero interval is a period type by definition, and calling it instantaneous produces a record the index cannot hold. This alone fixes the reported file, independently of any cell_methods parsing.

A record dropped for disagreeing with its own declared type is now logged and reported through DataReader.isValid(). Previously isValid() returned true with an empty message list for a file that could not be read at all, so every validation gate passed and the defect surfaced only at compute time.

The NetCDF writer now emits "time: " so vortex stops producing the non-conformant form it was the sole reader of. Two fixtures that differ only in that attribute, cf_style.nc and bare_mean.nc, pin both spellings against regression.

Resolves: HMS-5051

@tombrauer
tombrauer force-pushed the HMS-5051-Read-and-write-CF-1.11-conformant-NetCDF-grids branch from eaece00 to 3872637 Compare September 18, 2026 14:58
A NetCDF variable that declares its statistic the way CF requires, as "time: mean", resolved to UNDEFINED and fell through to type inference. Inference then typed the record INSTANTANEOUS despite a non-zero interval, and the instantaneous index holds only records whose start and end times are equal, so every record was skipped. The reader reported no time range and every read came back empty. Callers received a null grid with nothing to explain it.

NetcdfDataReader now extracts the method applied to the time coordinate before mapping it to a data type. VortexDataType.fromString stays a plain token mapper because it is shared with the DSS path. The entry may be keyed on either the literal "time" or the file's own time axis name, both of which CF permits. Bare tokens still resolve as they did, so files vortex wrote itself are unaffected.

Inference no longer returns a point type for a record that spans a period. A record with a non-zero interval is a period type by definition, and calling it instantaneous produces a record the index cannot hold. This alone fixes the reported file, independently of any cell_methods parsing.

A record dropped for disagreeing with its own declared type is now logged and reported through DataReader.isValid(). Previously isValid() returned true with an empty message list for a file that could not be read at all, so every validation gate passed and the defect surfaced only at compute time.

The NetCDF writer now emits "time: <method>" so vortex stops producing the non-conformant form it was the sole reader of. Two fixtures that differ only in that attribute, cf_style.nc and bare_mean.nc, pin both spellings against regression.

Resolves: HMS-5051
@tombrauer
tombrauer force-pushed the HMS-5051-Read-and-write-CF-1.11-conformant-NetCDF-grids branch from 3872637 to ef5e555 Compare September 18, 2026 16:05
@mikebartles
mikebartles merged commit 3e85569 into master Sep 18, 2026
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.

1 participant