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
nc_open("proteins.mmcif", NC_NOWRITE|NC_UDF8. &ncif);
This will cause the nc_open() to select the dispatch layer associated with UDF8, which is the mmCIF layer.
In order for this to work in netcdf4-python, we need to be able to specify the mode flag when a file is opened, and then pass it down to netcdf-c.
I'm not familiar with netcdf4-python code and would welcome guidence and suggestions as to how to proceed...
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:
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
nc_open("proteins.mmcif", NC_NOWRITE|NC_UDF8. &ncif);This will cause the nc_open() to select the dispatch layer associated with UDF8, which is the mmCIF layer.
In order for this to work in netcdf4-python, we need to be able to specify the mode flag when a file is opened, and then pass it down to netcdf-c.
I'm not familiar with netcdf4-python code and would welcome guidence and suggestions as to how to proceed...