TSTool / Command / ResequenceTimeSeriesData
ResequenceTimeSeriesData command resequences data in time series by
shifting/shuffling/repeating values from one year to another,
creating new time series for each time series.
For example, January 1950 might be shifted to January 1990.
This command is useful for generating synthetic time series by resequencing historical data.
The following constraints apply to the command as currently implemented:
- Processing by default occurs by calendar year, with the sequence specified as calendar years.
If an alternate output year type is used (see the
OutputStartyear is considered to be consistent with the output year type.
- The sequence of years must currently be supplied as a column of years in a table (rows of years may be added in a future enhancement).
- Full start and end years are required, matching the output year type.
- Currently the command can only be applied to month interval data.
For a daily data interval, several technical issues must be resolved before the feature can be implemented:
- If a short year (i.e., non-leap year with 365 days) is transferred to a long year (i.e., a leap year with 366 days), the first day after the short year is used for the 366th day during the transfer. What to do if the year being transferred is the last in the data set and no more years are available for the 366th day – repeat the last day?
- If a long year (i.e., leap year with 366 days) is transferred to a short year (i.e., a non-leap year with 365 days), the 366th day in the leap year is not transferred.
- The original period is by default retained in the output time series.
For example, if the original data are 1937 to 1997,
the resequenced data will also be in a time series with a period 1937 to 1997.
OutputStartparameter can be used to shift the start year of output.
The command is designed to work with a table that provides sequence information.
For example, see the
command and the example shown below.
The following dialog is used to edit the command and illustrates the syntax of the command.
ResequenceTimeSeries Command Editor (see also the full-size image)
The command syntax is as follows:
||Indicates the list of time series to be processed, one of:
||The time series identifier or alias for the time series to be processed, using the
||The ensemble to be processed, if processing an ensemble. Can be specified using
|The identifier for the sequence table to use, which indicates the dates to use when resequencing data (e.g., list of years for data sequence). For example, see the
||None – must be specified.|
|The column name containing the sequence information. Note that the input table must have column names in a header record.||None – must be specified.|
||The first data row number (1+) containing the first year in the new sequence.||Use all rows.|
||The last data row number (1+) containing the first year in the new sequence.||Use all rows.|
||The output year type, indicating the year extent for the resequencing, one of:
||The output start as a four-digit year that is consistent with
||Same as the original input data or use the global output start if specified. The output months will be adjusted for the output year type.|
||The new scenario to assign to the created time series, resulting in a unique TSID.||Not specified, but a new scenario and/or alias must be specified.|
||Alias to assign to the output time series. See the
||Not specified, but a new scenario and/or alias must be specified.|
See the automated tests.
The following example:
- Reads a list of time series from a StateMod model file.
- Reads a sequence of years from a delimited file.
- Resequences the StateMod time series data.
- Writes the resequenced file to a new StateMod file.
# Read all demand time series… ReadStateMod(InputFile=”..\StateMod\gunnC2005.xbm”) # Read the sequence of years to use… Table 0001HK0101 = ReadTableFromDelimitedFile(InputFile=”0001HK0101.csv”) # Resequence the StateMod time series… ResequenceTimeSeriesData(TSList=AllTS,TableID=”0001HK0101”, TableColumn=”Trace1”,NewScenario=”KNN0101”,Alias=”%L-KNN0101”) # Write the resequenced data for StateMod WriteStateMod(TSList=AllMatchingTSID,TSID=”*KNN*”,OutputFile=”..\StateMod0101\gunnC2005.xbm”)
The year sequence is specified in a file similar to the following.
# Some comments “Trace1”,”Trace2”,… 1905,1967,… 1920,1943,… etc.
Variations on the example can be implemented, for example, to process output products after the run.