ucar.visad
Class ScalarQuantity

java.lang.Object
  extended by ucar.visad.Quantity
      extended by ucar.visad.ScalarQuantity

public abstract class ScalarQuantity
extends Quantity

Provides support for single-component quantities. This class supports both scalar quantities with and without an associated coordinate system transformation. This is done so that the knowledge and semantics of superclass scalar quantities without associated coordinate system transformations can be inherited by subclass scalar quantities that have associated coordinate system transformations (e.g. ucar.visad.physics.PlaneAngle and ucar.visad.geoscience.Azimuth or ucar.visad.physics.Length and ucar.visad.geoscience.Altitude) -- thus, supporting a hierarchy of scientific scalar quantities without regard to coordinate system relationships.

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

Field Summary
 
Fields inherited from class ucar.visad.Quantity
DEPENDENT, INDEPENDENT, UNIMPORTANT
 
Constructor Summary
protected ScalarQuantity(RealType realType)
          Constructs from an existing RealType.
protected ScalarQuantity(RealType realType, CoordinateSystem coordSys)
          Constructs from a name, an existing RealType, and a coordinate system transformation.
protected ScalarQuantity(RealType realType, CoordinateSystem coordSys, Set domain)
          Constructs from a name, an existing RealType, a coordinate system transformation, and a default domain set.
protected ScalarQuantity(String name, Unit unit)
          Constructs from a name and a default unit.
protected ScalarQuantity(String name, Unit unit, Set set)
          Constructs from a name, default unit, and default representational set.
protected ScalarQuantity(String name, Unit unit, Set set, int attrMask)
          Constructs from a name, default unit, default representational set, and an attribute mask.
 
