Package hec.model

Class SeasonalRecord

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

public class SeasonalRecord extends Object implements AsciiSerializable, Cloneable
Contains a set of date-values pairs representing seasonal variation of a value. Methods include string I/O and interpolation functions.
See Also:
  • Field Details

  • Constructor Details

    • SeasonalRecord

      public SeasonalRecord()
  • Method Details

    • scaleValues

      public void scaleValues(double scl)
      set the scale value to use
      Parameters:
      scl - the new scale value to apply to the data
    • setParameterId

      public void setParameterId(int parameterId)
      Sets the parameter ID for the double values in this record.
      Parameters:
      parameterId -
      See Also:
    • getParameterId

      public int getParameterId()
      Returns the parameter id for the "double" data values.
    • setUnitSystem

      public void setUnitSystem(int us)
      Sets the new unit system for this data. The data is not converted if there is a change of systems
      Parameters:
      us - the new unit system. one of Units.SI_ID or Units.ENGLISH_ID
    • setGmtOffset

      public void setGmtOffset(int offset)
      set the GMT offset for the data
      Parameters:
      offset - the new 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 data's unit system
      See Also:
    • getUnitsString

      public String getUnitsString()
      get the units String for the data
      Returns:
      the units String
    • getParamIdString

      public String getParamIdString()
      get the Parameter String for the Parameter ID
      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 when interpolating data. INTERP_LINEAR_ID is the default;
      Parameters:
      type - one of INTERP_LINEAR_ID, INTERP_CUBIC_ID or INTERP_STEP_ID
    • initInterpArray

      protected void initInterpArray()
    • makeLeapYearTimeArray

      protected boolean makeLeapYearTimeArray()
    • getInterpolationType

      public int getInterpolationType()
      get the interpolation type being used. INTERP_LINEAR_ID is the default;
      Returns:
      the interpolation type one of INTERP_LINEAR_ID, INTERP_CUBIC_ID or INTERP_STEP_ID
    • getTimeArray

      public int[] getTimeArray()
      get the time array
      Returns:
      the time array
    • getDataArray

      public double[] getDataArray()
      get the data array
      Returns:
      the data array
    • setArrays

      public void setArrays(int[] timeArray, double[] dataArray)
      set the time and data arrays
      Parameters:
      timeArray - the time array
      dataArray - the data array
    • clear

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

      public double interpolate(RunTimeStep runtime)
      interpolate a value at the given time based on the default interpolation method
      Returns:
      the value at the interpolated run time step
    • interpolate

      public double interpolate(HecTime htime)
      interpolate a value at the given time based on the default interpolation method
      Parameters:
      htime - the time to get the value at
      Returns:
      the interpolated value
    • interpolateValue

      public double interpolateValue(int interpTime)
      Do a linear interpolation of value based on time index
      Parameters:
      interpTime - the index in the time array
      Returns:
      the interpolated value n
    • interpolateStepValue

      public double interpolateStepValue(int interpTime)
      Do a step interpolation of value based on time index
      Parameters:
      interpTime - the index in the time array
      Returns:
      the interpolated value
    • interpolateValueCubicSpline

      public double interpolateValueCubicSpline(int interpTime)
      Do a cublic spline interpolation of value based on time index
      Parameters:
      interpTime - the index in the time array
      Returns:
      the interpolated value
    • findInterval

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

      public void setCurveLabel(String str)
      set the label for the SeasonalRecord curve
      Parameters:
      str - the curve label
    • getCurvelLabel

      public String getCurvelLabel()
      get the label for the SeasonalRecord curve
      Returns:
      the curve label or null if not set
    • getCurveValue

      public double getCurveValue()
      Parse the curve label string to return a double value. If may be used for 3-variable interpolation between multiple SeasonalRecord curves.
      Returns:
    • toString

      public String toString()
      return the SeasonalRecord in the form of a String.
      Overrides:
      toString in class Object
    • parseString

      public int parseString(String param)
      parse the string into values
      Parameters:
      param -
      Returns:
      the number of value pairs loaded
    • size

      public int size()
      returns the current length of the seasonal record data arrays
      Returns:
      the number of values held by the SeasonalRecord
    • getLargestValue

      public double getLargestValue()
      gets the largest value greater than zero from the data array
      Returns:
      the largest value or RMAConst.UNDEF_DOUBLE if there are no values
    • getAnnualAverage

      public double getAnnualAverage()
      get the annual average
      Returns:
    • getValue

      public double getValue(int id)
      returns the value at the specified array location
    • getTime

      public int getTime(int id)
      returns the time at the specified array location
    • getYears

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

      public void setDSSIdentifier(DSSIdentifier dssId)
      set the DSSIdentifier to store the data into
      Parameters:
      dssId - the new DSSIdentifier
    • getDSSIdentifier

      public DSSIdentifier getDSSIdentifier()
      get the DSSIdentifier to store the data into
      Returns:
      the new DSSIdentifier
    • 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