HEC-DSS provides for a type of time series data that is not associated with a specific time, but rather a sequence that may or may not be associated with relative times. This includes, for example, daily average temperatures, which are associated with a specific day of the year, but not a specific year. Also included are unit hyrdographs, which are a sequence of flows in time, but do not include a specific time associated with the data.


These different time sequences are called "Time Patterns" in HEC-DSS and follow all HEC-DSS time series conventions, except the "D" part of the pathname is "TS-Pattern". Time pattern data may be regular interval or irregular interval; it may have a specified period (such as one year), or just a number of values from an unspecified start (such as 120 hourly values for a unit hydrograph).


The "E"part of time pattern pathnames still contains the time interval or block length; for example the E part for daily average temperatures would be "1Day", and the record would contain 365 values. An hourly unit hydrograph would have an E part of "1Hour" and the length of that record would be the entire data set for that hydrograph. Other types of time pattern data may be irregular interval, and a block length chosen that would encompass the entire data set (such as "IR-Month" for a non-uniform hydrograph).


When you use time pattern data, you do not set a start or end time; all data is assumed to be contained in one record, which is fully defined by the pathname. When you time pattern with irregular interval data, the time time array is to be given in minutes (or seconds) from the first point (so, hourly stored as irregular pattern would be "0, 60, 120, 180, …").


Time pattern data resembles paired data, where the ordinate is a time value, but is stored using time series conventions. It is recognized that some time pattern data, such as unit hydrographs, may also be stored using paired data convention. However, paired data is a different data type and most time series functions (e.g., math functions) will not work with it, whereas they will work with pattern data. Also, sometimes time pattern data is stored for the year 3000, which is often used for stastical values. Indeed, time pattern data is usually plotted using the year 3000 for the time axis. It is up to the user's description choose the most appropriate storage.


Example: Time Pattern with Regular Interval


import java.util.Vector;
import javax.swing.UIManager;

import hec.dataTable.HecDataTableFrame;
import hec.gfx2d.G2dDialog;
import hec.heclib.dss.*;
import hec.io.DataContainer;
import hec.io.TimeSeriesContainer;

//  Create a time pattern (from an existing data set)

public class ExampleTimePattern1 {

	public static void main (String args[])  {

		try {
			javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception ignore) {}
		
		//  First, get a data set that we can use
		TimeSeriesContainer tsc = new TimeSeriesContainer();		
		tsc.setName("//Sacramento/TEMP-MAX/01JAN1980/1Day/Obs/");
		HecTimeSeries dssTimeSeries = new HecTimeSeries();
		//  This is the "sample.dss" file included with HEC-DSSVue, converted to version 7
		dssTimeSeries.setDSSFileName("C:/temp/Sample7.dss");
		int status = dssTimeSeries.read(tsc, true);
		dssTimeSeries.done();		
		if (status != 0) return;
		
		//  Now save it as a time pattern
		TimeSeriesContainer tsc2 = new TimeSeriesContainer();		
		tsc2.setName("//Sacramento/TEMP-MAX/TS-Pattern/1Day/Daily Average/");
		tsc2.setValues(tsc.getValues());
		tsc2.setUnits("Deg F");
		tsc2.setType("Per-Aver");
		//  Note - no starting or ending times set!  (Just data)
		dssTimeSeries = new HecTimeSeries();
		dssTimeSeries.setDSSFileName("C:/temp/Example7.dss");
		status = dssTimeSeries.write(tsc2);
		
		//  Now read it back and display
		TimeSeriesContainer tsc3 = new TimeSeriesContainer();		
		tsc3.setName("//Sacramento/TEMP-MAX/TS-Pattern/1Day/Daily Average/");
		dssTimeSeries = new HecTimeSeries();
		dssTimeSeries.setDSSFileName("C:/temp/Example7.dss");
		status = dssTimeSeries.read(tsc3, true);
		dssTimeSeries.done();		
		if (status != 0) return;

		//  Show in a plot
		Vector<DataContainer> v = new Vector<DataContainer>();
		v.add(tsc3);
		hec.gfx2d.G2dDialog plot =  new G2dDialog(null, "My Plot", false, v);
		plot.setVisible(true);

		//  Show in a table
		 HecDataTableFrame tableFrame = new HecDataTableFrame(null);
		 tableFrame.setData(tsc3);
		 tableFrame.setVisible(true);

		HecDataManager.closeAllFiles();  //  Only at the end of the program
	}
}

JAVA




Example: Time Pattern with Irregular Interval

import java.util.Vector;
import javax.swing.UIManager;
import hec.dataTable.HecDataTableFrame;
import hec.gfx2d.G2dDialog;
import hec.heclib.dss.*;
import hec.io.DataContainer;
import hec.io.TimeSeriesContainer;

//  A time pattern example for a unit hydrograph with 
//  irregular-interval time series data
public class ExampleTimePattern2 {

	public static void main (String args[])  {

		try {
			javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception ignore) {}
		
		//  Write a irregular interval data set.  Gen up the data and times
		//  Note - this could also be stored with a "1Hour" E part
		double values[] = new double[200];
		long times[] = new long[200];
		for (int i=0; i<100; i++) {
			values[i] = (double)i * 5;
			times[i] = (i + 1) * 60;
		}
		for (int i=100; i<200; i++) {
			values[i] = 500.0 + (double)(100 - i) * 5.0;
			times[i] = (i + 1) * 60;
		}
		TimeSeriesContainer tsc = new TimeSeriesContainer();
		//  No absolute times are specified, just relative
		tsc.set(values, times);
		tsc.setName("/Basin/Location/Flow/TS-Pattern/Ir-Month/Unit Hydrograph/");		
		tsc.setUnits("CFS");
		tsc.setType("Inst-Val");
		
		HecTimeSeries dssTimeSeries = new HecTimeSeries();
		dssTimeSeries.setDSSFileName("C:/temp/Example7.dss");		
		int status = dssTimeSeries.write(tsc);
		dssTimeSeries.done();		
		if (status != 0) return;
		
		//  Read data
		TimeSeriesContainer tscRead = new TimeSeriesContainer();		
		tscRead.setName("/Basin/Location/Flow/TS-Pattern/Ir-Month/Unit Hydrograph/");
		HecTimeSeries dssTimeSeriesRead = new HecTimeSeries();
		dssTimeSeriesRead.setDSSFileName("C:/temp/Example7.dss");		
		status = dssTimeSeriesRead.read(tscRead, false);
		dssTimeSeriesRead.done();		
		if (status != 0) return;

		//  Show in a plot
		Vector<DataContainer> v = new Vector<DataContainer>();
		v.add(tscRead);
		hec.gfx2d.G2dDialog plot =  new G2dDialog(null, "Unit Hydrograph", false, v);
		plot.setVisible(true);

		//  Show in a table
		HecDataTableFrame tableFrame = new HecDataTableFrame(null);
		tableFrame.setData(tscRead);
		tableFrame.setVisible(true);
		HecDataManager.closeAllFiles();
	}
}

JAVA