Package hec.model

Class AbstractTSRecord

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, TSRecord, Serializable, Cloneable, Comparable, Observer, mil.army.usace.hec.metadata.VerticalDatum, Modifiable

public abstract class AbstractTSRecord extends NamedType implements TSRecord, mil.army.usace.hec.metadata.VerticalDatum

Title:

Description:

See Also:
  • Field Details

    • INPUT

      public static final boolean INPUT
      See Also:
    • OUTPUT

      public static final boolean OUTPUT
      See Also:
    • _varId

      protected int _varId
    • _paramName

      protected String _paramName
    • _dssFilename

      protected String _dssFilename
    • _dssPathname

      protected String _dssPathname
    • _units

      protected String _units
    • _inputDataPos

      protected int _inputDataPos
    • _isObservedData

      protected transient boolean _isObservedData
    • _unitsType

      protected transient String _unitsType
      unit type string read from DSS path header
    • _interpUnitsType

      protected transient String _interpUnitsType
      controls type of data that gets interpolated to the dataArray, may be INST-VAL or PER-AVER or null. if null no then use _unitsType
    • _beginDate

      protected transient int _beginDate
    • _beginTime

      protected transient int _beginTime
    • _timeStepMin

      protected transient int _timeStepMin
    • _numSteps

      protected transient int _numSteps
    • _timeWindow

      protected transient String _timeWindow
    • _timeIncrString

      protected transient String _timeIncrString
    • _startTime

      protected transient HecTime _startTime
    • _endTime

      protected transient HecTime _endTime
    • _size

      protected transient int _size
    • _dssArray

      protected transient DSSArrayContainer _dssArray
    • _timeArray

      protected transient intArrayContainer _timeArray
    • _dataArray

      protected transient doubleArrayContainer _dataArray
    • _vdc

      protected transient mil.army.usace.hec.metadata.VerticalDatumContainer _vdc
    • _compressData

      protected boolean _compressData
  • Constructor Details

    • AbstractTSRecord

      public AbstractTSRecord()
    • AbstractTSRecord

      public AbstractTSRecord(int idx)
    • AbstractTSRecord

      public AbstractTSRecord(AbstractTSRecord rec)
      copy constructor
  • Method Details

    • copyInto

      public boolean copyInto(AbstractTSRecord newTsRec)
      Copy data from this RssTSRecordImpl into the given RssTSRecordImpl. A deep copy is made of data specific to this time series records. A shallow copy is made for references to global data model objects such as TSDataSet.
      Parameters:
      newTsRec - the object that will receive the copied data
      Returns:
      true if the copy was successful
    • setInterpUnitsType

      public void setInterpUnitsType(String type)
      Specified by:
      setInterpUnitsType in interface TSRecord
    • getInterpUnitsType

      public String getInterpUnitsType()
      Specified by:
      getInterpUnitsType in interface TSRecord
    • shiftLeft

      public void shiftLeft(RunTimeWindow rtw)
      Specified by:
      shiftLeft in interface TSRecord
    • shiftLeft

      public void shiftLeft(HecTime startTime)
      Specified by:
      shiftLeft in interface TSRecord
    • setVariableId

      public void setVariableId(int varid)
      Specified by:
      setVariableId in interface TSRecord
    • getVariableId

      public int getVariableId()
      Specified by:
      getVariableId in interface TSRecord
    • clone

      public Object clone()
      Description copied from class: NamedType
      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 NamedType
    • getSummaryArray

      public double[] getSummaryArray()
      returns an array containing the average, min, max, and count of valid data in time series
      Specified by:
      getSummaryArray in interface TSRecord
    • getNumSteps

      public int getNumSteps()
      Specified by:
      getNumSteps in interface TSRecord
    • setTimeWindowString

      public void setTimeWindowString(String timestr)
      Specified by:
      setTimeWindowString in interface TSRecord
    • getTimeWindowString

      public String getTimeWindowString()
      Specified by:
      getTimeWindowString in interface TSRecord
    • setTimeWindow

      public void setTimeWindow(HecTime start, HecTime end)
      Specified by:
      setTimeWindow in interface TSRecord
    • setUnits

      public void setUnits(String units)
      Specified by:
      setUnits in interface TSRecord
    • getUnits

      public String getUnits()
      Specified by:
      getUnits in interface TSRecord
    • setUnitsType

      public void setUnitsType(String dataType)
      set the units type. one of DssDataType.INST-VAL,DssDataType.INST-CUM, DssDataType.PER-AVER, DssDataType.PER-CUM
      Specified by:
      setUnitsType in interface TSRecord
      Parameters:
      dataType - - the data type
      See Also:
    • getBeginDate

      public int getBeginDate()
      Rerturns the date in HEC Julian Day
      Specified by:
      getBeginDate in interface TSRecord
      Returns:
      int
    • getBeginTime

      public int getBeginTime()
      Specified by:
      getBeginTime in interface TSRecord
    • getTimeStepMinutes

      public int getTimeStepMinutes()
      Returns the time step in minutes;
      Specified by:
      getTimeStepMinutes in interface TSRecord
      Returns:
      int
    • getUnitsType

      public String getUnitsType()
      get the units type. one of DssDataType.INST-VAL,DssDataType.INST-CUM, DssDataType.PER-AVER, DssDataType.PER-CUM or not set, which returns an empty String
      Specified by:
      getUnitsType in interface TSRecord
      Returns:
      unitsType - the data type
      See Also:
    • getTimeArray

      public int[] getTimeArray()
      Specified by:
      getTimeArray in interface TSRecord
    • getDataArrayFor

      public double[] getDataArrayFor(int step, int period)
      Returns the values for the data starting at step and either going back period steps if the value is negative or forward if the value is positive.
      Specified by:
      getDataArrayFor in interface TSRecord
      Parameters:
      step - the starting step
      period - the number of steps to go back if a negative number or forward is a positive number
      Returns:
      double[] of the values for the given time span or null
    • getTSArray

      public double[] getTSArray()
      Get the data array for the time series record.
      Specified by:
      getTSArray in interface TSRecord
      Returns:
      double array containing all data values for record
    • getTSContainer

      public doubleArrayContainer getTSContainer()
      Specified by:
      getTSContainer in interface TSRecord
    • reset

      public void reset()
      Specified by:
      reset in interface TSRecord
    • initialize

      public boolean initialize(RunTimeWindow rtw)
      Specified by:
      initialize in interface TSRecord
    • reinitialize

      public boolean reinitialize(RunTimeWindow rtw)
      TODO complete this method - currently it does just what initialize does
      Specified by:
      reinitialize in interface TSRecord
    • initialize

      public boolean initialize(int beginDate, int beginTime, int timeStepMin, int numSteps, String timeWindow)
      Specified by:
      initialize in interface TSRecord
    • getParamName

      public String getParamName()
      Specified by:
      getParamName in interface TSRecord
    • setParamName

      public void setParamName(String name)
      Specified by:
      setParamName in interface TSRecord
    • getDSSPathname

      public String getDSSPathname()
      Specified by:
      getDSSPathname in interface TSRecord
    • setDSSPathname

      public void setDSSPathname(String name)
      Specified by:
      setDSSPathname in interface TSRecord
    • setDSSPathname

      public void setDSSPathname(String[] parts)
      Specified by:
      setDSSPathname in interface TSRecord
    • getDSSFilename

      public String getDSSFilename()
      Specified by:
      getDSSFilename in interface TSRecord
    • setDSSFilename

      public void setDSSFilename(String name)
      Specified by:
      setDSSFilename in interface TSRecord
    • setInputDataPos

      public void setInputDataPos(int inputPos)
      Specified by:
      setInputDataPos in interface TSRecord
    • getInputDataPos

      public int getInputDataPos()
      Specified by:
      getInputDataPos in interface TSRecord
    • isObservedData

      public boolean isObservedData()
      Specified by:
      isObservedData in interface TSRecord
    • isDefaultData

      public boolean isDefaultData()
      Specified by:
      isDefaultData in interface TSRecord
    • readData

      public boolean readData(BufferedReader input)
      Description copied from interface: TSRecord
      Read write methods for storing TSRecords to an ASCII file
      Specified by:
      readData in interface TSRecord
    • getRelativePath

      public abstract String getRelativePath(String pathName)
    • writeData

      public boolean writeData(BufferedWriter out)
      Specified by:
      writeData in interface TSRecord
    • readDataFromRas

      public boolean readDataFromRas(BufferedReader input)
      Reads time series record parameters from an existing opened BufferedReader according to RAS v.2.2 flow file format
      Specified by:
      readDataFromRas in interface TSRecord
    • writeDataToRas

      public boolean writeDataToRas(BufferedWriter out)
      Specified by:
      writeDataToRas in interface TSRecord
    • getValue

      public double getValue(HecTime time)
      Return the time series value at the specified time, do linear interpolation as necessary. Should add cubic interpolation later. It seems the time array is in minutes, check with Bill to see if this is right. Need to add error messages. If time is outside the time window the return value will be RMAConst.UNDEF_DOUBLE
      Specified by:
      getValue in interface TSRecord
      Parameters:
      time - time of data
      Returns:
      double value of data at specified time
    • getTSValueAt

      @Deprecated public double getTSValueAt(HecTime time)
      Deprecated.
      Return the time series value at the specified time, do linear interpolation as necessary. Should add cubic interpolation later. It seems the time array is in minutes, check with Bill to see if this is right. Need to add error messages.
      Specified by:
      getTSValueAt in interface TSRecord
      Parameters:
      time - time of data
      Returns:
      double value of data at specified time
    • getInterpolatedTSArray

      public double[] getInterpolatedTSArray(HecTime startTime, HecTime endTime, int intervalTime)
      Interpolate time series data for a regular size time interval "intervalTime" in minutes
      Specified by:
      getInterpolatedTSArray in interface TSRecord
    • parseDssPath

      public static String[] parseDssPath(String dsspath)
    • getCurrentValue

      public double getCurrentValue(RunTimeStep rts)
      return the value for the current runtime step
      Specified by:
      getCurrentValue in interface TSRecord
      Parameters:
      rts - the RunTimeStep
      Returns:
      the value at RunTimeStep.step
    • getValue

      public double getValue(int step)
      get the value at step
      Specified by:
      getValue in interface TSRecord
      Parameters:
      step - the index into the data array
      Returns:
      the value at step
    • setCurrentValue

      public void setCurrentValue(RunTimeStep rts, double value)
      set the value at the current run time step
      Specified by:
      setCurrentValue in interface TSRecord
      Parameters:
      rts - the index into the data array
      value - the value to set
    • setCurrentValue

      public void setCurrentValue(int step, double value)
      set the value at step
      Specified by:
      setCurrentValue in interface TSRecord
      Parameters:
      step - the index into the data array
      value - the value to set
    • getLaggedValue

      public double getLaggedValue(RunTimeStep rts, int lagAmount)
      get the value at current runtime step minus the lag amount
      Specified by:
      getLaggedValue in interface TSRecord
      Parameters:
      rts - the RunTimeWindow
      lagAmount - the lag amount
      Returns:
      the value at rts.step-lagAmount
    • getPreviousValue

      public double getPreviousValue(RunTimeStep rts)
      get the value previous to the current runtime step
      Specified by:
      getPreviousValue in interface TSRecord
      Parameters:
      rts - the RunTimeStep
      Returns:
      the value one step back (rts.step-1)
    • getPeriodAverage

      public double getPeriodAverage(RunTimeStep rts, int period, int lag)
      Get the Period Average starting at RunTimeStep and going back period steps. Assumes that data is constant prior to and following the time series array limits.
      Parameters:
      rts - the RunTimeStep
      period - the period to go back
      lag - the number of steps back to start the average period
      Returns:
      the period average of rts.step - period
    • getPeriodAverage

      public double getPeriodAverage(int step, int period, int lag)
      Get the Period Average starting at RunTimeStep and going back period steps. Assumes that data is constant prior to and following the time series array limits.
      Parameters:
      step - the starting step
      period - the period to go back
      lag - the number of steps back to start the average period
      Returns:
      the period average of rts.step - period
    • getPeriodAverage

      public double getPeriodAverage(RunTimeStep rts, int period)
      Get the Period Average starting at RunTimeStep and going back period steps. Assumes that data is constant prior to and following the time series array limits.
      Specified by:
      getPeriodAverage in interface TSRecord
      Parameters:
      rts - the RunTimeStep
      period - the period to go back
      Returns:
      the period average of rts.step - period
    • getPeriodAverage

      public double getPeriodAverage(int step, int period)
      Get the Period Average starting at RunTimeStep and going back period steps. Assumes that data is constant prior to and following the time series array limits.
      Specified by:
      getPeriodAverage in interface TSRecord
      Parameters:
      step - the starting step
      period - the number of steps to go back.
      Returns:
      the period average of step - period
    • getCumulativeTotal

      public double getCumulativeTotal(RunTimeStep rts, int period)
      Get the cumulative total starting at rts and going back period steps. Assumes that data is constant prior to and following the time series array limits.
      Specified by:
      getCumulativeTotal in interface TSRecord
      Parameters:
      rts - the RunTimeStep
      period - the number of steps to go back
      Returns:
      the cumulative total of rts.step - period
    • getCumulativeTotal

      public double getCumulativeTotal(int step, int period)
      get the cumulative total starting at step and going back period steps.
      Specified by:
      getCumulativeTotal in interface TSRecord
      Parameters:
      step - the starting step
      period - the number of steps to go back
      Returns:
      the cumulative total of step - period
    • getTimeSeriesContainer

      public TimeSeriesContainer getTimeSeriesContainer()
      Get the TimeSeriesContainer for the TSRecord. The TimeSeriesContainer and the TSRecord share the same underlying data model so changes in the data or times in one are reflected in the other. The TimeSeriesContainer will have no quality.
      Specified by:
      getTimeSeriesContainer in interface TSRecord
      Returns:
      The TSRecord's TimeSeriesContainer
    • max

      public double max(int step, int period)
      Finds the maximum value in the data starting at step and going back period, if the value is negative or forward period, if the value is positive.
      Specified by:
      max in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back if a negative number or forward is a positive number
      Returns:
      the maximum value in the given time range or Const.UNDEFINED_DOUBLE
    • min

      public double min(int step, int period)
      Finds the minimum value in the data set starting at step and going back period, if the value is negative or forward period, if the value is positive.
      Specified by:
      min in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back if a negative number or forward is a positive number
      Returns:
      the minimum value in the given time range or Const.UNDEFINED_DOUBLE
    • average

      public double average(int step, int period)
      Calculates the period average for the values in the data starting at step and going back period, if the value is negative or forward period, if the value is positive. Does not include undefined or missing values.
      Specified by:
      average in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back if a negative number or forward is a positive number
      Returns:
      double the period average for the values in the given time range or Const.UNDEFINED_DOUBLE
    • sum

      public double sum(int step, int period)
      Calculates the sum for the values in the data starting at step and going back period, if the value is negative or forward period, if the value is positive. Does not include undefined or missing values.
      Specified by:
      sum in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back if a negative number or forward is a positive number
      Returns:
      double the total sum for the values in the given time range or Const.UNDEFINED_DOUBLE
    • standardDeviation

      public double standardDeviation(int step, int period)
      Calculate the standard deviation of the time series values starting at step and either going back period steps if the value is negative or forward if the value is positive.
      Specified by:
      standardDeviation in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back if a negative number or forward is a positive number
      Returns:
      double the sample standard deviation or Const.UNDEFINED_DOUBLE
    • getTimeSeriesContainerFor

      public TimeSeriesContainer getTimeSeriesContainerFor(int step, int period)
      Creates a TimeSeriesContainer filled with data from the TSRecord starting at "step" and going forward, if period is positive, or backwards, if period is negative.
      Specified by:
      getTimeSeriesContainerFor in interface TSRecord
      Parameters:
      step - , the starting step
      period - , the number of steps to go back when a negative number or forward if a positive number
    • hasVerticalDatum

      public boolean hasVerticalDatum()
      Return whether this object includes vertical datum information
    • getVerticalDatumContainer

      public mil.army.usace.hec.metadata.VerticalDatumContainer getVerticalDatumContainer()
      Specified by:
      getVerticalDatumContainer in interface mil.army.usace.hec.metadata.VerticalDatum
    • setVerticalDatumContainer

      public void setVerticalDatumContainer(mil.army.usace.hec.metadata.VerticalDatumContainer vdc)
      Sets the Vertical Datum Container
      Parameters:
      vdc - |
    • getNativeVerticalDatum

      public String getNativeVerticalDatum() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getNativeVerticalDatum in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getCurrentVerticalDatum

      public String getCurrentVerticalDatum() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getCurrentVerticalDatum in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • isCurrentVerticalDatumEstimated

      public boolean isCurrentVerticalDatumEstimated() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      isCurrentVerticalDatumEstimated in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • toNativeVerticalDatum

      public boolean toNativeVerticalDatum() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      toNativeVerticalDatum in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • toNGVD29

      public boolean toNGVD29() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      toNGVD29 in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • toNAVD88

      public boolean toNAVD88() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      toNAVD88 in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • toVerticalDatum

      public boolean toVerticalDatum(String datum) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      toVerticalDatum in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • forceVerticalDatum

      public boolean forceVerticalDatum(String datum) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      forceVerticalDatum in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getCurrentOffset

      public double getCurrentOffset() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getCurrentOffset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getCurrentOffset

      public double getCurrentOffset(String unit) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getCurrentOffset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getNGVD29Offset

      public double getNGVD29Offset() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getNGVD29Offset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getNGVD29Offset

      public double getNGVD29Offset(String unit) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getNGVD29Offset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getNAVD88Offset

      public double getNAVD88Offset() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getNAVD88Offset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getNAVD88Offset

      public double getNAVD88Offset(String unit) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getNAVD88Offset in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • isNGVD29OffsetEstimated

      public boolean isNGVD29OffsetEstimated() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      isNGVD29OffsetEstimated in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • isNAVD88OffsetEstimated

      public boolean isNAVD88OffsetEstimated() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      isNAVD88OffsetEstimated in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • getVerticalDatumInfo

      public String getVerticalDatumInfo() throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      getVerticalDatumInfo in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • setVerticalDatumInfo

      public void setVerticalDatumInfo(String xmlStr) throws mil.army.usace.hec.metadata.VerticalDatumException
      Specified by:
      setVerticalDatumInfo in interface mil.army.usace.hec.metadata.VerticalDatum
      Throws:
      mil.army.usace.hec.metadata.VerticalDatumException
    • 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
      Overrides:
      getFieldObject in class NamedType
      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
      Overrides:
      setFieldObject in class NamedType
      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
    • setCompressData

      public void setCompressData(boolean comp)
      Specified by:
      setCompressData in interface TSRecord