Package hec.model

Class PairedValuesExt

java.lang.Object
hec.model.PairedValuesExt
All Implemented Interfaces:
AsciiSerializable, FieldAccessor, Serializable, Cloneable
Direct Known Subclasses:
SeasonalPairedValues

public class PairedValuesExt extends Object implements AsciiSerializable, Cloneable
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 Details

  • 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

      public DSSIdentifier getDssIdentifier()
    • setDssIdentifier

      public void setDssIdentifier(DSSIdentifier dssId)
      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 set hec.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

      public String 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

      public String 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

      public String 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

      public String 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 of hec.data.Units.SI_ID or hec.data.Units.ENGLISH_ID the data is not converted on a change of unit system
      Parameters:
      us - one of hec.data.Units.SI_ID or hec.data.Units.ENGLISH_ID
    • setParamXId

      public void setParamXId(int paramId)
      set the X parameter ID. The Parameter IDs come from the hec.data.Parameter class. So the parameter for elevation is hec.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 the hec.data.Parameter class. So the parameter for flow is hec.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 the hec.data.Parameter class. So the parameter for flow is hec.data.Parameter.PARAMID_FLOW
      Parameters:
      paramId - the Z parameter id.
    • getParamZString

      public String 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

      public String 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 at index
      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 at
      value - the value to insert into each curve
    • getCurve

      public PairedValues getCurve(int icurve)
      return a PairedValues with y data from icurve
      Parameters:
      icurve - the curve number to return data for
    • getXValue

      public void getXValue(int i, ParamDouble pd)
      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 index
      pd - the ParamDouble to fill data into. Can't be null
    • getYValue

      public void getYValue(int i, ParamDouble pd)
      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 i
      pd - the ParamDouble to fill data into. Can't be null
    • getYValue

      public void getYValue(int i, int iset, ParamDouble pd)
      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 as interpolateY(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 value
      iset -
      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 as interpolateValue(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 as interpolate(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 value
      iset -
      Returns:
      the y value
    • interpolateValueCubicSpline

      public double interpolateValueCubicSpline(double xval)
      cubic spline interpolation. return Y for the given X value implemented as interpolateValueCubicSpline(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 value
      iset - 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 of PairedValuesExt.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 the ValuePair at
    • toString

      public String toString()
      return the String representation.
      Overrides:
      toString in class Object
      Returns:
      the String representation
      See Also:
    • toTableForm

      public String toTableForm(int precision)
    • debugString

      public String debugString()
    • addPair

      public void addPair(double xval, double yval)
      add an X and Y pair
      Parameters:
      xval - the X value
      yval - the Y value
    • addPair

      public void addPair(double xval, double[] yval)
      add an X value and Y values
      Parameters:
      xval - the X value
      yval - 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 array
      yarray - 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]...
      [x2][y21][y22]...
      [x3][y31][y32]...
      [x4][y41][y42]...
      [x5][y51][y52]...
      the Y arrays are expected to all be the same length.

      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 data
      yarray - the Y data.
    • getDataVector

      public Vector<ValueSet> getDataVector()
      get the data Vector
      Returns:
      the data vector
    • clone

      public PairedValuesExt clone()
      Implementation of the public clone interface
      Overrides:
      clone in class Object
    • 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 as getYArray(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

      public boolean setData(PairedDataContainer pdc)
      Transfer data from the PairedDataContainer into the PairedValuesExt
      Parameters:
      pdc - the PairedDataContainer to copy the data from
      Returns:
      true
    • getPairedDataContainer

      public PairedDataContainer getPairedDataContainer()
      Copy values, units, labels and parameters into a PairedDataContainer
      Returns:
      pdc a new PairedDataContainer with the data
    • getCurveLabels

      public String[] getCurveLabels()
      get the curve labels
      Returns:
      the curve labels
    • setCurveLabels

      public void setCurveLabels(String[] curveLabels)
      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

      public String getData()
    • setData

      public int setData(String values)
    • getFieldObject

      public Object getFieldObject(Field fld)
      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 interface FieldAccessor
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      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 interface FieldAccessor
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful