Package hec.model

Class SeasonalRecordExt

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

public class SeasonalRecordExt extends Object implements AsciiSerializable, Cloneable
Contains two or more SeasonalRecord(s). Provides interpolation between curves (each a SeasonalRecord) and time. representing seasonal variation of a value. Methods include string I/O and interpolation functions.
See Also:
  • Constructor Details

    • SeasonalRecordExt

      public SeasonalRecordExt()
      create a new SeasonalRecordExt
  • Method Details

    • setParameterId

      public void setParameterId(int parameterId)
      Sets the parameter ID for the double values in this record. All double values are represented by this string.
      Parameters:
      parameterId - the parameter id. for flow the parameter would be hec.data.Parameter.PARAMID_FLOW
      See Also:
    • getParameterId

      public int getParameterId()
      Returns the parameter id for the "double" data values.
      Returns:
      the parameter id.
      See Also:
    • 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
    • setGmtOffset

      public void setGmtOffset(int offset)
      set the offset from GMT
      Parameters:
      offset - the GMT offset
    • 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, hec.data.Units.ENGLISH or if not set hec.data.Units.UNDEFINED_UNITS
    • getUnitsString

      public String getUnitsString()
      get the units string for the data. Requires that the unit system and parameter id have already 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
    • getParamIdString

      public String getParamIdString()
      get the String that represents the parameterId.
      Returns:
      the parameter string
    • getGmtOffset

      public int getGmtOffset()
      Returns the time zone that this data is defined for.
      Returns:
      the GMT offset
    • clone

      public Object clone() throws CloneNotSupportedException
      Creates a new object of the same class as this object.
      It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No
      constructor is called.
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • init

      public void init()
    • setInterpolationType

      public void setInterpolationType(int type)
      set the interpolation type to use.
      Parameters:
      type - one of SeasonalRecord.INTERP_LINEAR_ID SeasonalRecord.INTERP_CUBIC_ID SeasonalRecord.INTERP_STEP_ID
    • getInterpolationType

      public int getInterpolationType()
      get the interpolation type to use.
      Returns:
      one of SeasonalRecord.INTERP_LINEAR_ID SeasonalRecord.INTERP_CUBIC_ID SeasonalRecord.INTERP_STEP_ID
    • getTimeArray

      public int[] getTimeArray()
      return the times values as hec.heclib.util.HecTime values
      Returns:
      the times values
    • getDataArray

      public double[][] getDataArray()
      get the multiple sets of y-values
      Returns:
      the yvalues
    • getSeasonalRecordsList

      public List<SeasonalRecord> getSeasonalRecordsList()
    • setCurveLabels

      public void setCurveLabels(String[] labels)
      set the curve labels, the labels should be convertible to numeric values. the curve labels are used to determine which SeasonalRecord is used for the interpolation
      Parameters:
      labels - the labels for the curves
    • setCurveLabels

      public void setCurveLabels(double[] curveValues)
      set the curve labels. the curve labels are used to determine which SeasonalRecord is used for the interpolation
      Parameters:
      curveValues - the labels for the curves
    • setArrays

      public void setArrays(Object[][] values)
      fill the arrays with values the array is expected to have the form
      [date1][y1]
      [date2][y2]
      [date3][y3]
      [date4][y4]
      [date5][y5]

      or
      [date1][y11][y12]...
      [date2][y21][y22]...
      [date3][y31][y32]...
      [date4][y41][y42]...
      [date5][y51][y52]...

      This method will also take a Jython tuple defined like so: table=( ["01Jan1900, 1200", 10,20,30,40], ["15Jan1900, 1200", 3500,5000,7000,9000], ["30Jan1900, 1200", 10000,12000,15000,20000], ["04Feb1900, 1700", 3500, 4500, 6000, 8000])

      Parameters:
      values - the seasonal values
    • setArrays

      public void setArrays(int[] timeArray, double[][] dataArray, double[] curveValues)
      set the seasonal arrays with data.
      Parameters:
      timeArray - the date/times in hec.heclib.util.HecTime value
      dataArray - the data arrays
      curveValues - the curve values
    • setArrays

      public void setArrays(int[] timeArray, double[][] dataArray, String[] curveLabels)
      set the seasonal arrays with data.
      Parameters:
      timeArray - the date/times in hec.heclib.util.HecTime value
      dataArray - the data arrays
    • setArrays

      public void setArrays(int[] timeArray, double[] dataArray, String curveLabel)
      set the seasonal arrays with data.
      Parameters:
      timeArray - the date/times in hec.heclib.util.HecTime value
      dataArray - the data arrays
    • setArrays

      public void setArrays(String[] dateTimeArray, double[][] dataArray, double[] curveValues)
      set the seasonal arrays with data.
      Parameters:
      dateTimeArray - the date/times in a format hec.heclib.util.HecTime can parse
      dataArray - the data arrays
      curveValues - the curve values
    • setArrays

      public void setArrays(String[] dateTimeArray, double[][] dataArray, String[] curveLabels)
      set the seasonal arrays with data.
      Parameters:
      dateTimeArray - the date/times in a format hec.heclib.util.HecTime can parse
      dataArray - the data arrays
    • setArrays

      public void setArrays(String[] dateTimeArray, double[] dataArray, String curveLabel)
    • clear

      public void clear()
      empty record of all data
    • interpolate

      public double interpolate(RunTimeStep runtime, double zvalue)
      interpolate a value at the given time based on the default interpolation method
      Parameters:
      runtime - the compute's RunTimeStep
      zvalue - the value to interpolate for
      Returns:
      the Y value
    • findInterval

      public int findInterval(int rundate)
      find interval time for interpolation
    • toString

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

      public int parseString(String param)
    • size

      public int size()
      return number of x-values
      Returns:
      the number of x-values
    • getTime

      public int getTime(int id)
      returns the time at the specified array location
      Parameters:
      id - the array index to get the time for.
      Returns:
      the time as a hec.heclib.util.HecTime value
    • getYears

      public int getYears()
      get the length of the seasonal record (years)
      Returns:
      the length of the seasonal record
    • interpolate

      public double interpolate(HecTime htime, double zvalue)
      Interpolate of value based on time and zvalue
      Parameters:
      htime - the time
      zvalue - the zvalue
      Returns:
      the x-value
    • getNumberCurves

      public int getNumberCurves()
      get the number of SeasonalRecords
      Returns:
      the number of SeasonalRecords
    • getCurveLabels

      public String[] getCurveLabels()
      get the curve labels
      Returns:
      the array of curve labels
    • getCurveLabelValues

      public double[] getCurveLabelValues()
      get the curve label values
      Returns:
      the array of curve label values
    • addSeasonalRecord

      public void addSeasonalRecord(SeasonalRecord sr)
      Inserts the SeasonalRecord sr into the ArrayList of SeasonalRecords List is ordered by ascending curve value
      Parameters:
      sr - the SeasonalRecord to insert
    • 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
    • sortSeasonalRecords

      protected void sortSeasonalRecords()
      Make sure the list of SeasonalRecords are sorted by increasing curve label values
    • setDSSIdentifier

      public void setDSSIdentifier(DSSIdentifier dssId)
      set the DSSIdentifier. This is used to write out the SeasonalRecordExt to DSS when the enclosing class is AsciiSerialized
      Parameters:
      dssId - the DSSIdentifier
    • getDSSIdentifier

      public DSSIdentifier getDSSIdentifier()
    • 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