PrevTSValue

Syntax

    PrevTSValue
or PrevTSValue(Branch:VariableName)
or PrevTSValue(Branch:VariableName[Scale Unit])
or PrevTSValue(Branch:VariableName[Scale Unit, Dimension = Item])
or PrevTSValue(Branch:VariableName[Scale Unit, Dimension = Item], TimeStepsPrevious)
or PrevTSValue(Branch:VariableName[Scale Unit, Dimension = Item], TimeStepsPrevious,EndOfPreviousTSInterval)
or PrevTSValue(Branch:VariableName[Scale Unit, Dimension = Item], TimeStepsPrevious,EndOfPreviousTSInterval, FunctionToCompute)
or PrevTSValue(Branch:VariableName[Scale Unit, Dimension = Item], TimeStepsPrevious,EndOfPreviousTSInterval, FunctionToCompute, FunctionParameter)
or PrevTSValue(MODFLOWResultVariableName[Layer, Row, Column], TimeStepsPrevious,...)

Description

The PrevTSValue function can be used in two ways. One is to return results calculated in previous timesteps. The other is to return past or future values from Data variables. The parameters are:

Branch:VariableName[Scale Unit, Dimension = Item]: Name of branch and variable from which to read previous results. If omitted, then the result will be the value from the previous timestep of the current Branch:Variable.  Scale and Unit are optional, and can be used to convert to any unit of the same unit class (e.g., volume, area, flow).  A few result variables have extra "dimensions," e.g., source, water quality constituent, crop or cost/benefit type.  For these, you can specify the dimension inside the square brackets, after the unit.  If omitted, WEAP will sum up the values across all items, e.g., for costs, it will add Capital Costs, Operating Costs and Benefits.

TimeStepsPrevious: Number of previous time steps to look back. For example, a value of 1 returns the result from the previous time step, 2 returns the value from 2 time steps previous to the current time step, etc.. If omitted, the function will default to 1 time step previous.

EndOfPreviousTSInterval: The other end of the interval of time steps previous to use. For example, if TimeStepsPrevious is 1 and EndOfPreviousTSInterval is 4, then results are returned from the previous 4 time steps. If TimeStepsPrevious is 2 and EndOfPreviousTSInterval is 5, then results are returned from the interval from 2 time steps previous to 5 time steps previous (a total of 4 time steps). If omitted, the function will default to just the one time step specified by TimeStepsPrevious.

FunctionToCompute: Operation to execute on results: Sum, Average, Min, Max, Median, CV, Percentile, AverageAnnualSum, CountAbove, CountEqual, CountBelow. The function can be specified either by its name or by its numerical code: 0 for Sum, 1 for Average, 2 for Minimum, 3 for Maximum, 9 for Median, 8 for CV (coefficient of variation), 7 for percentile, 10 for AverageAnnualSum, 4 for CountAbove, 5 for CountEqual and 6 for CountBelow. If omitted, the operation will be Sum.  If any of the previous timestep values are the MissingValue (-9999), then the operation (sum, average, ...) will also equal the MissingValue.

FunctionParameter: If FunctionToCompute is Percentile, specify percentile to compute (from 0 to 100).  If FunctionToCompute is CountAbove, count the number of daily values in each month that are greater than or equal to the FunctionParameter.  If FunctionToCompute is CountBelow, count the number of daily values in each month that are less than or equal to the FunctionParameter.  If FunctionToCompute is CountEqual, count the number of daily values in each month that are exactly equal to the FunctionParameter.  If FunctionParameter omitted, 0 will be used.

MODFLOWVariableName[layer, row, column]: To access MODFLOW results for individual cells, replace Branch:VariableName with MODFLOWVariableName[layer, row, column].

Examples

If( PrevTSValue > 15, PrevTSValue / 2, PrevTSValue + 1)
This example looks at the previous value of the current branch:variable. If it is greater than 15, then reduce by half. Otherwise, increase by 1.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume)
This example calculates Central Reservoir's storage from the previous month.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million m^3, 3)
This example calculates Central Reservoir's storage from three months ago, in million cubic meters.

