Skip to content

TSTool / Command / RelativeDiff


A RelativeDiff command creates a new relative difference time series, computed by subtracting the time series and then dividing by one of the time series. This is useful when analyzing the relative magnitudes of two time series over time. Most of the properties for the new time series are the same as the first time series. The alias for the result can be referenced by other commands. The divisor can be either of the time series. The result is set to missing if either time series value is missing or the divisor is zero.

Command Editor

The following dialog is used to edit the command and illustrates the syntax of the command.


RelativeDiff Command Editor (see also the full-size image)

Command Syntax

The command syntax is as follows:


The following older command syntax is updated to the above syntax when a command file is read:

TS Alias = RelativeDiff(Parameter=Value,...)

Command Parameters

Parameter            Description Default                           
The time series identifier or alias for the first time series. None – must be specified.
The time series identifier or alias for the second time series (subtracted from the first). None – must be specified.
Indicates whether the first time series is the divisor (DivideByTS1) or the second time series is the divisor (DivideByTS2). None – must be specified.
The alias to assign to the time series, as a literal string or using the special formatting characters listed by the command editor. The alias is a short identifier used by other commands to locate time series for processing, as an alternative to the time series identifier (TSID). None – must be specified.


See the automated tests.

A sample command file to process a time series from the State of Colorado’s HydroBase database is as follows:

# (1912-1998) RIO GRANDE AT ALAMOSA, CO.  DWR  Streamflow  Monthly
# (1890-1998) RIO GRANDE NEAR DEL NORTE, CO.  DWR  Streamflow  Monthly

The input time series for the command are shown in the following figure:

RelativeDiff GraphData

Data for the RelativeDiff Command

The results of processing the commands are shown in the following figure:

RelativeDiff Graph

Results of RelativeDiff Command


See Also