Package noaa.coastwatch.io
Class CWHDFWriter
java.lang.Object
noaa.coastwatch.io.EarthDataWriter
noaa.coastwatch.io.HDFWriter
noaa.coastwatch.io.CWHDFWriter
- All Implemented Interfaces:
HDFSD
A CoastWatch HDF writer is an earth data writer that writes
CoastWatch HDF format files using the HDF library class.
- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The chunk size in kilobytes.static final double
The compatibility metadata package version.static final String
The compatibility mode flag.static final String
The compression mode flag.static final double
The current metadata package version.static final String[][]
The property defaults array.Fields inherited from class noaa.coastwatch.io.HDFWriter
closed, DEFAULT_CHUNK_SIZE, sdid
Fields inherited from class noaa.coastwatch.io.EarthDataWriter
info, isCanceled, variables, writeProgress, writeVariableName, writeVariables
-
Constructor Summary
ConstructorDescriptionCWHDFWriter
(String file) Opens an existing CWHDF file using the specified file name.CWHDFWriter
(EarthDataInfo info, double version, String file) Constructs a CWHDF writer from the specified file.CWHDFWriter
(EarthDataInfo info, String file) Constructs a CWHDF writer from the specified file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the writer and frees any resources.static String
getProperty
(String name) Gets a property value from the system properties.protected void
Writes the earth data info metadata.void
setMetaVersion
(double newVersion) Sets the CoastWatch HDF metadata version.protected void
setVariableInfo
(int sdsid, DataVariable var) Writes the data variable metadata.void
updateHistory
(String command, String[] argv) Appends a command line to the file history attribute.Methods inherited from class noaa.coastwatch.io.HDFWriter
flush, getChunked, getChunkSize, getCompressed, getFilename, getSDID, getTileDims, getType, setAttribute, setAttribute, setAttributes, setChunkCompress, setChunked, setChunkSize, setCompressed, setTileDims, writeVariable
Methods inherited from class noaa.coastwatch.io.EarthDataWriter
addVariable, cancel, finalize, getDestination, getProgress, getProgressLength, getProgressVariable
-
Field Details
-
CURRENT_METADATA_VERSION
public static final double CURRENT_METADATA_VERSIONThe current metadata package version.- See Also:
-
COMPATIBLE_METADATA_VERSION
public static final double COMPATIBLE_METADATA_VERSIONThe compatibility metadata package version.- See Also:
-
COMPATIBLE_MODE
The compatibility mode flag. When compatibility is on the HDF metadata is written to be compatible with the older metadata standard for the CoastWatch utilities version 2.3 and 2.4. Programs that expect the older metadata standard such as CDAT v0.7a or older require compatibility mode to be on. Note that the swath projection was not supported until version 3.1, thus compatibility mode cannot be used to write files containing swath data.- See Also:
-
CHUNK_SIZE
The chunk size in kilobytes. The chunk size is used to write chunked HDF variable data. A chunk size of 0 turns off chunking.- See Also:
-
COMPRESS_MODE
The compression mode flag. When compression is on the data is compressed using the GZIP deflation algorithm within the HDF file, resulting in a smaller file size. Some performance degradation is usually encountered when reading compressed HDF datasets.- See Also:
-
DEFAULTS
The property defaults array.
-
-
Constructor Details
-
CWHDFWriter
Opens an existing CWHDF file using the specified file name. The default writer settings are determined from the system properties and defaults constants.- Parameters:
file
- the HDF file name.- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.
-
CWHDFWriter
public CWHDFWriter(EarthDataInfo info, String file) throws hdf.hdflib.HDFException, IOException, ClassNotFoundException Constructs a CWHDF writer from the specified file. The default writer settings are determined from the system properties and defaults constants.- Parameters:
info
- the earth data info object.file
- the new HDF file name.- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.IOException
- if an error occurred writing the file metadata.ClassNotFoundException
- if the HDF attribute type is unknown.
-
CWHDFWriter
public CWHDFWriter(EarthDataInfo info, double version, String file) throws hdf.hdflib.HDFException, IOException, ClassNotFoundException Constructs a CWHDF writer from the specified file. The default writer settings are determined from the system properties and defaults constants, except for the metadata version.- Parameters:
info
- the earth data info object.version
- the metadata version.file
- the new HDF file name.- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.IOException
- if an error occurred writing the file metadata.ClassNotFoundException
- if the HDF attribute type is unknown.
-
-
Method Details
-
getProperty
Gets a property value from the system properties.- Parameters:
name
- the property name.- Returns:
- the property value from the system properties or the default value if the property is not set. If the property is unknown, null is returned.
-
setMetaVersion
public void setMetaVersion(double newVersion) Sets the CoastWatch HDF metadata version. Normally the version is determined from the class defaults. For compatibility with CDAT 0.7a and older, the version should be set to either 2.3 or 2.4.- Parameters:
newVersion
- the CWHDF metadata version.
-
updateHistory
public void updateHistory(String command, String[] argv) throws hdf.hdflib.HDFException, ClassNotFoundException Appends a command line to the file history attribute.- Parameters:
command
- the command or program name.argv
- an array of command line arguments.- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.ClassNotFoundException
- if the HDF attribute type is unknown.
-
setGlobalInfo
protected void setGlobalInfo() throws hdf.hdflib.HDFException, IOException, ClassNotFoundException, UnsupportedEncodingExceptionDescription copied from class:HDFWriter
Writes the earth data info metadata.- Specified by:
setGlobalInfo
in classHDFWriter
- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.IOException
- if an error occurred writing the file metadata.UnsupportedEncodingException
- if the transform class encoding is not supported.ClassNotFoundException
- if the HDF attribute type is unknown.
-
setVariableInfo
protected void setVariableInfo(int sdsid, DataVariable var) throws hdf.hdflib.HDFException, IOException, ClassNotFoundException Description copied from class:HDFWriter
Writes the data variable metadata.- Specified by:
setVariableInfo
in classHDFWriter
- Parameters:
sdsid
- the variable HDF scientific dataset ID.var
- the variable for which to write info.- Throws:
hdf.hdflib.HDFException
- if an error occurred in an HDF routine.IOException
- if an error occurred writing the file metadata.ClassNotFoundException
- if the HDF attribute type is unknown.
-
close
Description copied from class:EarthDataWriter
Closes the writer and frees any resources. Theflush
method is called prior to closing.- Overrides:
close
in classHDFWriter
- Throws:
IOException
- if the data destination had I/O errors.
-