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 Noman, > Per your suggestions we are now letting user specify units in all > export tools and writing them in the netCDF file. But we also want > to let users write a netCDF file without units in case they don't > know the units. My thought is - no unit is better than incorrect > unit. > > There is no problem when we know the unit. > > However, it seems like we are having problem when we don't specify > the unit of a variable. We can still create the file but the values > (data) in the netCDF file are incorrect (garbage). > > Are we using incorrect method or something while specifying a > variable and writing to a netCDF file? Is there any way we can write > a variable without specifying units if necessary? There should be no problem writing a variable without specifying a units attribute. The units attribute is only a convention and is not treated in any special way by the netCDF library, it just treats it like any other attribute. There are times when no units attribute is meaningful, for example if a variable just refers to an index, as in the "lastReport" variable of the Station Data described in http://www.unidata.ucar.edu/packages/netcdf-java/formats/StationDataFormat.html Lots of people write netCDF variables without units and read the data in OK. Do you have a small example writing a variable without a unit that fails? If so, please send it and we'll try to figure out what is going wrong. --Russ