NetCDF Attribute Conventions ("_FillValue" and "scalefactor")

Feb 28, 2011 at 4:01 PM


Is there any guidance available regarding how the SDS deals with attribute conventions such as _FIllValue and scale factor (see here:

I run into an error when trying to write the "_FillValue" metadata but this is not really a problem as I can use the MissingValue property which I assume is the intention?

I assume in the executable DataViewer.exe provided in the SDS install it does not apply the scale factor if defined in the variable metadata?

Mar 3, 2011 at 9:41 AM
Edited Mar 3, 2011 at 9:44 AM


SDS is not designed to be just a .NET wrapper for NetCDF, thus we do not deal with any NetCDF conventions. The idea behind SDS is that you can transparently change underlying data providers still using same API; e.g. a program that integrates some data through SDS, once written, without any modification can work with any type of data source, if there is an SDS provider for it. So we didn't fix any metadata conventions at all. The only attribute name we have fixed in SDS is "MissingValue" because of its high importance.

Nevertheless, if a user needs to create a NetCDF file following some conventions, it is still possible. For instance, you can add attribute "_FillValue" into a variable:

    using (var ds = DataSet.Open(""))
        ds.Add<double[]>("x", "i");
        ds.PutAttr("x", "_FillValue", -999.0); // follows NetCDF conventions
        ds["x"].MissingValue = -999.0; // standard for SDS

 Please, note that

ds.PutAttr("x", "_FillValue", -999);

  would cause an error since "-999" is considered as "int", but NetCDF expects "double" (i.e. type of variable x) as value of this attribute. The same is true for the MissingValue property.


Missing value is something different from fill value; former indicates that user explicitly said that there is no value, and the latter means that default value is used. As fill values SDS uses default values of .NET types instead of special attribute value.

DataSetViewer understands attributes "MissingValue" and "missing_value" (which is standard for NetCDF).  Unfortunately, it doesn't apply scale factor and offset attributes.





Mar 3, 2011 at 7:36 PM
Thanks for the clarification