Package hec.model
Class SeasonalRecord
java.lang.Object
hec.model.SeasonalRecord
- All Implemented Interfaces:
AsciiSerializable,FieldAccessor,Serializable,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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()empty record of all dataclone()Creates a new object of the same class as this object.intfindInterval(int rundate) find interval time for interpolationdoubleget the annual averageget the label for the SeasonalRecord curvedoubleParse the curve label string to return a double value.double[]get the data arrayget the DSSIdentifier to store the data intogetFieldObject(Field fld) This method allows access to java.lang.reflect.Field objects within the implementing class.intReturns the time zone that this data is defined for.intget the interpolation type being used.doublegets the largest value greater than zero from the data arrayintReturns the parameter id for the "double" data values.get the Parameter String for the Parameter IDintgetTime(int id) returns the time at the specified array locationint[]get the time arrayget the units String for the dataintReturns the unit system that this data is defined in or hec.data.Units.UNDEF_ID if no unit system has been setdoublegetValue(int id) returns the value at the specified array locationintgetYears()get the length of the seasonal record (years)voidinit()protected voiddoubleinterpolate(HecTime htime) interpolate a value at the given time based on the default interpolation methoddoubleinterpolate(RunTimeStep runtime) interpolate a value at the given time based on the default interpolation methoddoubleinterpolateStepValue(int interpTime) Do a step interpolation of value based on time indexdoubleinterpolateValue(int interpTime) Do a linear interpolation of value based on time indexdoubleinterpolateValueCubicSpline(int interpTime) Do a cublic spline interpolation of value based on time indexprotected booleanintparseString(String param) parse the string into valuesvoidscaleValues(double scl) set the scale value to usevoidsetArrays(int[] timeArray, double[] dataArray) set the time and data arraysvoidsetCurveLabel(String str) set the label for the SeasonalRecord curvevoidsetDSSIdentifier(DSSIdentifier dssId) set the DSSIdentifier to store the data intobooleansetFieldObject(Field fld, Object fobj) This allows access to fields withing the implementing object to set there data.voidsetGmtOffset(int offset) set the GMT offset for the datavoidsetInterpolationType(int type) set the interpolation type to use when interpolating data.voidsetParameterId(int parameterId) Sets the parameter ID for the double values in this record.voidsetUnitSystem(int us) Sets the new unit system for this data.intsize()returns the current length of the seasonal record data arraystoString()return the SeasonalRecord in the form of a String.
-
Field Details
-
INTERP_LINEAR
- See Also:
-
INTERP_CUBIC
- See Also:
-
INTERP_STEP
- See Also:
-
INTERP_LINEAR_ID
public static final int INTERP_LINEAR_ID- See Also:
-
INTERP_CUBIC_ID
public static final int INTERP_CUBIC_ID- See Also:
-
INTERP_STEP_ID
public static final int INTERP_STEP_ID- See Also:
-
INTERP_STRINGS
-
-
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
get the units String for the data- Returns:
- the units 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
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:
clonein classObject- 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 arraydataArray- the data array
-
clear
public void clear()empty record of all data -
interpolate
interpolate a value at the given time based on the default interpolation method- Returns:
- the value at the interpolated run time step
-
interpolate
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
set the label for the SeasonalRecord curve- Parameters:
str- the curve label
-
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
return the SeasonalRecord in the form of a String. -
parseString
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
set the DSSIdentifier to store the data into- Parameters:
dssId- the new DSSIdentifier
-
getDSSIdentifier
get the DSSIdentifier to store the data into- Returns:
- the new DSSIdentifier
-
getFieldObject
Description copied from interface:FieldAccessorThis method allows access to java.lang.reflect.Field objects within the implementing class.- Specified by:
getFieldObjectin interfaceFieldAccessor- Parameters:
fld- The field to get.- Returns:
- The data object that is stored in the given field
-
setFieldObject
Description copied from interface:FieldAccessorThis allows access to fields withing the implementing object to set there data.- Specified by:
setFieldObjectin interfaceFieldAccessor- Parameters:
fld- The java field object representing the member field to be setfobj- The data to set in that field- Returns:
- returns true if successful
-