visad.data.netcdf.out
Class DependentRealVar

java.lang.Object
  extended byucar.netcdf.ProtoVariable
      extended byvisad.data.netcdf.out.ExportVar
          extended byvisad.data.netcdf.out.DependentVar
              extended byvisad.data.netcdf.out.DependentRealVar
All Implemented Interfaces:
Accessor, Cloneable, MultiArrayInfo, Named, Serializable

class DependentRealVar
extends DependentVar

The DependentRealVar class adapts numeric data in a VisAD data object to a netCDF, dependent-variable, API for the purpose of exporting the data.


Constructor Summary
protected DependentRealVar(Real real, VisADAccessor accessor)
          Construct.
 
Method Summary
 void copyin(int[] origin, MultiArray multiArray)
          Set an array element identified by position.
 MultiArray copyout(int[] origin, int[] shape)
          Return a MultiArray into a slice of the data.
 Object get(int[] indexes)
          Return a netCDF datum identified by position.
protected  VisADAccessor getAccessor()
          Return the data accessor.
 boolean getBoolean(int[] indexes)
          Return an array element identified by position.
 byte getByte(int[] indexes)
          Return an array element identified by position.
 char getChar(int[] indexes)
          Return an array element identified by position.
 double getDouble(int[] indexes)
          Return an array element identified by position.
protected static Number getFillValue(Class type)
          Return the fill-value object for a numeric netCDF variable of the given type.
 float getFloat(int[] indexes)
          Return an array element identified by position.
 int getInt(int[] indexes)
          Return an array element identified by position.
protected static Class getJavaClass(Set set)
          Get the class of the Java primitive type that can contain the VisAD Set of a VisAD range value.
 long getLong(int[] indexes)
          Return an array element identified by position.
 short getShort(int[] indexes)
          Return an array element identified by position.
protected static Attribute[] myAttributes(Real real)
          Get the netCDF attributes for a DependentRealVar.
 void set(int[] index, Object value)
          Set an array element identified by position.
 void setBoolean(int[] index, boolean value)
          Set an array element identified by position.
 void setByte(int[] index, byte value)
          Set an array element identified by position.
 void setChar(int[] index, char value)
          Set an array element identified by position.
 void setDouble(int[] index, double value)
          Set an array element identified by position.
 void setFloat(int[] index, float value)
          Set an array element identified by position.
 void setInt(int[] index, int value)
          Set an array element identified by position.
 void setLong(int[] index, long value)
          Set an array element identified by position.
 void setShort(int[] index, short value)
          Set an array element identified by position.
 Object toArray()
          Convert values to an array.
 Object toArray(Object obj, int[] dummy1, int[] dummy2)
          Convert values to an array.
 
Methods inherited from class ucar.netcdf.ProtoVariable
clone, getAttribute, getAttributes, getComponentType, getDimensionIterator, getLengths, getName, getRank, isScalar, isUnlimited, putAttribute, toCdl, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DependentRealVar

protected DependentRealVar(Real real,
                           VisADAccessor accessor)
                    throws VisADException,
                           BadFormException
Construct.

Parameters:
real - The VisAD Real object to be adapted.
accessor - The means for accessing the individual VisAD Real objects of the enclosing VisAD data object.
Throws:
BadFormException - The VisAD data object cannot be adapted to a netCDF API
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.
Method Detail

myAttributes

protected static Attribute[] myAttributes(Real real)
                                   throws VisADException,
                                          BadFormException
Get the netCDF attributes for a DependentRealVar.

Parameters:
real - The VisAD data object for which netCDF Attribute must be created.
Returns:
An array of netCDF Attributes for real.
Throws:
BadFormException - The VisAD data object cannot be adapted to a netCDF API
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.

getJavaClass

protected static Class getJavaClass(Set set)
                             throws VisADException
Get the class of the Java primitive type that can contain the VisAD Set of a VisAD range value.

Parameters:
set - The VisAD Set describing the range of the variable data.
Returns:
The Java class corresponding to the variable data (i.e. Double, Float, Integer, etc.).
Throws:
VisADException - Problem in core VisAD. Probably some VisAD object couldn't be created.

