TSTool / Command / RelativeDiff
Overview
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:
RelativeDiff(Parameter="Value",...)
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 |
---|---|---|
TSID1 required |
The time series identifier or alias for the first time series. | None – must be specified. |
TSID2 required |
The time series identifier or alias for the second time series (subtracted from the first). | None – must be specified. |
Divisor required |
Indicates whether the first time series is the divisor (DivideByTS1 ) or the second time series is the divisor (DivideByTS2 ). |
None – must be specified. |
Alias required |
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. |
Examples
See the automated tests.
A sample command file to process a time series from the State of Colorado’s HydroBase database is as follows:
StartLog(LogFile="Example_RelativeDiff.log")
SetOutputPeriod(OutputStart="01/1912",OutputEnd="12/1998")
# (1912-1998) RIO GRANDE AT ALAMOSA, CO. DWR Streamflow Monthly
ReadTimeSeries(Alias=”Alamosa”,"08223000.DWR.Streamflow.Month~HydroBase")
# (1890-1998) RIO GRANDE NEAR DEL NORTE, CO. DWR Streamflow Monthly
ReadTimeSeries(TSID="08220000.USGS.Streamflow.Month~HydroBase",Alias=”DelNorte”)
RelativeDiff(TSID1="DelNorte",TSID2="Alamosa",Divisor=DivideByTS1,Alias=”RelativeDiff”)
The input time series for the command are shown in the following figure:
Data for the RelativeDiff
Command
The results of processing the commands are shown in the following figure:
Results of RelativeDiff
Command
Troubleshooting
See Also
Normalize
command