Method Summary
 MathType getMathType()
          Returns the natural MathType of this quantity.
 RealType getRealType()
          Returns the VisAD RealType of this quantity.
 boolean isCompatible(MathType type)
          Indicates if a VisAD MathType is compatible with this instance.
 Real newReal(double amount)
          Returns the single value of this quantity corresponding to a numeric amount in the default unit.
 Real newReal(double amount, Unit unit)
          Returns the single value of this quantity corresponding to a numeric amount and a unit.
 Real newReal(double amount, Unit unit, ErrorEstimate error)
          Returns the single value of this quantity corresponding to a numeric amount, a unit, and an error estimate.
 RealTuple newRealTuple(double amount, Unit unit)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(double amount, Unit unit, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(double amount, Unit unit, ErrorEstimate error, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 RealTuple newRealTuple(Real value, CoordinateSystem coordSys)
          Returns a single tuple of this quantity.
 DataImpl newValue(double[] amounts, Unit[] units, ErrorEstimate[] errors, CoordinateSystem coordSys)
          Returns the single value of this quantity corresponding to numeric amounts, units, error estimates, and coordinate system.
 
Methods inherited from class ucar.visad.Quantity
getName, getRealTupleType, isCompatible, newRealTuple, newRealTuple, newRealTuple, newRealTuple, vet, vet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScalarQuantity

protected ScalarQuantity(String name,
                         Unit unit)
                  throws TypeException,
                         VisADException
Constructs from a name and a default unit. The default representational set will be FloatSet.

Parameters:
name - The name of the scalar quantity.
unit - The default unit of the scalar quantity.
Throws:
TypeException - The VisAD RealType already exists but has an incompatible unit or representational set.
VisADException - VisAD failure.
See Also:
ScalarQuantity(String name, Unit unit, Set set)

ScalarQuantity

protected ScalarQuantity(String name,
                         Unit unit,
                         Set set)
                  throws VisADException
Constructs from a name, default unit, and default representational set. The attribute mask will be zero.

Parameters:
name - The name of the scalar quantity.
unit - The default unit of the scalar quantity.
set - The default representational set of the quantity. It shall be an instance of visad.DoubleSet, visad.FloatSet, visad.Integer1DSet, or null. If null, then the default is visad.FloatSet.
Throws:
VisADException - VisAD failure.
See Also:
ScalarQuantity(String name, Unit unit, Set set, int attrMask)

ScalarQuantity

protected ScalarQuantity(String name,
                         Unit unit,
                         Set set,
                         int attrMask)
                  throws VisADException
Constructs from a name, default unit, default representational set, and an attribute mask.

Parameters:
name - The name of the scalar quantity.
unit - The default unit of the scalar quantity.
set - The default representational set of the quantity. It shall be an instance of visad.DoubleSet, visad.FloatSet, visad.Integer1DSet, or null. If null, then the default is visad.FloatSet.
attrMask - The attribute mask: 0 or INTERVAL.
Throws:
VisADException - VisAD failure.
See Also:
ScalarQuantity(RealType realType)

ScalarQuantity

protected ScalarQuantity(RealType realType)
                  throws TypeException,
                         VisADException
Constructs from an existing RealType. The coordinate system transformation will be null.

Parameters:
realType - The existing RealType.
Throws:
TypeException - if an instance cannot be created.
VisADException - if a core VisAD failure occurs.
See Also:
ScalarQuantity(RealType, CoordinateSystem)

ScalarQuantity

protected ScalarQuantity(RealType realType,
                         CoordinateSystem coordSys)
                  throws TypeException,
                         VisADException
Constructs from a name, an existing RealType, and a coordinate system transformation. The default domain set will be null.

Parameters:
realType - The existing RealType.
coordSys - The coordinate system transformation.
Throws:
TypeException - if an instance cannot be created.
VisADException - if a core VisAD failure occurs.
See Also:
ScalarQuantity(RealType, CoordinateSystem, visad.Set)

ScalarQuantity

protected ScalarQuantity(RealType realType,
                         CoordinateSystem coordSys,
                         Set domain)
                  throws TypeException,
                         VisADException
Constructs from a name, an existing RealType, a coordinate system transformation, and a default domain set. The name of the quantity will be that of the RealType.

Parameters:
realType - The existing RealType.
coordSys - The coordinate system transformation.
domain - The default domain set.
Throws:
TypeException - if an instance cannot be created.
VisADException - if a core VisAD failure occurs.
Method Detail

getRealType

public final RealType getRealType()
Returns the VisAD RealType of this quantity.

Returns:
The VisAD RealType of this quantity.

getMathType

public final MathType getMathType()
Returns the natural MathType of this quantity.

Overrides:
getMathType in class Quantity
Returns:
The natural MathType of this quantity. The class of the object is RealType.

newReal

public final Real newReal(double amount)
                   throws VisADException
Returns the single value of this quantity corresponding to a numeric amount in the default unit. The error estimate will be null.

Parameters:
amount - The numeric value.
Returns:
The single value of this quantity corresponding to the input.
Throws:
VisADException - VisAD failure.
See Also:
newReal(double amount, Unit unit)

newReal

public final Real newReal(double amount,
                          Unit unit)
                   throws VisADException
Returns the single value of this quantity corresponding to a numeric amount and a unit. The error estimate will be null.

Parameters:
amount - The numeric value.
unit - The unit of the numeric value. May be null.
Returns:
The single value of this quantity corresponding to the input.
Throws:
VisADException - VisAD failure.
See Also:
newReal(double amount, Unit unit, ErrorEstimate error)

newReal

public Real newReal(double amount,
                    Unit unit,
                    ErrorEstimate error)
             throws VisADException
Returns the single value of this quantity corresponding to a numeric amount, a unit, and an error estimate. This is the most general factory method for creating scalar values.

Parameters:
amount - The numeric value.
unit - The unit of the numeric value. May be null.
error - The error estimate. May be null.
Returns:
The single value of this quantity corresponding to the input.
Throws:
VisADException - VisAD failure.

newRealTuple

public final RealTuple newRealTuple(double amount,
                                    Unit unit)
                             throws VisADException,
                                    RemoteException
Returns a single tuple of this quantity.

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

newRealTuple

public final RealTuple newRealTuple(double amount,
                                    Unit unit,
                                    CoordinateSystem coordSys)
                             throws VisADException,
                                    RemoteException
Returns a single tuple of this quantity.

Parameters:
amount - The numeric value.
unit - The unit of the numeric value. 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:
Quantity.newRealTuple(double[], Unit[], CoordinateSystem)

newRealTuple

public RealTuple newRealTuple(double amount,
                              Unit unit,
                              ErrorEstimate error,
                              CoordinateSystem coordSys)
                       throws VisADException,
                              RemoteException
Returns a single tuple of this quantity.

Parameters:
amount - The numeric value.
unit - The unit of the numeric value. May be null.
error - The error estimate. 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:
Quantity.newRealTuple(double[], Unit[] ErrorEstimate[], CoordinateSystem)

newRealTuple

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

Parameters:
value - The value.
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.
See Also:
Quantity.newRealTuple(Real[], CoordinateSystem)

newValue

public DataImpl newValue(double[] amounts,
                         Unit[] units,
                         ErrorEstimate[] errors,
                         CoordinateSystem coordSys)
                  throws VisADException
Returns the single value of this quantity corresponding to numeric amounts, units, error estimates, and coordinate system.

Overrides:
newValue in class Quantity
Parameters:
amounts - The numerical amounts. Must have only a single element.
units - The units of the amounts. May be null; otherwise, must have only a single element, which is the unit for the respective numerical amount (and may, itself, be null).
errors - The uncertainties of the numerical amounts. May be null; otherwise, must have only a single element, which is the uncertainty of the numerical amount (and may, itself, be null).
coordSys - The coordinate system transformation. Must be null.
Returns:
The single value corresponding to the input. The class of the object will be Real.
Throws:
VisADException - VisAD failure.

isCompatible

public boolean isCompatible(MathType type)
                     throws VisADException
Indicates if a VisAD MathType is compatible with this instance. A RealType is compatible if its RealType.equalsExceptNameButUnits(visad.MathType) method returns true when given the return value of getRealType() and if this quantity has no coordinate system transformation. A RealTupleType is compatible if its RealTupleType.equalsExceptNameButUnits(visad.MathType) method returns true when given the return value of Quantity.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.

Overrides:
isCompatible in class Quantity
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.