PrevTSValue(Demand Sites\South City:Pollution Generation[kg, WQ Constituent=BOD])
This example calculates the amount of BOD generated by South City.

PrevTSValue(Supply and Resources\River\Weaping River\Returns\Return Flow from South City:Pollution Loads[kg, Source=South City, WQ Constituent=BOD])
This example calculates the amount of BOD that flows into the Weaping River return flow node from South City.  (There is also inflow from South City WWTP, but it won't be included.)

PrevTSValue(Demand Sites\Agriculture West:Supply Delivered[m^3])
This example calculates the amount of supply delivered to Agriculture West from all sources.

PrevTSValue(Demand Sites\South City:Net Benefit[$, Cost/Benefit Type=Operating Cost])
This example calculates the amount of operating cost at South City.

PrevTSValue(Demand Sites and Catchments:Production[kg, Crop=Corn])
This example calculates the total annual production of the PGM crop named "Corn" for all catchments.

PrevTSValue(Demand Sites and Catchments\Big Farm:Crop Yield[kg])
This example calculates the total annual yield of all crops and branches for the catchment named "Big Farm."

PrevTSValue(Demand Sites\South City:Unmet Demand, 1, 4)
This example calculates the sum of all unmet demands at South City for the previous 4 months.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 4, Average)
This example calculates the storage in Central Reservoir, averaged over the previous four months (a moving average).

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million Cubic Meter], 1, 4, Minimum)
This example calculates the minimum storage in Central Reservoir over the previous four months in million cubic meterst.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 6, Maximum)
This example calculates the maximum storage in Central Reservoir over the previous six months.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 12, Median)
This example calculates the median (50% percentile) storage in Central Reservoir over the previous twelve months.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 12, Percentile, 5)
This example calculates the 5% percentile storage value in Central Reservoir over the previous twelve months.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million Cubic Meter], 1, 12, CountAbove, 300)
This example counts the number of the previous twelve months in which the storage value in Central Reservoir was greater than or equal to 300 Million Cubic Meters.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million Cubic Meter], 1, 12, CountBelow, 250)
This example counts the number of the previous twelve months in which the storage value in Central Reservoir was less than or equal to 250 Million Cubic Meters.

PrevTSValue(Cell Head[1,57,30], 1, 12, Minimum)
This example calculates the minimum groundwater head elevation of cell at layer 1, row 57, column 30 over the previous twelve months, as calculated by a linked MODFLOW model.

Other examples of MODFLOW results:

PrevTSValue(Recharge Volume[1,7,7], 1, 3, Sum)
PrevTSValue(Constant Head Flow Volume[1,17,3])
PrevTSValue(Flow Right Face Volume[2,10,14])
PrevTSValue(Evapotranspiration Volume[1,16,3])
PrevTSValue(Leakage Depth to River[1,14,14])

This function can also be used to return previous values from data variables found in the Data view, such as the "Top of Conservation" for reservoirs.

PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\North Reservoir:Top of Conservation, 1, 4, Average).
This example returns the average of the Top of Conservation variable for the North Reservoir over the four previous months.

The function can also be used to "look ahead" at a data variable. In this case, specify the time steps to look ahead as negative numbers for TimeStepsPrevious and EndOfPreviousTSInterval (because a negative number of timesteps previous means a positive number of timesteps ahead).

PrevTSValue(Supply and Resources\River\Weaping River:Headflow, -1, -4, Average)
This example returns the average headflow over the future four months.

Tip

To find out which result variables are available to use with PrevTSValue, go to the Branches tab of the Expression Builder, and drag a branch, such as a reservoir or groundwater node, to the expression area at the bottom. A menu will appear that lists all the available variables -- data variables first, followed by the result variables. The result variables will include the notation "calculated result from previous timestep."