Package noaa.coastwatch.io
Class CFNC4Writer
java.lang.Object
noaa.coastwatch.io.EarthDataWriter
noaa.coastwatch.io.CFNC4Writer
A CF NetCDF 4 writer creates NetCDF 4 format files with CF metadata using the Nujan NetCDF 4 writing library.
Some implementation notes:
- The Nujan NetCDF 4 writing library does not support all unsigned data
types. If unsigned 16-bit or 32-bit data is present (as specified by
the
DataVariable.getUnsigned()
flag), it is written as signed data of the next largest NetCDF data type. - As much as possible, the CF metadata written to the NetCDF file conforms to the examples laid out in the document "Encoding CoastWatch Satellite Data in NetCDF using the CF Metadata Conventions", Peter Hollemans, February 2010. Some of the metadata attributes require that CWHDF style attributes be available in the input stream. This will generally not be the case for non-CW input files. For now, this is how we handle things because the CW data model does not handle all attributes as full properties of the model (such as date and time, these are fully recognized properties of the model) and so must rely on the generic metadata container attributes to populate attributes in the CF output stream. For example, the CF attribute "ancillary_variables" is populated using the CWHDF attributes "quality_mask" and "direction_variable" but the CW data model does not include the concept of ancillary variables explicitly, even though the CWHDF format supports it.
- Since:
- 3.3.1
- Author:
- Peter Hollemans
-
Field Summary
Fields inherited from class noaa.coastwatch.io.EarthDataWriter
info, isCanceled, variables, writeProgress, writeVariableName, writeVariables
-
Constructor Summary
ConstructorDescriptionCFNC4Writer
(EarthDataInfo info, String file) Creates a new NetCDF 4 file from the specified info and file name.CFNC4Writer
(EarthDataInfo info, String file, boolean writeDcs, boolean writeCw) Creates a new NetCDF 4 file from the specified info and file name. -
Method Summary
Methods inherited from class noaa.coastwatch.io.EarthDataWriter
addVariable, cancel, finalize, getDestination, getProgress, getProgressLength, getProgressVariable
-
Constructor Details
-
CFNC4Writer
Creates a new NetCDF 4 file from the specified info and file name. The required CF data variables and attributes are written to the file. No extra DCS or CW attributes are written.- Parameters:
info
- the earth data info object.file
- the new NetCDF file name.- Throws:
IOException
- if an error occurred creating the file or writing the initial data.- Since:
- 3.3.1
-
CFNC4Writer
public CFNC4Writer(EarthDataInfo info, String file, boolean writeDcs, boolean writeCw) throws IOException Creates a new NetCDF 4 file from the specified info and file name. The required CF data variables and attributes are written to the file.- Parameters:
info
- the earth data info object.file
- the new NetCDF file name.writeDcs
- DCS metadata flag, true to write DCS attributes.writeCw
- CW metadata flag, true to write CW attributes.- Throws:
IOException
- if an error occurred creating the file or writing the initial data.
-
-
Method Details
-
flush
Description copied from class:EarthDataWriter
Flushes all unwritten data to the destination.- Specified by:
flush
in classEarthDataWriter
- Throws:
IOException
- if the data destination had I/O errors.
-
close
Description copied from class:EarthDataWriter
Closes the writer and frees any resources. Theflush
method is called prior to closing.- Specified by:
close
in classEarthDataWriter
- Throws:
IOException
- if the data destination had I/O errors.
-
main
Tests this class.- Parameters:
argv
- the array of command line parameters.- Throws:
Exception
-