Package hec.model

Class PairedValues

java.lang.Object
hec.model.PairedValues
All Implemented Interfaces:
AsciiSerializable, FieldAccessor, Serializable, Cloneable

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

  • 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

      public String getDssPathName()
      get the DSS pathname for the data
      Returns:
      the DSS pathname or null if there isn't one
    • getDssFileName

      public String getDssFileName()
      get the DSS filename for the data
      Returns:
      the DSS filename or null if there isn't one
    • setDssPathName

      public void setDssPathName(String pathName)
      set the DSS filename for the data
      Parameters:
      pathName - the new DSS pathname
    • getDssIdentifer

      public DSSIdentifier getDssIdentifer()
      get the DSS Identifier for the data the DSSIdentifier holds the DSS file and path
      Returns:
      the DSS Identifier
    • setDssIdentifer

      public void setDssIdentifer(DSSIdentifier dssId)
      set the DSS Identifier for the data the DSSIdentifier holds the DSS file and path
      Parameters:
      dssId - the new DSS Identifier
    • getParamXUnitsString

      public String getParamXUnitsString()
      get the Parameter units String (i.e. cfs) for X data
    • getParamYUnitsString

      public String getParamYUnitsString()
      get the Parameter units String (i.e. cfs) for Y data
    • getParamXString

      public String getParamXString()
      get the Parameter units String (i.e. Flow) for X data
    • getParamYString

      public String 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
      See Also:
    • getParamYId

      public int getParamYId()
      set the Parameter ID (i.e. Parameter.PARAMID_FLOW) for Y data
      See Also:
    • 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. if i outside the data range RmaConst.UNDEF_DOUBLE is returned in the ParamDouble;
    • getYValue

      public void getYValue(int i, ParamDouble pd)
      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

      public int parseString(String param)
    • 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

      public ValuePair getValuePair(int i)
      get the data pair at index i
      Parameters:
      i - the index to get the data pair at
      Returns:
      the data pair or null
    • getLastValuePair

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

      public String toString()
      Overrides:
      toString in class Object
    • toTableForm

      public String toTableForm(int precision)
      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 value
      yval - the Y value
    • getDataVector

      public Vector getDataVector()
      get a clone of the Vector of ValuePairs
      Returns:
      the Vector of ValuePairs
    • clone

      public Object clone()
      Implementation of the public clone interface
      Overrides:
      clone in class Object
    • init

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

      public boolean setData(PairedDataContainer pdc)
      Transfer data from the PairedDataContainer into the PairedValuesExt
      Parameters:
      pdc -
      Returns:
    • setCurveLabel

      public void setCurveLabel(String curveLabel)
      curveLabel for y-ordinate
      Parameters:
      curveLabel - the new curve label for the Y data
    • getCurveLabel

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

      public void getDatum(ParamDouble pd)
      get the data's Data returned in the ParamDouble
      Parameters:
      pd - the ParamDouble to set the Datum in
    • setDatum

      public void setDatum(ParamDouble pd)
      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

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      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)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      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
    • getData

      public String getData()
      get the data as a String. comma separates the pair X/Y values, semicolon separates pairs
      Returns:
      the data as a String
    • setData

      public int setData(String values)
      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

      public PairedDataContainer getPairedDataContainer()
      get the data in a PairedDataContainer
      Returns:
      the PairedDataContainer