Package ucar.visad
Class ScalarQuantity
java.lang.Object
ucar.visad.Quantity
ucar.visad.ScalarQuantity
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
ConstructorsModifierConstructorDescriptionprotected
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.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. -
Method Summary
Modifier and TypeMethodDescriptionfinal MathType
Returns the naturalMathType
of this quantity.final RealType
Returns the VisAD RealType of this quantity.boolean
isCompatible
(MathType type) Indicates if a VisAD MathType is compatible with this instance.final Real
newReal
(double amount) Returns the single value of this quantity corresponding to a numeric amount in the default unit.final Real
Returns the single value of this quantity corresponding to a numeric amount and a unit.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.final RealTuple
newRealTuple
(double amount, Unit unit) Returns a single tuple of this quantity.final RealTuple
newRealTuple
(double amount, Unit unit, CoordinateSystem coordSys) Returns a single tuple of this quantity.newRealTuple
(double amount, Unit unit, ErrorEstimate error, CoordinateSystem coordSys) Returns a single tuple of this quantity.newRealTuple
(Real value, CoordinateSystem coordSys) Returns a single tuple of this quantity.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
-
Constructor Details
-
ScalarQuantity
Constructs from a name and a default unit. The default representational set will beFloatSet
.- 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
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 ofvisad.DoubleSet
,visad.FloatSet
,visad.Integer1DSet
, ornull
. Ifnull
, then the default isvisad.FloatSet
.- Throws:
VisADException
- VisAD failure.- See Also:
-
ScalarQuantity
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 ofvisad.DoubleSet
,visad.FloatSet
,visad.Integer1DSet
, ornull
. Ifnull
, then the default isvisad.FloatSet
.attrMask
- The attribute mask:0
orINTERVAL
.- Throws:
VisADException
- VisAD failure.- See Also:
-
ScalarQuantity
Constructs from an existing RealType. The coordinate system transformation will benull
.- Parameters:
realType
- The existing RealType.- Throws:
TypeException
- if an instance cannot be created.VisADException
- if a core VisAD failure occurs.- See Also:
-
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 benull
.- 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
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 Details
-
getRealType
Returns the VisAD RealType of this quantity.- Returns:
- The VisAD RealType of this quantity.
-
getMathType
Returns the naturalMathType
of this quantity.- Overrides:
getMathType
in classQuantity
- Returns:
- The natural
MathType
of this quantity. The class of the object isRealType
.
-
newReal
Returns the single value of this quantity corresponding to a numeric amount in the default unit. The error estimate will benull
.- Parameters:
amount
- The numeric value.- Returns:
- The single value of this quantity corresponding to the input.
- Throws:
VisADException
- VisAD failure.- See Also:
-
newReal
Returns the single value of this quantity corresponding to a numeric amount and a unit. The error estimate will benull
.- Parameters:
amount
- The numeric value.unit
- The unit of the numeric value. May benull
.- Returns:
- The single value of this quantity corresponding to the input.
- Throws:
VisADException
- VisAD failure.- See Also:
-
newReal
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 benull
.error
- The error estimate. May benull
.- 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 benull
.- Returns:
- The single tuple corresponding to the input.
- Throws:
VisADException
- VisAD failure.RemoteException
- Java RMI failure.- See Also:
-
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 benull
.coordSys
- The coordinate system transformation for this particular tuple. Must be compatible with the default coordinate system transformation. May benull
.- Returns:
- The single tuple corresponding to the input.
- Throws:
VisADException
- VisAD failure.RemoteException
- Java RMI failure.- See Also:
-
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 benull
.error
- The error estimate. May benull
.coordSys
- The coordinate system transformation for this particular tuple. Must be compatible with the default coordinate system transformation. May benull
.- Returns:
- The single tuple corresponding to the input.
- Throws:
VisADException
- VisAD failure.RemoteException
- Java RMI failure.
-
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 benull
, 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:
-
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 classQuantity
- Parameters:
amounts
- The numerical amounts. Must have only a single element.units
- The units of the amounts. May benull
; otherwise, must have only a single element, which is the unit for the respective numerical amount (and may, itself, benull
).errors
- The uncertainties of the numerical amounts. May benull
; otherwise, must have only a single element, which is the uncertainty of the numerical amount (and may, itself, benull
).coordSys
- The coordinate system transformation. Must benull
.- Returns:
- The single value corresponding to the input.
The class of the object will be
Real
. - Throws:
VisADException
- VisAD failure.
-
isCompatible
Indicates if a VisAD MathType is compatible with this instance. A RealType is compatible if itsRealType.equalsExceptNameButUnits(visad.MathType)
method returns true when given the return value ofgetRealType()
and if this quantity has no coordinate system transformation. A RealTupleType is compatible if itsRealTupleType.equalsExceptNameButUnits(visad.MathType)
method returns true when given the return value ofQuantity.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 classQuantity
- 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.
-