Package hec.model
Class SeasonalRecordExt
java.lang.Object
hec.model.SeasonalRecordExt
- All Implemented Interfaces:
AsciiSerializable,FieldAccessor,Serializable,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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the SeasonalRecord sr into the ArrayList of SeasonalRecords List is ordered by ascending curve valuevoidclear()empty record of all dataclone()Creates a new object of the same class as this object.intfindInterval(int rundate) find interval time for interpolationString[]get the curve labelsdouble[]get the curve label valuesdouble[][]get the multiple sets of y-valuesgetFieldObject(Field fld) required AsciiSerialized method.intReturns the time zone that this data is defined for.intget the interpolation type to use.intget the number of SeasonalRecordsintReturns the parameter id for the "double" data values.get the String that represents the parameterId.intgetTime(int id) returns the time at the specified array locationint[]return the times values ashec.heclib.util.HecTimevaluesget the units string for the data.intReturns the unit system that this data is defined in or hec.data.Units.UNDEF_ID if no unit system has been setintgetYears()get the length of the seasonal record (years)voidinit()doubleinterpolate(HecTime htime, double zvalue) Interpolate of value based on time and zvaluedoubleinterpolate(RunTimeStep runtime, double zvalue) interpolate a value at the given time based on the default interpolation methodintparseString(String param) voidremoveCurve(int index) Removes an entire curve from the set of curves located atindex voidsetArrays(int[] timeArray, double[][] dataArray, double[] curveValues) set the seasonal arrays with data.voidset the seasonal arrays with data.voidset the seasonal arrays with data.voidfill 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]...
voidset the seasonal arrays with data.voidset the seasonal arrays with data.voidvoidsetCurveLabels(double[] curveValues) set the curve labels.voidsetCurveLabels(String[] labels) set the curve labels, the labels should be convertible to numeric values.voidsetDSSIdentifier(DSSIdentifier dssId) set the DSSIdentifier.booleansetFieldObject(Field fld, Object fobj) required AsciiSerialized method.voidsetGmtOffset(int offset) set the offset from GMTvoidsetInterpolationType(int type) set the interpolation type to use.voidsetParameterId(int parameterId) Sets the parameter ID for the double values in this record.voidsetUnitSystem(int us) set the unit system.intsize()return number of x-valuesprotected voidMake sure the list of SeasonalRecords are sorted by increasing curve label valuestoString()
-
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 behec.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 ofhec.data.Units.SI_IDorhec.data.Units.ENGLISH_IDthe data is not converted on a change of unit system- Parameters:
us- one ofhec.data.Units.SI_IDorhec.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.ENGLISHor if not sethec.data.Units.UNDEFINED_UNITS
-
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_IDor if not sethec.data.Units.UNDEF_ID
-
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
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.- Parameters:
type- one ofSeasonalRecord.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 ashec.heclib.util.HecTimevalues- Returns:
- the times values
-
getDataArray
public double[][] getDataArray()get the multiple sets of y-values- Returns:
- the yvalues
-
getSeasonalRecordsList
-
setCurveLabels
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
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 inhec.heclib.util.HecTimevaluedataArray- the data arrayscurveValues- the curve values
-
setArrays
set the seasonal arrays with data.- Parameters:
timeArray- the date/times inhec.heclib.util.HecTimevaluedataArray- the data arrays
-
setArrays
set the seasonal arrays with data.- Parameters:
timeArray- the date/times inhec.heclib.util.HecTimevaluedataArray- the data arrays
-
setArrays
set the seasonal arrays with data.- Parameters:
dateTimeArray- the date/times in a formathec.heclib.util.HecTimecan parsedataArray- the data arrayscurveValues- the curve values
-
setArrays
set the seasonal arrays with data.- Parameters:
dateTimeArray- the date/times in a formathec.heclib.util.HecTimecan parsedataArray- the data arrays
-
setArrays
-
clear
public void clear()empty record of all data -
interpolate
interpolate a value at the given time based on the default interpolation method- Parameters:
runtime- the compute's RunTimeStepzvalue- the value to interpolate for- Returns:
- the Y value
-
findInterval
public int findInterval(int rundate) find interval time for interpolation -
toString
-
parseString
-
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.HecTimevalue
-
getYears
public int getYears()get the length of the seasonal record (years)- Returns:
- the length of the seasonal record
-
interpolate
Interpolate of value based on time and zvalue- Parameters:
htime- the timezvalue- the zvalue- Returns:
- the x-value
-
getNumberCurves
public int getNumberCurves()get the number of SeasonalRecords- Returns:
- the number of SeasonalRecords
-
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
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 atindex - 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
set the DSSIdentifier. This is used to write out the SeasonalRecordExt to DSS when the enclosing class is AsciiSerialized- Parameters:
dssId- the DSSIdentifier
-
getDSSIdentifier
-
getFieldObject
required AsciiSerialized method. publicially callable only because of an implementation detail. Should not be called by anything other than the AsciiSerializer- Specified by:
getFieldObjectin interfaceFieldAccessor- Parameters:
fld- The field to get.- Returns:
- The data object that is stored in the given field
-
setFieldObject
required AsciiSerialized method. publicially callable only because of an implementation detail. Should not be called by anything other than the AsciiDeserializer- 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
-