Class HecTimeSeries

All Implemented Interfaces:
HecDssListener, Serializable, Cloneable, EventListener
Direct Known Subclasses:
DSSTimeSeriesTranslator, HecTimePattern, HecTimeSeriesMath

public class HecTimeSeries extends HecTimeSeriesBase implements Serializable
HecTimeSeries is used to read and write time series data to DSS. TimeSeriesContainers are used for input and output transfer objects.
See Also:
  • Field Details

    • _timeZone

      protected TimeZone _timeZone
  • Constructor Details

    • HecTimeSeries

      public HecTimeSeries()
    • HecTimeSeries

      public HecTimeSeries(String DssFileName)
  • Method Details

    • ztsRetrieve

      public int ztsRetrieve(TimeSeriesContainer tsc, String pathname, HecTime startDateTime, HecTime endDateTime, boolean retrieveQualityAndNotes, int retrieveFlag)
    • computeTimes

      protected void computeTimes(TimeSeriesContainer tsc)
    • ztsStore

      public int ztsStore(TimeSeriesContainer tsc)
    • ztsStore

      public int ztsStore(TimeSeriesContainer tsc, int storageFlag)
    • expandProfileContainer

      public static Vector<TimeSeriesContainer> expandProfileContainer(TimeSeriesContainer profileContainer)
      converts profile data from a TimeSeriesContainer into a Vector of TimeSeries containers
      Parameters:
      profileContainer -
      Returns:
    • contractProfileContainer

      public static TimeSeriesContainer contractProfileContainer(Vector<TimeSeriesContainer> containers)
    • setRetrieveAllTimes

      public void setRetrieveAllTimes(boolean retrieveAllTimes)
      Retrieve data for all times in the data base This ignores the start and end times, and searches all records for this time series sequence. The start and end times are retained as startTime() and endTime()
    • setRegularIntervalStorePlan

      public void setRegularIntervalStorePlan(int regularStorePlan)
      This is the "plan" variable in zsrtsx
      Parameters:
      regularStorePlan - int A flag indicating if existing data should be written over or not: regularStorePlan = 0 Always replace data (default) regularStorePlan = 1 Only replace missing data. regularStorePlan = 2 Write regardless, even if all missing data. regularStorePlan = 3 If a record is all missing, do not write it and delete it from disk if it exists. regularStorePlan = 4 Do not allow a missing input data to replace a valid data piece.
    • setIrregularIntervalInFlag

      public void setIrregularIntervalInFlag(int inFlag)
      This is the "inFlag" variable in zsitsx
      Parameters:
      inFlag - int A flag indicating if existing data should be written over or not: inFlag = 0 Merge Data (replaces data with coincident times) inFlag = 1 Replace Data (replaces the entire time window)
    • setStoreDoubles

      public void setStoreDoubles(boolean storeDoubles)
    • getStoreDoubles

      public boolean getStoreDoubles()
    • getSupplementalInfo

      public String getSupplementalInfo()
    • read

      public int read()
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • setReadPreviousSubsquent

      public void setReadPreviousSubsquent(boolean readPrevious, boolean readSubsequent)
      For irregular-interval data, this setting will indicate if the value previous to the set time window should also be read, and if the value after the time window should be read. This is often needed for interpolating a first or last value. A time window must be set to use this function
      Parameters:
      readPrevious - boolean
      readSubsequent - boolean
    • getData

      public int getData(doubleArrayContainer values)
    • getData

      public int getData(HecDoubleArray values)
    • getTimes

      public int getTimes(intArrayContainer timesAsInts)
    • getTimes

      public int getTimes(HecTimeArray timeArray)
    • getFlags

      public int getFlags(intArrayContainer flags)
    • read

      public int read(doubleArrayContainer values)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(doubleArrayContainer values, int unitSystem)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(HecTimeArray timeArray, doubleArrayContainer values)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(HecTimeArray timeArray, doubleArrayContainer values, int unitSystem)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(HecTimeArray timeArray, HecDoubleArray values)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(HecDoubleArray values)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(HecTimeArray timeArray, HecDoubleArray values, int unitSystem)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(intArrayContainer timeArray, doubleArrayContainer values)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(intArrayContainer timeArray, doubleArrayContainer values, int unitSystem)
      Deprecated. Use read(TimeSeriesContainer) instead This read is for backwards compatibility
    • read

      public int read(TimeSeriesContainer timeSeriesContainer, boolean removeMissing)
    • read

      public int read(TimeSeriesCollectionContainer timeSeriesCollectionContainer, boolean removeMissing)
    • read

      public int read(TimeSeriesCollectionContainer timeSeriesCollectionContainer, boolean removeMissing, boolean getCollectionTimes)
    • setData

      public void setData(double[] values, int numberToWrite)
      Typical use of write functions.. setDSSFileName(filename); setPathname(pathnmae); Regular Interval Time Series data: setStartTime(startTime); setData(dataValues, numberToWrite); write(); Irregular Interval setData(dataValues, numberToWrite); setTimes(timeArray); write();
    • setData

      public void setData(double[] values)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • setData

      public void setData(HecDoubleArray values)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • setTimes

      public int setTimes(int[] times)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • setTimes

      public int setTimes(int[] times, int ntimes)
    • setTimes

      public int setTimes(HecTimeArray times)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • setFlags

      public int setFlags(int[] flags)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • setFlags

      public int setFlags(int[] flags, int nflags)
    • write

      public int write()
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(boolean writeToDisk)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(double[] values, int numberToWrite, boolean writeToDisk)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(int[] times, double[] values, int numberToWrite, boolean writeToDisk)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(HecDoubleArray values, boolean writeToDisk)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(HecTimeArray times, double[] values, boolean writeToDisk)
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • write

      public int write(TimeSeriesContainer timeSeriesContainer)
    • write

      public int write(TimeSeriesCollectionContainer timeSeriesCollectionContainer)
    • saveDataToDisk

      public int saveDataToDisk()
      Deprecated. Use write(TimeSeriesContainer) instead This method is for backwards compatibility
    • DSSFileName

      public String DSSFileName(boolean useDefault)
    • timeWindowNumber

      public int timeWindowNumber()
    • removeLeadingTrailingMissing

      public static int removeLeadingTrailingMissing(HecTimeArray timeArray, HecDoubleArray arrayX)
    • getCoincidentTimes

      public static int getCoincidentTimes(List<TimeSeriesContainer> timeSeriesContainers)
      Take a list of TimeSeriesContainers, and remove all data that is not coincident in time with all other containers in the list. For example, one data set is hourly, and the other at six hours, this will return both data sets at six hour times (coincident times). The data and times that are not coincident will be removed from the containers. This will not change the identified interval or E part, it is not dependent on the data type (e.g., inst or average). It will change the number of values and length of the time, values and quality arrays.
      Parameters:
      timeSeriesContainers - List
      Returns:
      int
    • intIndex

      protected static int intIndex(int[] intArray, int intValue)
      returns location of intValue in array intArray returns -1 if not found.
      Parameters:
      intArray - The array to search
      intValue - The value to search for
      Returns:
      The lowest index at which the value occurs, or -1 if not found
    • status

      public void status()
      Overrides:
      status in class HecTimeSeriesBase
    • getStatistics

      public int getStatistics(doubleContainer minimum, HecTime minimumTime, doubleContainer maximum, HecTime maximumTime, doubleContainer average, intContainer totalNumberValues, intContainer numberMissing)
    • value

      public double value(HecTime newTime, intContainer status)
    • incrementalValue

      public double incrementalValue(HecTime valueStartTime, HecTime valueEndTime, intContainer status)
    • getSeriesPathnameRange

      public int getSeriesPathnameRange(stringContainer firstPath, stringContainer lastPath, int searchOption)
      Get the first and last pathnames for an entire time series data set For an exhaustive search (which may be slower), set the searchOption to 0. When it is known that there are few or no missing pathnames in the series, set this to the search limit (on both sides) of pathnames found. Typically a number like 10 is good. For example, if you have hourly data (in blocks of months), this would work for data sets that had no more than 10 months of sequential missing data. If this number is above about 25, it probably would be better to do an exhaustive search, unless the file is very large (>10,000 pathnames) Returns the number of records found in the data set
    • getStandardPathDate

      public static String getStandardPathDate(String pathname)
    • getSeriesTimeRange

      public int getSeriesTimeRange(HecTime startRange, HecTime endRange, int searchOption)
      Get the date and time of the first piece and last piece of data in an entire time series set (not just the pathname) For an exhaustive search (which may be slower), set the searchOption to 0. When it is known that there are few or no missing pathnames in the series, set this to the search limit (on both sides) of pathnames found. Typically a number like 10 is good. For example, if you have hourly data (in blocks of months), this would work for data sets that had no more than 10 months of sequential missing data. If this number is above about 25, it probably would be better to do an exhaustive search, unless the file is very large (>10,000 pathnames) Returns status of 0 = OK, ERROR = error
    • reset

      public void reset()
      Get information about an individual time series record (pathname) This includes the time of the first and last values in the record, and the records units and type. This is for a single record, not an entire data set. Returns status of 0 = OK, ERROR = error
    • clear

      public void clear()
      Overrides:
      clear in class HecDataManager
    • resetArrayTime

      public void resetArrayTime()
    • getTimeZone

      public TimeZone getTimeZone()
      Returns a SimpleTimeZone object for the time zone set If no time zone, returns null
    • hasTimeZone

      public boolean hasTimeZone()
    • setTimeZone

      public void setTimeZone(TimeZone timeZone)
    • removeTimeZone

      public void removeTimeZone()
    • getCollectionList

      public String[] getCollectionList(String seedPathname)
      Description copied from class: HecDSSFileAccess
      Returns a string array of all the pathnames in a single collection in a DSS file. Any of the pathnames from the collection can be used as a seed (defining the remainder of the pathname). The sequence for the seed does not have to exist (i.e., you can use "000000", even if there is not a pathname with the sequence 000000.
      Overrides:
      getCollectionList in class HecDSSFileAccess
      Parameters:
      seedPathname - String
      Returns:
      String[]
    • arraySizeOk

      protected boolean arraySizeOk(int arraySize)
    • retrieveData

      protected int retrieveData(int unitSystem)
    • prepareForWrite

      protected int prepareForWrite()
    • flushToDisk

      protected int flushToDisk()
    • updateArrayTime

      protected int updateArrayTime(int number)
    • getInterval

      protected int getInterval(String ePart)
    • checkTimeWindow

      protected int checkTimeWindow(boolean readData)
    • getBlockStartDate

      protected int getBlockStartDate(int jul, int[] block, int[] year, int[] month, int[] day)
    • getDesiredArraySize

      protected int getDesiredArraySize()