ucar.visad
Class Quantity

java.lang.Object
  extended by ucar.visad.Quantity
Direct Known Subclasses:
ScalarQuantity, TupleQuantity

public abstract class Quantity
extends Object

Provides support for quantities (ex: temperature, wind). This class uses the facade design pattern to provide a (hopefully) more convenient API to the RealType, Real, RealTupleType, and RealTuple API-s. It also defines the root of a hierarchy of classes that encapsulate quantity-specific scientific knowledge.

Version:
$Revision: 1.13 $ $Date: 2005/05/13 18:34:03 $
Author:
Steven R. Emmerson

Field Summary
 ucar.visad.Quantity.DependenceMode DEPENDENT
          Indicates that a secondary object will be the same object as the primary object.
 ucar.visad.Quantity.DependenceMode INDEPENDENT
          Indicates that a secondary object will be a different object than the primary object.
 ucar.visad.Quantity.DependenceMode UNIMPORTANT
          Indicates that it is irrelevant whether or not a secondary object will be a different object than the primary object.
 
Method Summary
 MathType getMathType()
          Returns the natural MathType of this quantity.
 String getName()
          Returns the name of this quantity.
 RealTupleType getRealTupleType()
          Returns the VisAD RealTupleType of this quantity.
 boolean isCompatible(Data data)
          Indicates if a VisAD data object is compatible with this instance.
 boolean isCompatible(MathType type)
          Indicates if a VisAD MathType is compatible with this instance.
 RealTuple newRealTuple(double[] amounts, Unit[] units)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(double[] amounts, Unit[] units, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(double[] amounts, Unit[] units, ErrorEstimate[] errors, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(Real[] values, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 DataImpl newValue(double[] amounts, Unit[] units, ErrorEstimate[] errors, CoordinateSystem coordSys)
          Returns a single value of this quantity.
 void vet(Data data)
          Vets a VisAD data object for compatibility.
 void vet(MathType type)
          Vets a VisAD MathType for compatibility.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPENDENT

public final ucar.visad.Quantity.DependenceMode DEPENDENT
Indicates that a secondary object will be the same object as the primary object.


INDEPENDENT

public final ucar.visad.Quantity.DependenceMode INDEPENDENT
Indicates that a secondary object will be a different object than the primary object.


UNIMPORTANT

public final ucar.visad.Quantity.DependenceMode UNIMPORTANT
Indicates that it is irrelevant whether or not a secondary object will be a different object than the primary object.

Method Detail

getName

public final String getName()
Returns the name of this quantity.

Returns:
The name of this quantity.

getRealTupleType

public final RealTupleType getRealTupleType()
Returns the VisAD RealTupleType of this quantity.

Returns:
The VisAD RealTupleType of this quantity.

getMathType

public MathType getMathType()
Returns the natural MathType of this quantity. This method should be overridden in subclasses when appropriate.

Returns:
The natural MathType of this quantity. The class of the object is either RealType or RealTupleType.

newRealTuple

public final RealTuple newRealTuple(double[] amounts,
                                    Unit[] units)
                             throws VisADException,
                                    RemoteException
Returns a single tuple of this quantity. The coordinate system transformation specific to this instance will be null.

Parameters:
amounts - The numeric values.
units - The units of the numeric values. May be null.
Returns:
The single tuple corresponding to the input.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
newRealTuple(double[], Unit[], CoordinateSystem)

newRealTuple

public final RealTuple newRealTuple(double[] amounts,
                                    Unit[] units,
                                    CoordinateSystem coordSys)
                             throws VisADException,
                                    RemoteException
Returns a single tuple of this quantity. The error estimate specific to this instance will be null.

Parameters:
amounts - The numeric values.
units - The units of the numeric values. May be null.
coordSys - The coordinate system transformation for this particular tuple. Must be compatible with the default coordinate system transformation. May be null.
Returns:
The single tuple corresponding to the input.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
newRealTuple(double[], Unit[], ErrorEstimate[], CoordinateSystem)

newRealTuple

public RealTuple newRealTuple(double[] amounts,
                              Unit[] units,
                              ErrorEstimate[] errors,
                              CoordinateSystem coordSys)
                       throws VisADException,
                              RemoteException
Returns a single tuple of this quantity.

Parameters:
amounts - The numeric values.
units - The units of the numeric values. May be null.
errors - The error estimates. May be null.
coordSys - The coordinate system transformation for this particular tuple. Must be compatible with the default coordinate system transformation. May be null.
Returns:
The single tuple corresponding to the input.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
newRealTuple(Real[], CoordinateSystem)

newRealTuple

public RealTuple newRealTuple(Real[] values,
                              CoordinateSystem coordSys)
                       throws VisADException,
                              RemoteException
Returns a single tuple of this quantity.

Parameters:
values - The values.
coordSys - The coordinate system transformation. May be null, in which case the default coordinate system transformation is used.
Returns:
The single value corresponding to the input. The class of the object is RealTuple.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

newValue

public DataImpl newValue(double[] amounts,
                         Unit[] units,
                         ErrorEstimate[] errors,
                         CoordinateSystem coordSys)
                  throws VisADException,
                         RemoteException
Returns a single value of this quantity. This method should be overridden when appropriate.

Parameters:
amounts - The numerical amounts.
units - The units of the amounts. May be null -- in which case the defualt units are used; otherwise, element i is the unit for the respective numerical amount (and may, itself, be null -- in which case the default unit is used).
errors - The uncertainties of the numerical amounts. May be null, in which case the undertainties are zero; otherwise, element i is the uncertainty for the respectve numerical amount (and may, itself, be null -- in which case the uncertainty is zero).
coordSys - The coordinate system transformation. May be null, in which case the default coordinate system transformation is used.
Returns:
The single value corresponding to the input. Unless overridden, the class of the object is RealTuple.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

isCompatible

public boolean isCompatible(Data data)
                     throws VisADException,
                            RemoteException
Indicates if a VisAD data object is compatible with this instance. A VisAD data object is compatible if its VisAD MathType is compatible.

Parameters:
data - The VisAD data object to examine for compatibility.
Returns:
true if and only if the MathType of the VisAD data object is compatible with this instance.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
isCompatible(MathType)

isCompatible

public boolean isCompatible(MathType type)
                     throws VisADException
Indicates if a VisAD MathType is compatible with this instance. A RealTupleType is compatible if its RealTupleType.equalsExceptNameButUnits(visad.MathType) method returns true when given the return value of getRealTupleType() and if the coordinate system transformations are compatible. A SetType is compatible if its RealTupleType is compatible. A FunctionType is compatible if the MathType of its range is compatible. All other MathTypes are incompatible.

Parameters:
type - The VisAD MathType to examine for compatibility.
Returns:
true if and only if the MathType is compatible with this instance.
Throws:
VisADException - VisAD failure.

vet

public final void vet(Data data)
               throws TypeException,
                      VisADException,
                      RemoteException
Vets a VisAD data object for compatibility.

Parameters:
data - The VisAD data object to examine for compatibility.
Throws:
TypeException - The VisAD data object is incompatible with this quantity.
VisADException - VisAD failure.
RemoteException - Java RMI failure.

vet

public final void vet(MathType type)
               throws VisADException
Vets a VisAD MathType for compatibility.

Parameters:
type - The VisAD MathType to examine for compatibility.
Throws:
VisADException - if a core VisAD failure occurs.