Package hec.model
Class PairedValuesExt
java.lang.Object
hec.model.PairedValuesExt
- All Implemented Interfaces:
AsciiSerializable
,FieldAccessor
,Serializable
,Cloneable
- Direct Known Subclasses:
SeasonalPairedValues
Represents an array of paired values with multiple Y data. 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 TypeMethodDescriptionvoid
addPair
(double xval, double yval) add an X and Y pairvoid
addPair
(double xval, double[] yval) add an X value and Y valuesboolean
return whether X interpolation can take place.void
clears all valuesclone()
Implementation of the public clone interfaceint
findInterval
(double xval) find interval for interpolationint
findInterval
(double[] array, double val) find interval for interpolationgetCurve
(int icurve) return a PairedValues with y data from icurveString[]
get the curve labelsdouble[]
get the curve labels as double valuesgetData()
get the data VectorgetFieldObject
(Field fld) required AsciiSerialized method.int
return the interpolation typedouble
gets the largest value greater than zero from the y arraysint
get the number of Y curvesint
getNumY()
get the number of Y valuesCopy values, units, labels and parameters into a PairedDataContainerint
getParametersId
(int icol) get the parameter id for either X or Y valuesint[]
Returns an array the parameter ID's in the order of {XPARAMID, YPARAMID}.int
get the X parameter id.get the parameter string (i.e.get the units string for the X parameter.int
get the Y parameter id.get the parameter string (i.e.get the units string for the Y parameter.int
parameter id for curves parameterget the parameter string for the Z parameter.get the units string for the Z parameter.int
Returns the unit system that this data is defined in or hec.data.Units.UNDEF_ID if no unit system has been setdouble[]
get an array of the X Valuesdouble
getXValue
(double yval) get a single x value - given yvaluedouble
getXValue
(int i) get a single x valuevoid
getXValue
(int i, ParamDouble pd) Gets an x value at location i.double[]
get an array of Y values from the first Y curve implemented asgetYArray(0)
double[]
getYArray
(int iset) get an array of Y values from the Y curve iset.double[][]
getYData()
get the Y data arraydouble
getYValue
(double xval) get a single y value - given xvaluedouble
getYValue
(double xval, int iset) get a single y value - given xvaluedouble
getYValue
(int i) get the first y value in curve idouble
getYValue
(int i, int iset) get a single y valuevoid
getYValue
(int i, int iset, ParamDouble pd) get the iset Y value in curve i.void
getYValue
(int i, ParamDouble pd) Gets first Y value at location i.boolean
return whether the curve labels have been set.void
init()
initialize the PairedValueExt object.void
insertCurve
(int index, double value) Inserts a curve into the array of curves, where each point on the curve has the same valuedouble
interpolate
(double xval) interpolate a value at the given time based on the default interpolation methoddouble
interpolate
(double xvalue, double zvalue) 2-variable interpolationdouble
interpolate
(double xval, int iset) interpolate a value at the given time based on the default interpolation methoddouble
interpolateStepValue
(double xval) step interpolation, return Y for the given X value implemented asinterpolate(xval, 0)
double
interpolateStepValue
(double xval, int iset) step interpolation, return Y for the given X valuedouble
interpolateValue
(double xval) linear interpolation, return y for given x value implemented asinterpolateValue(xval,0)
double
interpolateValue
(double xval, int iset) double
interpolateValueCubicSpline
(double xval) cubic spline interpolation.double
interpolateValueCubicSpline
(double xval, int iset) cubic spline interpolation.double
interpolateY
(double yval) interpolate a value at the given time based on the default interpolation method implemented asinterpolateY(yval,0)
double
interpolateY
(double yvalue, double zvalue) 2-variable interpolation on the Y variabledouble
interpolateY
(double yval, int iset) interpolate a value at the given time based on the default interpolation methodboolean
isXValueOutOfRange
(double xval) boolean
isZValueOutOfRange
(double zval) void
removeCurve
(int index) Removes an entire curve from the set of curves located atindex void
removePair
(int i) Removes a value pair at the given indexvoid
setArrays
(double[][] values) fill the X and Y arrays with values the array is expected to have the form
[x1][y1]
[x2][y2]
[x3][y3]
[x4][y4]
[x5][y5]
or
[x1][y11][y12]...
the Y arrays are expected to all be the same length.
[x2][y21][y22]...
[x3][y31][y32]...
[x4][y41][y42]...
[x5][y51][y52]...
void
setArrays
(double[] xarray, double[] yarray) fill the X and Y arrays with values.void
setArrays
(double[] xarray, double[][] yarray) fill the X and Y arrays with data.void
setCurveLabels
(String[] curveLabels) set the curve labelsboolean
Transfer data from the PairedDataContainer into the PairedValuesExtint
void
setDssIdentifier
(DSSIdentifier dssId) set the DSSIdentifier.boolean
setFieldObject
(Field fld, Object fobj) required AsciiSerialized method.void
setInterpolationType
(int type) set the interpolation type to use.void
setNumY
(int n) void
setParamXId
(int paramId) set the X parameter ID.void
setParamYId
(int paramId) set the Y parameter ID.void
setParamZId
(int paramId) set the curves (Z) parameter ID.void
setUnitSystem
(int us) set the unit system.int
size()
Returns the number of data points in the listtoString()
return the String representation.toTableForm
(int precision)
-
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
-
PairedValuesExt
public PairedValuesExt()create a new PairedValuesExt
-
-
Method Details
-
getNumY
public int getNumY()get the number of Y values- Returns:
- the number of Y values
-
setNumY
public void setNumY(int n) -
getDssIdentifier
-
setDssIdentifier
set the DSSIdentifier. This is used when the containing object is AsciiSerialized so that the PairedValues gets written to DSS.- Parameters:
dssId
-
-
getUnitSystem
public int getUnitSystem()Returns the unit system that this data is defined in or hec.data.Units.UNDEF_ID if no unit system has been set- Returns:
- the unit system one of
hec.data.Units.SI_ID
,hec.data.Units.ENGLISH_ID
or if not sethec.data.Units.UNDEF_ID
-
getParametersId
public int getParametersId(int icol) get the parameter id for either X or Y values- Parameters:
icol
- 0 for X parameter Id, anything else for Y parameter id- Returns:
- the parameter id
-
getParamXUnitsString
get the units string for the X parameter. Requires that the unit system and parameter id have already been set.- Returns:
- the X unit system
-
getParamYUnitsString
get the units string for the Y parameter. Requires that the unit system and parameter id have already been set.- Returns:
- the Y unit system
-
getParamXString
get the parameter string (i.e. ft ) for the X parameter. Requires that the parameters have already been set.- Returns:
- the X parameter
-
getParamYString
get the parameter string (i.e. cfs) for the Y parameter. Requires that the parameters have already been set.- Returns:
- the Y parameter
-
getParametersIds
public int[] getParametersIds()Returns an array the parameter ID's in the order of {XPARAMID, YPARAMID}. If they are not defined they will have the value RMAConst.UNDEF_INT;- Returns:
- the parameter ids
-
setUnitSystem
public void setUnitSystem(int us) set the unit system. can be set by getting the unit system from an object that has the unit system set, usually by calling getUnitSystem() or by passing in one ofhec.data.Units.SI_ID
orhec.data.Units.ENGLISH_ID
the data is not converted on a change of unit system- Parameters:
us
- one ofhec.data.Units.SI_ID
orhec.data.Units.ENGLISH_ID
-
setParamXId
public void setParamXId(int paramId) set the X parameter ID. The Parameter IDs come from thehec.data.Parameter
class. So the parameter for elevation ishec.data.Parameter.PARAMID_ELEV
- Parameters:
paramId
- the X parameter id.
-
setParamYId
public void setParamYId(int paramId) set the Y parameter ID. The Parameter IDs come from thehec.data.Parameter
class. So the parameter for flow ishec.data.Parameter.PARAMID_FLOW
- Parameters:
paramId
- the Y parameter id.
-
getParamXId
public int getParamXId()get the X parameter id.- Returns:
- the X parameter id.
- See Also:
-
getParamYId
public int getParamYId()get the Y parameter id.- Returns:
- the Y parameter id.
- See Also:
-
getParamZId
public int getParamZId()parameter id for curves parameter- Returns:
- the curves (Z) parameter
- See Also:
-
setParamZId
public void setParamZId(int paramId) set the curves (Z) parameter ID. The Parameter IDs come from thehec.data.Parameter
class. So the parameter for flow ishec.data.Parameter.PARAMID_FLOW
- Parameters:
paramId
- the Z parameter id.
-
getParamZString
get the parameter string for the Z parameter. Requires that the parameters have already been set.- Returns:
- the Z parameter
-
getNumberCurves
public int getNumberCurves()get the number of Y curves- Returns:
- the number of Y curves
-
getParamZUnitsString
get the units string for the Z parameter. Requires that the unit system and parameter id have already been set.- Returns:
- the Z unit system
-
removeCurve
public void removeCurve(int index) Removes an entire curve from the set of curves located atindex - Parameters:
index
- the curve index to remove
-
insertCurve
public void insertCurve(int index, double value) Inserts a curve into the array of curves, where each point on the curve has the same value- Parameters:
index
- the index to insert the curve atvalue
- the value to insert into each curve
-
getCurve
return a PairedValues with y data from icurve- Parameters:
icurve
- the curve number to return data for
-
getXValue
Gets an x value at location i. Fills the ParamDouble with the current unit system param type and the double value.- Parameters:
i
- the X indexpd
- the ParamDouble to fill data into. Can't be null
-
getYValue
Gets first Y value at location i. Fills the ParamDouble with the current unit system param type and the double value.- Parameters:
i
- the first Y value in the curve ipd
- the ParamDouble to fill data into. Can't be null
-
getYValue
get the iset Y value in curve i. Fills the ParamDouble with the current unit system, param type and the double value- Parameters:
i
-iset
-pd
- the ParamDouble to fill data into. Can't be null.
-
getXValue
public double getXValue(int i) get a single x value- Parameters:
i
- the X index to get the value for- Returns:
- the X value at index i. If the index is invalid RMAConst.UNDEF_DOUBLE
-
getYValue
public double getYValue(int i) get the first y value in curve i- Parameters:
i
- the- Returns:
- first Y value in curve i
-
getYValue
public double getYValue(int i, int iset) get a single y value- Parameters:
i
-iset
-- Returns:
- a single Y value
-
getXValue
public double getXValue(double yval) get a single x value - given yvalue- Parameters:
yval
-- Returns:
- the interpolated X value for yval
-
getYValue
public double getYValue(double xval) get a single y value - given xvalue- Parameters:
xval
-- Returns:
-
getYValue
public double getYValue(double xval, int iset) get a single y value - given xvalue- Parameters:
xval
-iset
-- Returns:
- Y value
-
isXValueOutOfRange
public boolean isXValueOutOfRange(double xval) -
isZValueOutOfRange
public boolean isZValueOutOfRange(double zval) -
interpolate
public double interpolate(double xval) interpolate a value at the given time based on the default interpolation method- Parameters:
xval
-- Returns:
-
interpolate
public double interpolate(double xval, int iset) interpolate a value at the given time based on the default interpolation method- Parameters:
xval
-iset
-- Returns:
- the Y value
-
interpolate
public double interpolate(double xvalue, double zvalue) 2-variable interpolation- Parameters:
xvalue
-zvalue
-- Returns:
- the Y value
-
interpolateY
public double interpolateY(double yval) interpolate a value at the given time based on the default interpolation method implemented asinterpolateY(yval,0)
- Parameters:
yval
- the y value- Returns:
- the X value
- See Also:
-
interpolateY
public double interpolateY(double yval, int iset) interpolate a value at the given time based on the default interpolation method- Parameters:
yval
- the y valueiset
-- Returns:
- the X value
-
interpolateY
public double interpolateY(double yvalue, double zvalue) 2-variable interpolation on the Y variable- Parameters:
yvalue
-zvalue
-- Returns:
- the X value
-
interpolateValue
public double interpolateValue(double xval) linear interpolation, return y for given x value implemented asinterpolateValue(xval,0)
- Parameters:
xval
- the xvalue- Returns:
- the Y value
- See Also:
-
interpolateValue
public double interpolateValue(double xval, int iset) -
interpolateStepValue
public double interpolateStepValue(double xval) step interpolation, return Y for the given X value implemented asinterpolate(xval, 0)
- Parameters:
xval
- the x value- Returns:
- the y value
- See Also:
-
interpolateStepValue
public double interpolateStepValue(double xval, int iset) step interpolation, return Y for the given X value- Parameters:
xval
- the x valueiset
-- Returns:
- the y value
-
interpolateValueCubicSpline
public double interpolateValueCubicSpline(double xval) cubic spline interpolation. return Y for the given X value implemented asinterpolateValueCubicSpline(xval,0)
- Parameters:
xval
- the X value- Returns:
- the Y value
- See Also:
-
interpolateValueCubicSpline
public double interpolateValueCubicSpline(double xval, int iset) cubic spline interpolation. return Y for the given X value- Parameters:
xval
- the X valueiset
- the Y curve to use- Returns:
- the Y value
-
findInterval
public int findInterval(double xval) find interval for interpolation -
findInterval
public int findInterval(double[] array, double val) find interval for interpolation -
setInterpolationType
public void setInterpolationType(int type) set the interpolation type to use.- Parameters:
type
- one ofPairedValuesExt.INTERP_LINEAR_ID PairedValuesExt.INTERP_CUBIC_ID PairedValuesExt.INTERP_STEP_ID
-
getInterpolationType
public int getInterpolationType()return the interpolation type- Returns:
- the interpolation type. one of
PairedValuesExt.INTERP_LINEAR_ID PairedValuesExt.INTERP_CUBIC_ID PairedValuesExt.INTERP_STEP_ID
-
size
public int size()Returns the number of data points in the list- Returns:
- the number of points
-
clearValues
public void clearValues()clears all values -
removePair
public void removePair(int i) Removes a value pair at the given index- Parameters:
i
- the index to remove theValuePair
at
-
toString
return the String representation. -
toTableForm
-
debugString
-
addPair
public void addPair(double xval, double yval) add an X and Y pair- Parameters:
xval
- the X valueyval
- the Y value
-
addPair
public void addPair(double xval, double[] yval) add an X value and Y values- Parameters:
xval
- the X valueyval
- the Y values
-
setArrays
public void setArrays(double[] xarray, double[] yarray) fill the X and Y arrays with values. The number of values in the X array must match the number of values in the Y array- Parameters:
xarray
- the X arrayyarray
- the Y array
-
setArrays
public void setArrays(double[][] values) fill the X and Y arrays with values the array is expected to have the form
[x1][y1]
[x2][y2]
[x3][y3]
[x4][y4]
[x5][y5]
or
[x1][y11][y12]...
the Y arrays are expected to all be the same length.
[x2][y21][y22]...
[x3][y31][y32]...
[x4][y41][y42]...
[x5][y51][y52]...
This method will also take a Jython tuple defined like so:
stageFlowRating=(
[0, 10],
[38., 3500],
[38.5,4180],
[39.,4900],
[39.5,5670],
[40.,6480],
[40.5,7320],
[41.,8200],
[41.5,9120],
[42.,10100],
[42.5,11000],
[43.,12100],
[43.5,13100],
[44,14200],
[44.5,15300],
[45.,16400],
[45.5,17500],
[46.,18700],
[46.5,19900],
[47.,21200])- Parameters:
values
- the X and Y values
-
setArrays
public void setArrays(double[] xarray, double[][] yarray) fill the X and Y arrays with data. The X and Y data arrays have to be the same length.- Parameters:
xarray
- the X datayarray
- the Y data.
-
getDataVector
get the data Vector- Returns:
- the data vector
-
clone
Implementation of the public clone interface -
init
public void init()initialize the PairedValueExt object. validate that the data is valid and that the xvalues and yvalues are continuously increasing sequences -
getXArray
public double[] getXArray()get an array of the X Values- Returns:
- an array of X values
-
getYArray
public double[] getYArray()get an array of Y values from the first Y curve implemented asgetYArray(0)
- Returns:
- an array of Y values
-
getYArray
public double[] getYArray(int iset) get an array of Y values from the Y curve iset.- Parameters:
iset
- the Y curve number- Returns:
- an array of Y values from the Y curve iset.
-
getYData
public double[][] getYData()get the Y data array- Returns:
-
getLargestValue
public double getLargestValue()gets the largest value greater than zero from the y arrays- Returns:
-
canInterpX
public boolean canInterpX()return whether X interpolation can take place. If the X values are not a continuously increasing sequence, then X interpolation can't be done- Returns:
- true if X interpolation can take place
-
setData
Transfer data from the PairedDataContainer into the PairedValuesExt- Parameters:
pdc
- the PairedDataContainer to copy the data from- Returns:
- true
-
getPairedDataContainer
Copy values, units, labels and parameters into a PairedDataContainer- Returns:
- pdc a new PairedDataContainer with the data
-
getCurveLabels
get the curve labels- Returns:
- the curve labels
-
setCurveLabels
set the curve labels- Parameters:
curveLabels
- the new curve labels
-
hasCurveLabels
public boolean hasCurveLabels()return whether the curve labels have been set.- Returns:
- true if there are curve labels
-
getCurveLabelValues
public double[] getCurveLabelValues()get the curve labels as double values- Returns:
- an array of curve labels or null if they're not set
-
getData
-
setData
-
getFieldObject
required AsciiSerialized method. publicially callable only because of an implementation detail. Should not be called by anything other than the AsciiSerializer- Specified by:
getFieldObject
in interfaceFieldAccessor
- Parameters:
fld
- The field to get.- Returns:
- The data object that is stored in the given field
-
setFieldObject
required AsciiSerialized method. publicially callable only because of an implementation detail. Should not be called by anything other than the AsciiDeserializer- Specified by:
setFieldObject
in 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
-