Package hec.model
Class PairedValues
java.lang.Object
hec.model.PairedValues
- All Implemented Interfaces:
AsciiSerializable,FieldAccessor,Serializable,Cloneable
Represents an array of paired values. Parsing functions are provided to
read from and write data to strings. Functions are provided to interpolate
data between intervals.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPair(double xval, double yval) add a pair of values to the end of the databooleanget whether the X interpolation can be performedbooleanget whether the Y interpolation can be performedvoidclears all values from the arrayclone()Implementation of the public clone interfaceintfindInterval(double xval) find interval for interpolationintfindInterval(double[] array, double val) find interval for interpolationget the Y data curve labelgetData()get the data as a String.get a clone of the Vector ofValuePairsdoublegetDatum()get the data's DatumvoidgetDatum(ParamDouble pd) get the data's Data returned in the ParamDoubleget the DSS filename for the dataget the DSS Identifier for the data the DSSIdentifier holds the DSS file and pathget the DSS pathname for the datagetFieldObject(Field fld) This method allows access to java.lang.reflect.Field objects within the implementing class.intReturns the current interpolation type that is set.get the last ValuePairdoublegetMaxY()get the maximum Y valuedoublegetMinY()get the minimum Y valuedoubleget the Data's offsetintget the number of data pairs.get the data in a PairedDataContainerint[]Returns an array the parameter ID's in the order of {XPARAMID, YPARAMID}.intget the Parameter ID (i.e.get the Parameter units String (i.e.get the Parameter units String (i.e.intset the Parameter ID (i.e.get the Parameter units String (i.e.get the Parameter units String (i.e.doublegetShift()get the Data's shiftintget the Unit System for the values.getValuePair(int i) get the data pair at index idouble[]get the X values arraydoublegetXValue(double yval) get a single X value for a given Y value, value returned can be interpolateddoublegetXValue(int i) get a single X value at index i return the X value at index i or RMAConst.UNDEF_DOUBLE if i is outside the range of the datavoidgetXValue(int i, ParamDouble pd) Gets an x value at location i.double[]get the Y values arraydoublegetYValue(double xval) get a single Y value for a given X value, value returned can be interpolateddoublegetYValue(int i) get a single Y value at index i return the Y value at index i or RMAConst.UNDEF_DOUBLE if i is outside the range of the datavoidgetYValue(int i, ParamDouble pd) Gets an y value at location i.booleanreturn whether the Y data has a curve label setinit()doubleinterpolate(double xval) interpolate a value at the given time based on the interpolation methoddoubleinterpolateStepValue(double xval) step interpolation return Y value for the given X valuedoubleinterpolateValue(double xval) linear interpolation, return y for given x valuedoubleinterpolateValueCubicSpline(double xval) cubic spline interpolation return Y value for the given X valuedoubleinterpolateY(double yval) interpolate a value at the given time based on the interpolation methodbooleanisXValueOutOfRange(double xval) check to see if the X value is out of rangebooleanisYValueOutOfRange(double yval) check to see if the Y value is out of rangeintparseString(String param) voidremovePair(int i) Removes a value pair at the given indexvoidsetCurveLabel(String curveLabel) curveLabel for y-ordinatebooleanTransfer data from the PairedDataContainer into the PairedValuesExtintset the data from a String.voidsetDatum(double datum) set the data's DatumvoidsetDatum(ParamDouble pd) set the data's Data returned from the ParamDoublevoidsetDssIdentifer(DSSIdentifier dssId) set the DSS Identifier for the data the DSSIdentifier holds the DSS file and pathvoidsetDssPathName(String pathName) set the DSS filename for the databooleansetFieldObject(Field fld, Object fobj) This allows access to fields withing the implementing object to set there data.voidsetInterpolationType(int type) Sets the interpolation type used when doing linear interpolations.voidsetOffset(double offset) set the Data's offsetvoidsetParamXId(int paramId) set the Parameter ID (i.e.voidsetParamYId(int paramId) set the Parameter ID (i.e.voidsetShift(double shift) set the Data's shiftvoidsetUnitSystem(int us) set the Unit system for the data.intsize()Returns the number of value paires contained in this object.toString()toTableForm(int precision) returns the data in table form
-
Field Details
-
INTERP_LINEAR
- See Also:
-
INTERP_CUBIC
- See Also:
-
INTERP_STEP
- See Also:
-
INTERP_LINEAR_ID
public static final int INTERP_LINEAR_ID- See Also:
-
INTERP_CUBIC_ID
public static final int INTERP_CUBIC_ID- See Also:
-
INTERP_STEP_ID
public static final int INTERP_STEP_ID- See Also:
-
INTERP_STRINGS
-
-
Constructor Details
-
PairedValues
public PairedValues()
-
-
Method Details
-
getMinY
public double getMinY()get the minimum Y value- Returns:
- the minimum Y value
-
getMaxY
public double getMaxY()get the maximum Y value- Returns:
- the maximum Y value
-
getUnitSystem
public int getUnitSystem()get the Unit System for the values.- Returns:
- the unit system
-
getDssPathName
get the DSS pathname for the data- Returns:
- the DSS pathname or null if there isn't one
-
getDssFileName
get the DSS filename for the data- Returns:
- the DSS filename or null if there isn't one
-
setDssPathName
set the DSS filename for the data- Parameters:
pathName- the new DSS pathname
-
getDssIdentifer
get the DSS Identifier for the data the DSSIdentifier holds the DSS file and path- Returns:
- the DSS Identifier
-
setDssIdentifer
set the DSS Identifier for the data the DSSIdentifier holds the DSS file and path- Parameters:
dssId- the new DSS Identifier
-
getParamXUnitsString
get the Parameter units String (i.e. cfs) for X data -
getParamYUnitsString
get the Parameter units String (i.e. cfs) for Y data -
getParamXString
get the Parameter units String (i.e. Flow) for X data -
getParamYString
get the Parameter units String (i.e. Flow) for Y data -
getParametersIds
public int[] getParametersIds()Returns an array the parameter ID's in the order of {XPARAMID, YPARAMID}. If they are not definge they will have the value RMAConst.UNDEF_INT; -
setUnitSystem
public void setUnitSystem(int us) set the Unit system for the data. changing the unit system doesn't not convert the data- Parameters:
us- the new unit system. Units.SI_ID or Units.ENGLISH_ID- See Also:
-
setParamXId
public void setParamXId(int paramId) set the Parameter ID (i.e. Parameter.PARAMID_FLOW) for X data- Parameters:
paramId- the Parameter Units ID for the X Data- See Also:
-
setParamYId
public void setParamYId(int paramId) set the Parameter ID (i.e. Parameter.PARAMID_FLOW) for Y data- Parameters:
paramId- the Parameter Units ID for the Y Data- See Also:
-
getParamXId
public int getParamXId()get the Parameter ID (i.e. Parameter.PARAMID_FLOW) for X data -
getParamYId
public int getParamYId()set the Parameter ID (i.e. Parameter.PARAMID_FLOW) for Y data- See Also:
-
getXValue
Gets an x value at location i. Fills the ParamDouble with the current unit system param type and the double value. if i outside the data range RmaConst.UNDEF_DOUBLE is returned in the ParamDouble; -
getYValue
Gets an y value at location i. Fills the ParamDouble with the current unit system param type and the double value. if i outside the data range RmaConst.UNDEF_DOUBLE is returned in the ParamDouble; -
getXValue
public double getXValue(int i) get a single X value at index i return the X value at index i or RMAConst.UNDEF_DOUBLE if i is outside the range of the data -
getYValue
public double getYValue(int i) get a single Y value at index i return the Y value at index i or RMAConst.UNDEF_DOUBLE if i is outside the range of the data -
getXValue
public double getXValue(double yval) get a single X value for a given Y value, value returned can be interpolated- Returns:
- the X value for the given Y value
-
getYValue
public double getYValue(double xval) get a single Y value for a given X value, value returned can be interpolated- Returns:
- the Y value for the given X value
-
interpolate
public double interpolate(double xval) interpolate a value at the given time based on the interpolation method -
interpolateY
public double interpolateY(double yval) interpolate a value at the given time based on the interpolation method -
interpolateValue
public double interpolateValue(double xval) linear interpolation, return y for given x value- Parameters:
xval- the X Value to get the Y value for- Returns:
- the Y value for the Xvalue
-
interpolateStepValue
public double interpolateStepValue(double xval) step interpolation return Y value for the given X value- Parameters:
xval- the X value to get the Y value for- Returns:
- the Y value for the X value
-
interpolateValueCubicSpline
public double interpolateValueCubicSpline(double xval) cubic spline interpolation return Y value for the given X value- Parameters:
xval- the X value to get the Y value for- Returns:
- the Y value for the X value
-
isXValueOutOfRange
public boolean isXValueOutOfRange(double xval) check to see if the X value is out of range- Parameters:
xval- the X value to check- Returns:
- true if the X value is out of range
-
isYValueOutOfRange
public boolean isYValueOutOfRange(double yval) check to see if the Y value is out of range- Parameters:
yval- the Y value to check- Returns:
- true if the Y value is out of range
-
findInterval
public int findInterval(double xval) find interval for interpolation -
findInterval
public int findInterval(double[] array, double val) find interval for interpolation -
parseString
-
setInterpolationType
public void setInterpolationType(int type) Sets the interpolation type used when doing linear interpolations. Valid types are INTERP_LINEAR_ID, INTERP_STEP_ID, INTERP_CUBIC_ID- Parameters:
type- one of INTERP_LINEAR_ID, INTERP_STEP_ID, INTERP_CUBIC_ID
-
getInterpolationType
public int getInterpolationType()Returns the current interpolation type that is set. Returns either INTERP_LINEAR_ID, INTERP_STEP_ID, INTERP_CUBIC_ID. The default type is INTERP_LINEARD_ID.- Returns:
- one of INTERP_LINEAR_ID, INTERP_STEP_ID, INTERP_CUBIC_ID
-
size
public int size()Returns the number of value paires contained in this object.- Returns:
- the number of pairs
-
clearValues
public void clearValues()clears all values from the array -
getPairCount
public int getPairCount()get the number of data pairs.- Returns:
- the number of pairs
-
getValuePair
get the data pair at index i- Parameters:
i- the index to get the data pair at- Returns:
- the data pair or null
-
getLastValuePair
get the last ValuePair- Returns:
- the last ValuePair or null
-
removePair
public void removePair(int i) Removes a value pair at the given index- Parameters:
i- the index to remove
-
toString
-
toTableForm
returns the data in table form- Parameters:
precision- the precision for the numbers- Returns:
- the data in table for in a String
-
addPair
public void addPair(double xval, double yval) add a pair of values to the end of the data- Parameters:
xval- the X valueyval- the Y value
-
getDataVector
get a clone of the Vector ofValuePairs- Returns:
- the Vector of
ValuePairs
-
clone
Implementation of the public clone interface -
init
-
getXArray
public double[] getXArray()get the X values array- Returns:
- the X values array
-
getYArray
public double[] getYArray()get the Y values array- Returns:
- the Y values array
-
canInterpX
public boolean canInterpX()get whether the X interpolation can be performed- Returns:
- true if it can interpolate X values
-
canInterpY
public boolean canInterpY()get whether the Y interpolation can be performed- Returns:
- true if it can interpolate Y values
-
setData
Transfer data from the PairedDataContainer into the PairedValuesExt- Parameters:
pdc-- Returns:
-
setCurveLabel
curveLabel for y-ordinate- Parameters:
curveLabel- the new curve label for the Y data
-
getCurveLabel
get the Y data curve label- Returns:
- the Y data Curve label
-
hasCurveLabel
public boolean hasCurveLabel()return whether the Y data has a curve label set- Returns:
- true if the Y Data has a curve label set
-
setDatum
public void setDatum(double datum) set the data's Datum- Parameters:
datum- the new datum value
-
getDatum
public double getDatum()get the data's Datum- Returns:
- the Data's Datum or Heclib.UNDEFINED_DOUBLE if its not set
-
getDatum
get the data's Data returned in the ParamDouble- Parameters:
pd- the ParamDouble to set the Datum in
-
setDatum
set the data's Data returned from the ParamDouble- Parameters:
pd- the ParamDouble to set the Datum from
-
setShift
public void setShift(double shift) set the Data's shift- Parameters:
shift- the new shift
-
getShift
public double getShift()get the Data's shift- Returns:
- the data's shift
-
setOffset
public void setOffset(double offset) set the Data's offset- Parameters:
offset- the new offset
-
getOffset
public double getOffset()get the Data's offset- Returns:
- the data's offset
-
getFieldObject
Description copied from interface:FieldAccessorThis method allows access to java.lang.reflect.Field objects within the implementing class.- Specified by:
getFieldObjectin interfaceFieldAccessor- Parameters:
fld- The field to get.- Returns:
- The data object that is stored in the given field
-
setFieldObject
Description copied from interface:FieldAccessorThis allows access to fields withing the implementing object to set there data.- Specified by:
setFieldObjectin interfaceFieldAccessor- Parameters:
fld- The java field object representing the member field to be setfobj- The data to set in that field- Returns:
- returns true if successful
-
getData
get the data as a String. comma separates the pair X/Y values, semicolon separates pairs- Returns:
- the data as a String
-
setData
set the data from a String. comma separates the pair X/Y values, semicolon separates pairs- Parameters:
values- the data in the form of a String- Returns:
- the number of pairs parsed from the String
-
getPairedDataContainer
get the data in a PairedDataContainer- Returns:
- the PairedDataContainer
-