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.
David, If by "booleans seem to be supported" you mean that the netCDF data model supports attributes with no values (and thus no type), that's almost right, except attributes still have to be given a type, and boolean is not a supported type. If the mere existence of an attribute is all that's important, you can assign it a numeric value such as 1, or a string value, such as "" (the empty string). The latter is the convention supported by ncdump for attributes that are created with no values (which the APIs currently allow). If you want to store a mask array efficiently, there is a convention for doing that that has been accepted into the CF conventions, and will appear in the next version of the CF conventions document. It uses just one bit for each flag value, and permits both exclusive flags as well as enumerated flags: http://cf-pcmdi.llnl.gov/trac/ticket/26 There is currently no API in netCDF to support that convention, so if you want to look at that and develop something suitable, it might be useful. One thing to remember about new data types in netCDF is that it should be possible to implement support for them portably in all the language interfaces for netCDF (C, Fortran-77, Fortran-90, C++, Java, Perl, Python, Ruby, etc.) so that data written with any language interface can be read and interpreted correctly with any other language interface. This principal is violated currently by NC_UINT64, which is supposed to represent unsigned 8-byte integers, not available in all the above languages, but I'd like to not see any more such types that can cause problems for interoperability. Adding a new boolean primitive type to the netCDF data model might be a good idea for a future release, but seems quite ambitious to add as patch to the current release, if it covered more than just the Fortran-90 interface. We do consider patches, however. What might be more useful at this point is an independent evaluation of the adequacy of the proposed masking convention or an implementation of auxiliary APIs to Unidata's libcf to implement it, or even to check for conformance with the rules proposed for this convention. Anyway, thanks for the offer of help! I agree that boolean masks are useful, and we want it to be easy to represent data that uses boolean masks in netCDF. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: XDD-271000 Department: Support netCDF Priority: Normal Status: Closed