Class CWHDFWriter

All Implemented Interfaces:
HDFSD

public class CWHDFWriter extends HDFWriter
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 Details

    • CURRENT_METADATA_VERSION

      public static final double CURRENT_METADATA_VERSION
      The current metadata package version.
      See Also:
    • COMPATIBLE_METADATA_VERSION

      public static final double COMPATIBLE_METADATA_VERSION
      The compatibility metadata package version.
      See Also:
    • COMPATIBLE_MODE

      public static final String 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

      public static final String 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

      public static final String 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

      public static final String[][] DEFAULTS
      The property defaults array.
  • Constructor Details

    • CWHDFWriter

      public CWHDFWriter(String file) throws hdf.hdflib.HDFException
      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

      public static String getProperty(String name)
      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, UnsupportedEncodingException
      Description copied from class: HDFWriter
      Writes the earth data info metadata.
      Specified by:
      setGlobalInfo in class HDFWriter
      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 class HDFWriter
      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

      public void close() throws IOException
      Description copied from class: EarthDataWriter
      Closes the writer and frees any resources. The flush method is called prior to closing.
      Overrides:
      close in class HDFWriter
      Throws:
      IOException - if the data destination had I/O errors.