Package hec.io
Class TimeSeriesContainer
java.lang.Object
hec.io.DataContainer
hec.io.TimeSeriesContainer
- All Implemented Interfaces:
IVerticalDatumOperations<TimeSeriesContainer,,mil.army.usace.hec.metadata.VerticalDatumException> Serializable,Cloneable
- Direct Known Subclasses:
TimeSeriesContainerVertDatum
public class TimeSeriesContainer
extends DataContainer
implements Cloneable, Serializable, IVerticalDatumOperations<TimeSeriesContainer,mil.army.usace.hec.metadata.VerticalDatumException>
This is a simple generic container class that holds
time series data, and some related information
The purpose of this class is to pass time series data
to plot and tabulate functions.
The class does not know where the data came from (or
is going). It does not contain any reference or connection
to any database.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class hec.io.DataContainer
DataContainer.VERTICAL_DATUM, DataContainer.VERTICAL_UNITS -
Field Summary
FieldsModifier and TypeFieldDescriptionString[]intDeprecated.use endHecTime instead, set with setEndTimeint[][]intDeprecated.Do not access this variable directly.intintintThe C Part of the DSS Pathintdouble[]double[][]int[]int[][]booleanintintintDeprecated.use startHecTime instead, set with setStartTimeintint[]intthe Units i.e.double[]Fields inherited from class hec.io.DataContainer
coordinateID, coordinateSystem, CURRENT_VERTICAL_DATUM_HEADER, CURRENT_VERTICAL_DATUM_KEY, dataType, fileLastWriteTimeMillis, fileName, fullName, horizontalDatum, horizontalUnits, lastWriteTimeMillis, location, locationTimezone, modified, otherInfo, storedAsdoubles, subVersion, supplementalInfo, version, VERTICAL_DATUM_INFO_HEADER, VERTICAL_DATUM_INFO_KEY, verticalDatum, verticalUnits, watershed, xOrdinate, yOrdinate, zOrdinate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanclone()clone the TimeSerieContainervoidclone(TimeSeriesContainer tsc) clone this TimeSeriesContainer into tscReturns a new TimeSeriesContainer object constructed from this object, with the TimeSeiresContainerVertDatum.vdc field collapsed into vertical datum info in the supplementalInfo field (overwriting any existing vertical datum info there)booleanbooleanconvertTimeZone(String toTimezoneID, boolean observeDST) converts the data, start and end time to a new time zonevoidconvertTimeZone(TimeZone toTimezone) converts the data, start and end time to a new time zoneReturns a new TimeSeriesContainerVertDatum object constructed from this object and the vertical datum info in the supplementalInfo field of this object.get the TimeSeriesContainer as a StringgetAsXML()get the TimeSeriesContainer as a XML StringString[]booleangetDataSetStats(TsDataSetStats dataStats) Returns the end time.Returns the String representation the time series id, and if it exists the version date separated by ':'getHecTime(int index) Gets the time for an individual ordiante in the times array.intGets the base date for this objectstatic int[]getJulianDateAndTimeGranularity(HecTimeArray hecTimes, int dataValuesLength) Returns the String representation of the DSS Location LOCATION - SUB_LOCATION or "" if the values are nullint[]Gets the times in minutes.long[]Gets the times in minutes.longgetMinutesLong(int index) Gets the time, in minutes, for a specific ordinate.intReturns the number of values in the dataset.Returns the String representation of the DSS Parameter PARAMETER - SUB_PARAMETER or "" if the values are nulldouble[]intdouble[][]int[]Return a copy of the quality arrayint[][]Return a copy of the quality arrayintReturns the short String representation of the time series id, the location name, version name, parameter name separated by ' ', and if it exists the version date separated by ':'Returns the start time.intGets the time granularity for the time array.intDeprecated.usegetTimeIntervalSeconds()instead as the resolution of the returned interval is based on the timeGranularitySecondsintget the time interval in seconds that the data is atgetTimes()Return the times array as an HecTimeArray.get the DATA time zone identifier.getType()get the data typegetUnits()get the unitsdoublegetValue(int index) Returns a single value according to the index.doubleReturn the time series value at the specified time, do linear interpolation as necessary.double[]Return a copy of the data values arraymil.army.usace.hec.data.timeseries.VersionDategets the VersionDateReturns the String representation of the DSS Version VERSION - SUB_VERSION or "" if the values are nullOptional<mil.army.usace.hec.metadata.VerticalDatum>booleanvoidrearrrange time and data arrays so that all times are ascending Remove any undefinded times and reset array sized to reflect Primarily for irregular interval datadoubleget the maximum value from the time series valuesdoubleDeprecated.use maximumValue()doublemean()get the mean value from the time series valuesdoubleget the minimum value of the datavoidPrints time series data to System.outvoidprintToConsole(int maxNumberToPrint) Prints time series data to System.outintRemove all missing values from the data array, reducing the size of the time, values, and quality arrays.intset(double[] dataValues, long[] minutes) Sets the data and times array, converting long minutes to int minutes, and setting the julian base date and time granularity, if required to keep within int boundary.intset(double[] dataValues, HecTimeArray hecTimes) Sets the data and time arrays, including start and end times, and number of values.intset(double[] dataValues, HecTimeArray hecTimes, int julBaseDate, int timeGranularityInSeconds) Generally not a public item.intset(HecTimeArray hecTimes, int julBaseDate, int timeGranularityInSeconds) voidsetCharacterNotes(String[] characterNotes) voidsetCompressData(boolean compress) voidsetEndTime(HecTime end) Sets the end time, if differnt than the default end time (the last value in the times array.) This can be used by irregular interval data to show that there is no data between the last time in the times array and this value
This must be called after setting times array, if not using defaultvoidsetJulianBaseDate(int julBaseDate) Set the julain base date (defualt is zero).intsetProfile(double[] profileDepths, double[][] profileValues) voidsetProfileDepthsUnits(String unitsProfileDepths) voidsetProfileLabel(String profileLabel) voidsetProfileValuesUnits(String unitsProfileValues) intsetQuality(int[] qualityIn) Sets the quality array.intsetQuality7(int[][] qualityIn) voidsetStartTime(HecTime start) Sets the start time, if different than the default start time (the first value in the times array.) This can be used by irregular interval data to show that there is no data between this time and first time in the times array.voidsetTimeGranularitySeconds(int timeGranularityInSeconds) Sets the time granularity for time time array This is normally 60 (seconds), but the acceptable values are:
Time Granularity timeGranularityInSecondsMax DaysMax Years One second 1 24,855 69 One minute 60 1,491,308 4,083 One hour 3600 89,478,485 244,978 One day 86400 2,147,483,6475,879,489(current limit for TSC) One year 31536000 (nominal)(not supported at this time)intsetTimes(HecTimeArray hecTimes) set the timesvoidsetTimeZoneID(String timeZoneIdentifier) Set the DATA time zone identifier.voidset the data typevoidset the units (i.e.intsetValues(double[] dataValues) Sets the data values array.voidsetVersionDate(mil.army.usace.hec.data.timeseries.VersionDate versionDate) sets the VersionDatebooleantrimToTime(HecTime newStartTime, HecTime newEndTime) booleantrimToTime(HecTime newStartTime, HecTime newEndTime, boolean bShrinkOnly) booleanDetermines if extended dates are used and times in long (or HecTime) need to be used.Methods inherited from class hec.io.DataContainer
clone, extractVerticalDatum, getFullName, getHorizontalDatum, getLatLong, getName, getStoreAsDoubles, getSupplementalInfo, getVerticalDatum, getVerticalUnits, insertVerticalDatum, setFullName, setHorizontalDatum, setLatLong, setName, setStoreAsDoubles, setSupplementalInfo, setVerticalDatum, setVerticalDatum, setVerticalUnits, setVerticalUnits, toString
-
Field Details
-
values
public double[] values -
times
public int[] times -
quality
public int[] quality -
numberValues
public int numberValues -
interval
Deprecated.Do not access this variable directly. The interval may be represented in second, minutes, etc. depending on the timeGranularitySeconds usegetTimeIntervalSeconds()instead for consistencyinterval between data points. the resolution of the interval is based on timeGranularitySeconds -
startTime
Deprecated.use startHecTime instead, set with setStartTime -
endTime
Deprecated.use endHecTime instead, set with setEndTime -
startHecTime
-
endHecTime
-
units
the Units i.e. CFS -
type
-
precision
public int precision -
subLocation
-
parameter
The C Part of the DSS Path -
subParameter
-
timeZoneID
-
timeZoneRawOffset
public int timeZoneRawOffset -
julianBaseDate
public int julianBaseDate -
timeGranularitySeconds
public int timeGranularitySeconds -
retrieveAllTimes
public boolean retrieveAllTimes -
quality7
public int[][] quality7 -
sizeEachQuality7
public int sizeEachQuality7 -
inotes
public int[][] inotes -
sizeEachNote
public int sizeEachNote -
cnotes
-
numberDepths
public int numberDepths -
profileDepths
public double[] profileDepths -
profileValues
public double[][] profileValues -
unitsProfileDepths
-
unitsProfileValues
-
profileLabel
-
-
Constructor Details
-
TimeSeriesContainer
public TimeSeriesContainer()create new empty TimeSeriesContainer
-
-
Method Details
-
setUnits
set the units (i.e. CFS)- Parameters:
dataUnits- the new units
-
getUnits
get the units- Returns:
- the data units
-
setType
set the data type- Parameters:
dataType- the new data type
-
getType
get the data type- Returns:
- the data type
-
set
Sets the data and time arrays, including start and end times, and number of values. Uses the time granularity of the HecTimeArray and will adjust (upwards) if times would exceed capacity. Also, will adjust julian base date if needed. (i.e., you can pass an array of any times, up to 5,000,000 years, and not have to compute the base or granularity yourself.)
If the start or end time are different than the first and last times in the time array, be sure to set them after this function
Time Granularity timeGranularityInSeconds Max Days Max Years One second 1 24,855 69 One minute 60 1,491,308 4,083 One hour 3600 89,478,485 244,978 One day 86400 2,147,483,647 5,879,489 (current limit for TSC) One year 31536000 (nominal) (not supported at this time) - Parameters:
dataValues-hecTimes-- Returns:
- status 0 = okay, < 0 fail
-
setTimes
set the times- Parameters:
hecTimes- the new times values- Returns:
- 0 if successful
-
getJulianDateAndTimeGranularity
- Parameters:
hecTimes-- Returns:
- [0] julianBaseDate [1] time granularity in seconds, null on error
-
set
public int set(double[] dataValues, HecTimeArray hecTimes, int julBaseDate, int timeGranularityInSeconds) Generally not a public item. Use set(double dataValues[], HecTimeArray hecTimes) instead.
Sets the data and time arrays, julian base date, and the time granularity in seconds, including start and end times, and number of values.- Parameters:
dataValues-hecTimes-julBaseDate-timeGranularityInSeconds-- Returns:
- status 0 = okay, < 0 fail
-
set
-
set
public int set(double[] dataValues, long[] minutes) Sets the data and times array, converting long minutes to int minutes, and setting the julian base date and time granularity, if required to keep within int boundary. (i.e., you not have to compute the base or granularity yourself.)- Parameters:
dataValues-minutes-- Returns:
-
setValues
public int setValues(double[] dataValues) Sets the data values array. You must set the start / end times and other parameters in other functions.
Note: This is used only for regular interval data, where a time array is not required. Always use the set(values, times) function when you have a time array.- Parameters:
dataValues-- Returns:
- status 0 = okay, < 0 fail
-
setStartTime
Sets the start time, if different than the default start time (the first value in the times array.) This can be used by irregular interval data to show that there is no data between this time and first time in the times array.
This must be called after setting times array, if not using default- Parameters:
start-
-
getStartTime
Returns the start time. This may, or may not, be different than the first time in the times array. (usually, it is the same.)- Returns:
- start time
-
setEndTime
Sets the end time, if differnt than the default end time (the last value in the times array.) This can be used by irregular interval data to show that there is no data between the last time in the times array and this value
This must be called after setting times array, if not using default -
getEndTime
Returns the end time. This may, or may not, be different than the last time in the times array. (usually, it is the same.)- Returns:
- end time
-
getTimes
Return the times array as an HecTimeArray. Accounts for julian base date and time granularity.- Returns:
- time array as HecTimeArray
-
getHecTime
Gets the time for an individual ordiante in the times array. Normally this is used when you only want one ordinate's time. If you want multiple times, use getTimes() instead.- Parameters:
index-- Returns:
-
getTimeInterval
Deprecated.usegetTimeIntervalSeconds()instead as the resolution of the returned interval is based on the timeGranularitySecondsget the time interval that the data is at- Returns:
- the time interval
-
getTimeIntervalSeconds
public int getTimeIntervalSeconds()get the time interval in seconds that the data is at- Returns:
- the time interval in seconds
-
getNumberValues
public int getNumberValues()Returns the number of values in the dataset.- Returns:
- the number of values
-
getValues
public double[] getValues()Return a copy of the data values array- Returns:
- data values
-
getValue
public double getValue(int index) Returns a single value according to the index.- Parameters:
index- the index (0 based) to get the value at- Returns:
-
getValue
Return the time series value at the specified time, do linear interpolation as necessary.
Note: A computationally intensive function; please use only when needed (i.e., don't call to retrieve all or most data.)- Parameters:
time- time of data- Returns:
- double value of data at specified time
-
setQuality
public int setQuality(int[] qualityIn) Sets the quality array. This must be the same length as the data values array- Returns:
- status 0 = okay, < 0 fail
-
getQuality
public int[] getQuality()Return a copy of the quality array- Returns:
- quality
-
setQuality7
public int setQuality7(int[][] qualityIn) -
getQualitySize
public int getQualitySize() -
getQuality7
public int[][] getQuality7()Return a copy of the quality array- Returns:
- quality
-
setCharacterNotes
-
getCharacterNotes
-
setProfile
public int setProfile(double[] profileDepths, double[][] profileValues) -
getProfileNumberDepths
public int getProfileNumberDepths() -
getProfileDepths
public double[] getProfileDepths() -
getProfileValues
public double[][] getProfileValues() -
setProfileDepthsUnits
-
setProfileValuesUnits
-
setProfileLabel
-
getProfileDepthsUnits
-
getProfileValuesUnits
-
getProfileLabel
-
getMinutes
public int[] getMinutes()Gets the times in minutes. Will convert the time array to minutes, if there is a different time granularity (rare). If there is a base date, you must account for it; use getMinutesLong() instead. See usesExtendedDates() to know if this is necessary- Returns:
- time array in minutes.
-
getMinutesLong
public long[] getMinutesLong()Gets the times in minutes. Will convert the time array to minutes, if there is a different time granularity (rare), and accounts for a base date.- Returns:
-
getMinutesLong
public long getMinutesLong(int index) Gets the time, in minutes, for a specific ordinate. Accounts for time granularity and base date- Parameters:
index-- Returns:
- time for index
-
getJulianBaseDate
public int getJulianBaseDate()Gets the base date for this object- Returns:
- julian base date (days from Jan 1, 1900)
-
setJulianBaseDate
public void setJulianBaseDate(int julBaseDate) Set the julain base date (defualt is zero).- Parameters:
julBaseDate- *
-
getTimeGranularitySeconds
public int getTimeGranularitySeconds()Gets the time granularity for the time array. This is normally 60 (seconds), but the acceptable values are:
Time Granularity timeGranularityInSeconds Max Days Max Years One second 1 24,855 69 One minute 60 1,491,308 4,083 One hour 3600 89,478,485 244,978 One day 86400 2,147,483,647 5,879,489 (current limit for TSC) One year 31536000 (nominal) (not supported at this time) - Returns:
-
setTimeGranularitySeconds
public void setTimeGranularitySeconds(int timeGranularityInSeconds) Sets the time granularity for time time array This is normally 60 (seconds), but the acceptable values are:
Time Granularity timeGranularityInSeconds Max Days Max Years One second 1 24,855 69 One minute 60 1,491,308 4,083 One hour 3600 89,478,485 244,978 One day 86400 2,147,483,647 5,879,489 (current limit for TSC) One year 31536000 (nominal) (not supported at this time) - Parameters:
timeGranularityInSeconds-
-
usesExtendedDates
public boolean usesExtendedDates()Determines if extended dates are used and times in long (or HecTime) need to be used.- Returns:
- true if so.
-
clone
clone the TimeSerieContainer -
clone
clone this TimeSeriesContainer into tsc- Parameters:
tsc- the filled in TimeSeriesContainer
-
setTimeZoneID
Set the DATA time zone identifier. This is not necessarily the location time zone, as many data sets are reported in UTC.- Parameters:
timeZoneIdentifier-
-
getTimeZoneID
get the DATA time zone identifier. This is not necessarily the location time zone, as many data sets are reported in UTC.- Returns:
- the time zone identifier
-
convertTimeZone
converts the data, start and end time to a new time zone- Parameters:
toTimezone- destination time zone
-
convertTimeZone
converts the data, start and end time to a new time zone- Parameters:
toTimezoneID- destination time zoneobserveDST- true to observe DST
-
trimToTime
-
trimToTime
-
getDataSetStats
-
minimumValue
public double minimumValue()get the minimum value of the data- Returns:
-
maxmimumValue
Deprecated.use maximumValue()get the maximum value from the time series values. retained for backwards compatibility- Returns:
- the maximum value
-
maximumValue
public double maximumValue()get the maximum value from the time series values- Returns:
- the maximum value
-
mean
public double mean()get the mean value from the time series values- Returns:
- the mean value
-
getShortName
Returns the short String representation of the time series id, the location name, version name, parameter name separated by ' ', and if it exists the version date separated by ':'- Returns:
- String
-
getVersionName
Returns the String representation of the DSS Version VERSION - SUB_VERSION or "" if the values are null- Returns:
- String
-
getParameterName
Returns the String representation of the DSS Parameter PARAMETER - SUB_PARAMETER or "" if the values are null- Returns:
- String
-
getLocationName
Returns the String representation of the DSS Location LOCATION - SUB_LOCATION or "" if the values are null- Returns:
- String
-
setCompressData
public void setCompressData(boolean compress) -
compressData
public boolean compressData() -
getAsString
get the TimeSeriesContainer as a String- Returns:
- the String representation
-
getAsXML
get the TimeSeriesContainer as a XML String- Returns:
- the XML String representation
-
removeAllMissing
public int removeAllMissing()Remove all missing values from the data array, reducing the size of the time, values, and quality arrays. Returns the resultant number of valid values.- Returns:
- int
-
makeAscending
public void makeAscending()rearrrange time and data arrays so that all times are ascending Remove any undefinded times and reset array sized to reflect Primarily for irregular interval data -
expandVerticalDatum
Returns a new TimeSeriesContainerVertDatum object constructed from this object and the vertical datum info in the supplementalInfo field of this object. The vertical datum info is removed from the supplementalInfo field of the new object.- Specified by:
expandVerticalDatumin interfaceIVerticalDatumOperations<TimeSeriesContainer,mil.army.usace.hec.metadata.VerticalDatumException> - Returns:
- Either the new object as described above or a clone of this object. In either case this object is not modified. A clone of this object is returned if it is already a TimeSeriesContainerVertDatum object, if the supplementalInfo field doesn't contain vertical datum information, or if an error occurs during the operation.
-
collapseVerticalDatum
Returns a new TimeSeriesContainer object constructed from this object, with the TimeSeiresContainerVertDatum.vdc field collapsed into vertical datum info in the supplementalInfo field (overwriting any existing vertical datum info there)- Specified by:
collapseVerticalDatumin interfaceIVerticalDatumOperations<TimeSeriesContainer,mil.army.usace.hec.metadata.VerticalDatumException> - Returns:
- Either the new object as described above or this object. In either case this object is not modified. This object is returned if it is not a TimeSeriesContainerVertDatum object or an exception occurs during the operation.
-
printToConsole
public void printToConsole()Prints time series data to System.out -
printToConsole
public void printToConsole(int maxNumberToPrint) Prints time series data to System.out- Parameters:
maxNumberToPrint- limit on how many points to print
-
allMissing
public boolean allMissing() -
hasValidProfileData
public boolean hasValidProfileData() -
setVersionDate
public void setVersionDate(mil.army.usace.hec.data.timeseries.VersionDate versionDate) sets the VersionDate- Parameters:
versionDate- the version date to be set
-
getVersionDate
public mil.army.usace.hec.data.timeseries.VersionDate getVersionDate()gets the VersionDate- Returns:
- VersionDate
-
getFullVersionedName
Returns the String representation the time series id, and if it exists the version date separated by ':'- Returns:
- String
-
getVerticalDatumMetadata
-