Terrenus HRPT v2.2

terrenus.util
Class HDFServices

java.lang.Object
  extended by terrenus.util.HDFServices

public class HDFServices
extends java.lang.Object

The HDFServices class contains a number of static methods to help write Hierarchical Data Format (HDF) version 4 data files.


Constructor Summary
HDFServices()
           
 
Method Summary
static int createVariable(int sdid, java.lang.String name, int hdfType, java.lang.String units, int[] dims, boolean keepOpen)
          Creates a new HDF variable with standard attributes.
static void writeAtt(int sdid, java.lang.String name, java.lang.Object value)
          Writes an HDF attribute.
static void writeVariable(int sdid, int varRef, boolean isOpen, int[] start, int[] stride, int[] count, java.lang.Object data)
          Writes data to an HDF variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDFServices

public HDFServices()
Method Detail

writeAtt

public static void writeAtt(int sdid,
                            java.lang.String name,
                            java.lang.Object value)
                     throws java.io.IOException
Writes an HDF attribute.

Parameters:
sdid - the scientific dataset ID for either a file or variable.
name - the name of the attribute.
value - the value for the attribute. Primitive Java types must be passed as an array.
Throws:
java.io.IOException - if an HDF or other error occurred writing the attribute.

createVariable

public static int createVariable(int sdid,
                                 java.lang.String name,
                                 int hdfType,
                                 java.lang.String units,
                                 int[] dims,
                                 boolean keepOpen)
                          throws java.io.IOException
Creates a new HDF variable with standard attributes.

Parameters:
sdid - the scientific dataset ID for the HDF file.
name - the new variable name to create.
hdfType - the HDF type for the variable. Currently only DFNT_INT16 (scale_factor = 0.01) and DFNT_FLOAT32 (no scale_factor) are supported.
units - the data units string.
dims - the variable dimensions.
keepOpen - the keep open flag, true to keep the variable open after creating it or false to end access to the variable.
Returns:
the scientific dataset ID for the new variable if keepOpen is true, or the SD index if keepOpen is false.
Throws:
java.io.IOException - if an HDF or other error occurred creating the variable.

writeVariable

public static void writeVariable(int sdid,
                                 int varRef,
                                 boolean isOpen,
                                 int[] start,
                                 int[] stride,
                                 int[] count,
                                 java.lang.Object data)
                          throws java.io.IOException
Writes data to an HDF variable.

Parameters:
sdid - the scientific dataset ID for the file.
varRef - the variable reference, either the scientific dataset ID for open variables, or the scientific dataset index for closed variables. See the createVariable(int, java.lang.String, int, java.lang.String, int[], boolean) method for an explanation of open versus closed.
isOpen - the open flag, true if the variable is open already or false if not. If the variable is not open, it is opened, written to, and then closed. If the variable is already open, it is left open.
start - the starting data coordinates for writing data.
stride - the stride for for writing data.
count - the count of data values to write in each data dimension.
data - the data value array to write.
Throws:
java.io.IOException - if an HDF error occurred writing the variable data.

Terrenus HRPT v2.2