You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow mode flag to be passed to nc_open() to support additional dispatch layers #1490
The netcdf-c library has a feature called User-Defined Formats (docs here). User defined formats allow the library to read and write other backend formats (beyond classic formats, HDF5, and HDF4, which all come with netCDF.)
The NetCDF Expansion Pack (NEP) uses this capability to allow the netcdf-c library to read a bunch of additional formats, as if they were netCDF. Currently these additions formats include:
GRIB2 - WMO format for gridded weather data
CDF - NASA format for heliophysics
FITS - NASA format for images from space missions
PDS4 - NASA/ESA format for data from planetary, asteroid, and space telescope missions
DICOM - Medical images of all kinds
PDB/mmCIF - Protein folding databases
This is all good, clean fun, and the format can usually be detected by magic number. When that happens, the python API will be able to transparently open the file with netcdf-c/NEP, as if it were netCDF.
However, when there is no magic number (for example with mmCIF), then there is no way for the netcdf-c library to determine which dispatch layer to use. For this reason, the nc_open() accepts flags in the mode field to override the automatic selection of dispatch layer. For example, I can call
I outlined this idea to Jeff in email and got this encouraging reply which may contain the clue as to how I should proceed:
Hi Ed: That sounds like a really great idea! I would especially love to use the interface to read GRIB2. Would be happy to add the extra flag to Dataset.init. Feel free to open an issue and/or pull request on the github.
Never mind Ed - AI figured it out. Can you take a look at PR #1518? Seems like all the formats in your list work without this extra flag, except maybe DICOM and mmCIF.
Activity
captainkirk99 commentedon Aug 2, 2026
I outlined this idea to Jeff in email and got this encouraging reply which may contain the clue as to how I should proceed:
jswhit commentedon Oct 23, 2026
@captainkirk99 I'm finally starting to work on this! It should be straightforward to pass the extra mode flag as a keyword to
Dataset. One question though - how do I declare it in the Cython code? Is it achar *or an integer? It looks like from https://intelligent-data-design-inc.github.io/NEP/group__nep__magic__numbers.html that it is a C string.jswhit commentedon Oct 23, 2026
Never mind Ed - AI figured it out. Can you take a look at PR #1518? Seems like all the formats in your list work without this extra flag, except maybe DICOM and mmCIF.