This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hi Russ, > > Thanks for your explanation. > > Recently JPSS program converted some hdf5 files into netcdf4 by removing > some meta data > information. > > One example of output netcdf4: > ftp://ftp.star.nesdis.noaa.gov/pub/corp/scsb/wchen/tmp/TATMS_npp_d20120911_t1359540_e1400256_b04529_c20120911202503549711_noaa_ops.nc > > If viewed from hdfview, no those meta data, it's a netcdf4 file, right? Or > you think this still a > hdf5 file? It's a netCDF-4 file, as running the netCDF-4 ncdump utility shows: $ ncdump -k ~/Downloads/TATMS_npp_d20120911_t1359540_e1400256_b04529_c20120911202503549711_noaa_ops.nc netCDF-4 Of course it's also an HDF5 file, because netCDF-4 files are just special kinds of HDF5 files with some added artifacts to support the netCDF-4 data model, which is different from the HDF5 data model. > The input hdf5 used is: > ftp://ftp.star.nesdis.noaa.gov/pub/corp/scsb/wchen/tmp/TATMS_npp_d20120911_t1359540_e1400256_b04529_c20120911202503549711_noaa_ops.h5 Yes, that's an HDF5 file that's not a netCDF-4 file, and the netCDF-4 file can't currently read it, although the netCDF-4 library can read some HDF5 files that don't use the HDF5 features in this list: http://www.unidata.ucar.edu/netcdf/docs/faq.html#fv15 > That's the reason that lead me to think it's possible to skip meta data > information in netcdf4 file. > > All those red "A" on some original hdf5 fields are gone in output nc file. > I guess they removed attributes. h5dump should work on both files and make it clear what was removed. --Russ > address@hidden> wrote: > > > Wanchun, > > > > > I used the simple C code: simple_xy_nc4_wr.c > > > > > http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial/simple_005fxy_005fnc4_005fwr_002ec.html#simple_005fxy_005fnc4_005fwr_002ec > > > > > > > > > > > http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial/simple_005fxy_005fnc4_005fwr_002ec.html#simple_005fxy_005fnc4_005fwr_002ec > > > > > > But generated nc file simple_xy_nc4.nc has x and y besides data when I > > > viewed it in hdfview, but I only want data, not x and y. > > > > > > Can you tell me in which part of netcd4 source code do those dimensions > > > like x and y get written out? I want to disable them or comment them > > > out so that only data is kept in file. I searched netcdf4 src directory > > > and can not pinpoint which is the correct code to change. > > > > What you're asking for is not possible, because of a mismatch between the > > netCDF-4 > > data model and the HDF5 datamodel. NetCDF-4 has "shared dimensions" such > > as x > > and y that can be shared among multiple variables, to indicate a common > > grid. HDF5, > > used as the storage layer for netCDF-4, lacks the concept of shared > > dimensions, but > > provides a different mechanism. "dimension scales", on which netCDF-4 > > shared > > dimensions are implemented. An HDF5 dimension scale is a special type of > > HDF5 > > dataset, and must always be used for every netCDF-4 dimension, because it > > is the > > only HDF5 mechanism available for modeling shared dimensions. > > > > If netCDF-4 had "anonymous dimensions" such as HDF5 dataspaces, which > > cannot be > > shared among variables, then you could define a variable that had its own > > dataspace, > > with unnamed and unsharable dimensions. If you must store just the data > > but not the > > metadata about dimensions, you probably want to use HDF5 rather than > > netCDF-4. > > > > For more on netCDF-4 dimensions versus HDF5 dimension scales, see these > > blogs by John > > Caron, explaining the issues: > > > > http://www.unidata.ucar.edu/blogs/developer/en/entry/dimensions_scales > > http://www.unidata.ucar.edu/blogs/developer/en/entry/dimension_scale2 > > > > http://www.unidata.ucar.edu/blogs/developer/en/entry/dimension_scales_part_3 > > > > http://www.unidata.ucar.edu/blogs/developer/en/entry/netcdf4_shared_dimensions > > > > --Russ > > > > Russ Rew UCAR Unidata Program > > address@hidden http://www.unidata.ucar.edu > > > > > > > > Ticket Details > > =================== > > Ticket ID: YRC-237402 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: YRC-237402 Department: Support netCDF Priority: Normal Status: Closed