NetcdfDataset extends the netCDF API, adding standard attribute parsing such as scale and offset, and explicit support for Coordinate Systems. A NetcdfDataset wraps a NetcdfFile, or is defined by an NcML document.
Be sure to close the dataset when done, best practice is to enclose in a try/finally block:
NetcdfDataset ncd = null; try { ncd = NetcdfDataset.openDataset(fileName); ... } finally { ncd.close(); }
By default NetcdfDataset is opened with all enhancements turned on. The default "enhance mode" can be set through setDefaultEnhanceMode(). One can also explicitly set the enhancements you want in the dataset factory methods. The enhancements are:
- ScaleMissing : process scale/offset/missing attributes, and automatically convert the data.
- ScaleMissingDefer : process scale/offset/missing attributes, but dont automatically convert the data. You can call VariableEnhanced.convertScaleOffsetMissing() on the data manually.
- CoordSystem : extract CoordinateSystem using the CoordSysBuilder plug-in mechanism
- ConvertEnums : automaticlly convert enum values to their corresponding Strings. If you want to do this manually, you can call Variable.lookupEnumString() manually.
Automatic ScaleMissing processing has some overhead, and if you need maximum performance, but still want to use scale/offset/missing value handling, open the NetcdfDataset with ScaleMissingDefer. The VariableDS data type is not promoted, and the data is not converted on a read, but you can call the convertScaleOffsetMissing() routines which will do the conversion on a point-by-point basis.
@author caron
@see ucar.nc2.NetcdfFile