getFillValue

protected static Number getFillValue(Class type)
                              throws BadFormException
Return the fill-value object for a numeric netCDF variable of the given type.

Parameters:
type - netCDF type (e.g. Character.TYPE, Float.TYPE).
Returns:
The default fill-value object for the given netCDF type.
Throws:
BadFormException - Unknown netCDF type.

get

public Object get(int[] indexes)
           throws IOException
Return a netCDF datum identified by position.

Specified by:
get in interface Accessor
Specified by:
get in class DependentVar
Parameters:
indexes - The netCDF indexes of the desired datum. Includes all adapted dimensions -- including those of all enclosing VisAD data objects.
Returns:
A Java Double that contains the data value or NaN if the data is missing.
Throws:
IOException - Data access failure.

getAccessor

protected VisADAccessor getAccessor()
Return the data accessor.

Returns:
The data accessor that knows how to get the data from the VisAD data object.

copyin

public void copyin(int[] origin,
                   MultiArray multiArray)
            throws IOException
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
copyin in interface Accessor
Parameters:
origin - int array specifying the starting index.
multiArray - MultiArray with the same componentType as this and shape smaller than this.getLengths() - origin
Throws:
IOException

set

public void set(int[] index,
                Object value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
set in interface Accessor
Parameters:
index - MultiArray index
value - the new value.

setBoolean

public void setBoolean(int[] index,
                       boolean value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setBoolean in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setChar

public void setChar(int[] index,
                    char value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setChar in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setByte

public void setByte(int[] index,
                    byte value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setByte in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setShort

public void setShort(int[] index,
                     short value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setShort in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setInt

public void setInt(int[] index,
                   int value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setInt in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setLong

public void setLong(int[] index,
                    long value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setLong in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setFloat

public void setFloat(int[] index,
                     float value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setFloat in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

setDouble

public void setDouble(int[] index,
                      double value)
Set an array element identified by position. Not supported for read-only, VisAD data objects.

Specified by:
setDouble in interface Accessor
See Also:
Accessor.set(int[], java.lang.Object)

getBoolean

public boolean getBoolean(int[] indexes)
                   throws IOException
Return an array element identified by position. Not supported.

Specified by:
getBoolean in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getChar

public char getChar(int[] indexes)
             throws IOException
Return an array element identified by position. Not supported.

Specified by:
getChar in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getByte

public byte getByte(int[] indexes)
             throws IOException
Return an array element identified by position. Not supported.

Specified by:
getByte in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getShort

public short getShort(int[] indexes)
               throws IOException
Return an array element identified by position. Not supported.

Specified by:
getShort in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getInt

public int getInt(int[] indexes)
           throws IOException
Return an array element identified by position. Not supported.

Specified by:
getInt in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getLong

public long getLong(int[] indexes)
             throws IOException
Return an array element identified by position. Not supported.

Specified by:
getLong in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getFloat

public float getFloat(int[] indexes)
               throws IOException
Return an array element identified by position. Not supported.

Specified by:
getFloat in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

getDouble

public double getDouble(int[] indexes)
                 throws IOException
Return an array element identified by position. Not supported.

Specified by:
getDouble in interface Accessor
Throws:
IOException
See Also:
Accessor.get(int[])

copyout

public MultiArray copyout(int[] origin,
                          int[] shape)
                   throws IOException
Return a MultiArray into a slice of the data. Not supported.

Specified by:
copyout in interface Accessor
Parameters:
origin - int array specifying the starting index.
shape - int array specifying the extents in each dimension. This becomes the shape of the return.
Returns:
the MultiArray with the specified shape
Throws:
IOException

toArray

public Object toArray()
Convert values to an array. Not supported.

Specified by:
toArray in interface Accessor
Returns:
a one dimensional Array containing all the elements in this MultiArray

toArray

public Object toArray(Object obj,
                      int[] dummy1,
                      int[] dummy2)
Convert values to an array. Not supported.

Specified by:
toArray in interface Accessor
Returns:
a one dimensional Array containing the specified elements