visad
Class Real
- java.lang.Object
-
- visad.ThingImpl
-
- visad.DataImpl
-
- visad.Scalar
-
- visad.Real
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Data, RealIface, ScalarIface, Thing
- Direct Known Subclasses:
- DateTime
public class Real extends Scalar implements RealIface
Real is the class of VisAD scalar data for real numbers represented as double precision floating point values. Double.NaN is used to indicate missing values, because it has the appropriate arithmetic semantics. Real objects are immutable.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class visad.DataImpl
DataImpl.Syncher
-
-
Field Summary
-
Fields inherited from interface visad.Data
ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE
-
-
Constructor Summary
Constructors Constructor and Description Real(double value)Constructs a generic Real object.Real(double value, double error)Constructs a generic Real object.Real(RealType type)Constructs a Real object.Real(RealType type, double value)Constructs a Real object.Real(RealType type, double value, Unit u)Constructs a Real object.Real(RealType type, double value, Unit u, double error)Constructs a Real object.Real(RealType type, double value, Unit u, ErrorEstimate error)Constructs a Real object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description int__eq__(double other)int__eq__(Real other)int__ge__(double other)int__ge__(Real other)int__gt__(double other)Methods for Jython comparisons with doubles and other Realsint__gt__(Real other)int__le__(double other)int__le__(Real other)int__lt__(double other)int__lt__(Real other)int__ne__(double other)int__ne__(Real other)DataadjustSamplingError(Data error, int error_mode)return a Real that clones this, except its ErrorEstimate is adjusted for the sampling error in errorDatabinary(Data data, int op, MathType new_type, int sampling_mode, int error_mode)Pointwise binary operation between this and data.RealcloneButUnit(Unit u)clone this, but with a new UnitRealcloneButValue(double value)clone this, but with a new valueintcompareTo(java.lang.Object object)Compares this Real to another.DataShadowcomputeRanges(ShadowType type, DataShadow shadow)Recursive version of computeRanges(), called down through Data object tree.booleanequals(java.lang.Object obj)Indicates if this Real is semantically identical to an object.ErrorEstimategetError()Returns the uncertainty in the numeric value of this instance.UnitgetUnit()Returns the unit of this instance.doublegetValue()Get the value for this Real in the units of the data.doublegetValue(Unit unit_out)Get the value for this Real converted to unit_out.inthashCode()Returns the hash code of this Real.booleanisMissing()Check to see if the value of this Real is a NaN.java.lang.StringlongString(java.lang.String pre)static voidmain(java.lang.String[] args)run 'java visad.Real' to test the Real classjava.lang.StringtoString()java.lang.StringtoValueString()Gets a string that represents just the value portion of this Real -- but with full semantics (e.g.Dataunary(int op, MathType new_type, int sampling_mode, int error_mode)unary function on a Real; override some trig functions based on Unit; transcental functions destroy dimensionfull Unit-
Methods inherited from class visad.Scalar
addReference, clone, removeReference
-
Methods inherited from class visad.DataImpl
__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary
-
Methods inherited from interface visad.Data
abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary
-
Methods inherited from interface visad.Thing
addReference, removeReference
-
-
-
-
Constructor Detail
-
Real
public Real(RealType type, double value, Unit u, ErrorEstimate error) throws VisADException
Constructs a Real object. This is the most general constructor.- Parameters:
type- The type of the Real.value- The value of the Real. May beDouble.NaN.u- The unit of the Real. May benull. If non-nullandtype.isInterval()returns true, then the unit will actually beu.getAbsoluteUnit().error- Error estimate of the Real. May benull.- Throws:
UnitException- if the default unit of the type is inconvertible with the unit argument (i.e. ifUnit.canConvert(u, type.getDefaultUnit())returns false).VisADException- Couldn't create necessary VisAD object.
-
Real
public Real(RealType type, double value, Unit u, double error) throws VisADException
Constructs a Real object. The error estimate will be based on a numeric value.- Parameters:
type- The type of the Real.value- The value of the Real. May beDouble.NaN.u- The unit of the Real. May benull. If non-nullandtype.isInterval()returns true, then the unit will actually beu.getAbsoluteUnit().error- Value for constructing an error estimate for the Real in units ofu != null && type.isInterval() ? u.getAbsoluteUnit() : u.- Throws:
VisADException- Couldn't create necessary VisAD object.
-
Real
public Real(RealType type, double value, Unit u) throws VisADException
Constructs a Real object. The error estimate will benull.- Parameters:
type- The type of the Real.value- The value of the Real. May beDouble.NaN.u- The unit of the Real. May benull. If non-nullandtype.isInterval()returns true, then the unit will actually beu.getAbsoluteUnit().- Throws:
VisADException- Couldn't create necessary VisAD object.
-
Real
public Real(RealType type, double value)
Constructs a Real object. The unit of the Real will be the default unit of the RealType and the error estimate will benull.- Parameters:
type- The type of the Real.value- The value of the Real in units oftype.getDefaultUnit(). May beDouble.NaN.
-
Real
public Real(RealType type)
Constructs a Real object. The value will be missing, the unit of the Real will be the default unit of the RealType, and the error estimate will benull.- Parameters:
type- The type of the Real.
-
Real
public Real(double value, double error)Constructs a generic Real object. The RealType of the Real will beRealType.Generic, the unit of the Real will beRealType.Generic.getDefaultUnit(), and the error estimate will be based on a numeric value.- Parameters:
value- The value of the Real. May beDouble.NaN.error- Value for constructing an error estimate for the Real in units ofRealType.Generic.getDefaultUnit().
-
Real
public Real(double value)
Constructs a generic Real object. The RealType of the Real will beRealType.Generic, the unit of the Real will beRealType.Generic.getDefaultUnit(), and the error estimate will be 0.0.- Parameters:
value- The value of the Real. May beDouble.NaN.
-
-
Method Detail
-
getValue
public final double getValue()
Get the value for this Real in the units of the data.
-
__gt__
public int __gt__(double other)
Methods for Jython comparisons with doubles and other Reals- Returns:
- =0 for false, =1 for true
-
__lt__
public int __lt__(double other)
-
__ge__
public int __ge__(double other)
-
__le__
public int __le__(double other)
-
__ne__
public int __ne__(double other)
-
__eq__
public int __eq__(double other)
-
__gt__
public int __gt__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
__lt__
public int __lt__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
__ge__
public int __ge__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
__le__
public int __le__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
__eq__
public int __eq__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
__ne__
public int __ne__(Real other) throws VisADException, java.rmi.RemoteException
- Throws:
VisADExceptionjava.rmi.RemoteException
-
getValue
public final double getValue(Unit unit_out) throws VisADException
Get the value for this Real converted to unit_out.- Specified by:
getValuein interfaceRealIface- Parameters:
unit_out- unit for return value- Returns:
- value in unit_out units.
- Throws:
VisADException- if either the Real's Unit or the unit_out is null (but not both).
-
isMissing
public boolean isMissing()
Check to see if the value of this Real is a NaN.
-
binary
public Data binary(Data data, int op, MathType new_type, int sampling_mode, int error_mode) throws VisADException, java.rmi.RemoteException
Description copied from class:DataImplPointwise binary operation between this and data. Applies to Reals, Tuples (recursively to components), and to Field ranges (Field domains implicitly resampled if necessary). Does not apply to Field domains or Sets (regarded as domains of Fields wthout ranges). Data.ADD is only op defined for Text, interpreted as concatenate. MathTypes of this and data must match, or one may match the range of the other if it is a FunctionType.- Specified by:
binaryin interfaceData- Overrides:
binaryin classDataImpl- Parameters:
data- other Data operand for binary operationop- may be Data.ADD, Data.SUBTRACT, etc; these include all binary operations defined for Java primitive data typesnew_type- MathType of the resultsampling_mode- may be Data.NEAREST_NEIGHBOR or Data.WEIGHTED_AVERAGEerror_mode- may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;- Returns:
- result, with MathType = new_type
- Throws:
VisADException- a VisAD error occurredjava.rmi.RemoteException- an RMI error occurred
-
unary
public Data unary(int op, MathType new_type, int sampling_mode, int error_mode) throws VisADException
unary function on a Real; override some trig functions based on Unit; transcental functions destroy dimensionfull Unit- Specified by:
unaryin interfaceData- Overrides:
unaryin classDataImpl- Parameters:
op- may be Data.ABS, Data.ACOS, etc; these include all unary operations defined for Java primitive data typesnew_type- MathType of the resultsampling_mode- may be Data.NEAREST_NEIGHBOR or Data.WEIGHTED_AVERAGEerror_mode- may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;- Returns:
- result, with MathType = new_type
- Throws:
VisADException- a VisAD error occurred
-
computeRanges
public DataShadow computeRanges(ShadowType type, DataShadow shadow) throws VisADException, java.rmi.RemoteException
Description copied from interface:DataRecursive version of computeRanges(), called down through Data object tree.- Specified by:
computeRangesin interfaceData- Parameters:
type- ShadowType generated for MathType of thisshadow- DataShadow instance whose contained double[][] array and animation sampling Set are modified according to RealType values in this, and used as return value- Returns:
- DataShadow instance containing double[][] array of RealType ranges, and an animation sampling Set
- Throws:
VisADException- a VisAD error occurredjava.rmi.RemoteException- an RMI error occurred
-
getUnit
public Unit getUnit()
Description copied from interface:RealIfaceReturns the unit of this instance.
-
getError
public ErrorEstimate getError()
Description copied from interface:RealIfaceReturns the uncertainty in the numeric value of this instance.
-
adjustSamplingError
public Data adjustSamplingError(Data error, int error_mode) throws VisADException, java.rmi.RemoteException
return a Real that clones this, except its ErrorEstimate is adjusted for the sampling error in error- Specified by:
adjustSamplingErrorin interfaceData- Specified by:
adjustSamplingErrorin interfaceRealIface- Overrides:
adjustSamplingErrorin classDataImpl- Parameters:
error- The uncertainty by which to adjust the clone.error_mode- may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;- Returns:
- clone of this, except with ErrorEstimates set according to values in error
- Throws:
VisADException- a VisAD error occurredjava.rmi.RemoteException- an RMI error occurred
-
cloneButValue
public Real cloneButValue(double value) throws VisADException
clone this, but with a new value- Specified by:
cloneButValuein interfaceRealIface- Parameters:
value- The numeric value for the clone.- Returns:
- A clone of this nstance with the given numeric value.
- Throws:
VisADException- VisAD failure.
-
cloneButUnit
public Real cloneButUnit(Unit u) throws VisADException
clone this, but with a new Unit- Specified by:
cloneButUnitin interfaceRealIface- Parameters:
u- The unit for the clone.- Returns:
- A clone of this instance but with the given unit.
- Throws:
VisADException
-
toString
public java.lang.String toString()
-
toValueString
public java.lang.String toValueString()
Gets a string that represents just the value portion of this Real -- but with full semantics (e.g. numeric value and unit).- Specified by:
toValueStringin interfaceRealIface- Returns:
- A string representation of just the value portion of this Real.
-
longString
public java.lang.String longString(java.lang.String pre) throws VisADException- Specified by:
longStringin interfaceData- Overrides:
longStringin classDataImpl- Parameters:
pre- String added to start of each line- Returns:
- a longer String than returned by toString(), indented by pre (a string of blanks)
- Throws:
VisADException
-
compareTo
public int compareTo(java.lang.Object object)
Compares this Real to another.- Specified by:
compareToin interfacejava.lang.Comparable- Specified by:
compareToin interfaceRealIface- Parameters:
object- The other Real to compare against. It shall be a Real with a compatible (i.e. convertible) unit.- Returns:
- A negative integer, zero, or a positive integer
depending on whether this Real is considered
less than, equal to, or greater than the other
Real, respectively. If the values of the Real-s
in the default unit are equal, then the
ErrorEstimate.compareTo()method is used to break the tie.
-
equals
public boolean equals(java.lang.Object obj)
Indicates if this Real is semantically identical to an object.- Specified by:
equalsin interfaceScalarIface- Specified by:
equalsin classScalar- Parameters:
obj- The object.- Returns:
trueif and only if this Real is semantically identical to the object.
-
hashCode
public int hashCode()
Returns the hash code of this Real.
-
main
public static void main(java.lang.String[] args) throws VisADException, java.rmi.RemoteExceptionrun 'java visad.Real' to test the Real class- Throws:
VisADExceptionjava.rmi.RemoteException
-
-
DMelt 3.0 © DataMelt by jWork.ORG