slot_agg_list {RWDataPlyr} | R Documentation |
A class to control how RiverWare data are aggregated
Description
"slot_agg_list"
is a class that contains a set of RiverWare slots, which
rdf file they are found in, and a set of keywords that are used to control
how getDataForAllScens()
aggregates RiverWare data.
Usage
slot_agg_list(x)
Arguments
x |
Either an Nx4 character matrix or a character with an absolute or relative path to a csv file. |
Details
The slot_agg_list
class, contains a list that includes: which rdf file to
find each slot in, how to aggregate and process the slot data, and any
thresholds or scaling factors. The function can either read in a csv file or
start from an N x 4 or N x 5 string matrix (the 5th column is optional).
The csv file and the matrix should be in the form of an Nx4 or Nx5 matrix.
Each row is a single slot, aggregation, and threshold combination. If you
want to compare a single slot value to multiple thresholds, it needs to have
one row for each threshold. The first column is the rdf the slot is found in.
The second column is the slot name. The third column is the aggregation
method that will be applied to the slot (see below for a list of the
aggregation methods). The fourth column is a scaling factor or threshold to
compare the slot data to. The fifth column is an optional column; if
specified, the 5th column will be used for the variable name for the
data.frame created by getDataForAllScens()
. If it is not specified
the variable name will be created by concatenating the slot, aggregation
method, and threshold/scaling factor using '_' to separate the columns.
Below is an example table. All values should be strings except for NA
,
if specified as a matrix in R.
rdf | Slot | Aggregation Method | Threshold or Scaling Factor | Variable Name (optional) |
'KeySlots.rdf' | 'Mead.Pool Elevation' | 'EOCY' | NA | Mead EOCY Elevation |
'KeySlots.rdf' | 'Mead.Pool Elevation' | 'AnnMinLTE' | '1100' | Mead < 1,100 |
'KeySlots.rdf' | 'Mead.Pool Elevation' | 'AnnMinLTE' | '1060' | Mead < 1,060 |
'Other.rdf' | 'Powell.Outflow' | 'AnnualSum' | '0.001' | Powell Annual Release |
The above table lists each slot, the rdf the slot is saved in, the summary
function, the threshold to be used to scale the data by or compare the data
to, and an optionally specified variable name. The threshold and scaling
factors are described in more detail below. For example, the first row will
result in compiling all end-of-December values for Mead's pool elevation.
The data will not be scaled, and getDataForAllScens()
will look in
KeySlots.rdf for the "Mead.Pool Elevation" slot. The second row will find
the annual minimum Mead pool elevation and see if it is less than or equal
to 1,100' feet in the second line and less than or equal to 1,060' feet in
the third row.
To scale the data by a value less than 1, use decimals rather than fractions,
as shown in the fourth row. If the Variable Name column was not specified,
the variable name for the first row would be Mead.Pool Elevation_EOCY_1
NA
is replaced with a 1 when constructing the variable names.
See the Aggregation Methods section for available aggregation methods.
Value
A slot_agg_list
object.
Aggregation Methods
The available aggregation methods are as follows. The behavior of the
"Threshold or scaling factor" are described and a bold "Threshold" or
"Scaled" indicates which is used by the aggregation method. For scaling
factors, a value of NA
will not scale the data.
- 'AnnMin'
Returns the minimum annual scaled value.
- 'AnnMax'
Returns the maximum annual scaled value.
- 'AnnualSum'
Returns the annual scaled sum.
- 'AnnMinLTE'
Checks to see if the annual minimum value is less than or equal to a threshold. Returns 1 if it is less than or equal to the threshold and 0 otherwise.
- 'AnnualRaw'
Returns the annual scaled data. This aggregation method should only be used if the rdf file contains only annual data. For rdf files that include monthly data and only an annual value is desired, the EOCY aggregation method should be used. This differs from the Monthly aggregation method, only in the timestep naming.
- 'BOCY'
Beginning-of-calendar year values are reported and scaled. Any values that are NaNs are changed to 0s.
- 'EOCY'
End-of-calendar year values are reported and scaled. Any values that are NaNs are changed to 0s.
- 'EOCYGTE'
Checks to see if the end-of-calendar year values are greater than or equal to a threshold. Returns 1 if it is greater than or equal to the threshold and 0 otherwise.
- 'EOCYLTE'
Checks to see if the end-of-calendar year values are less than or equal to a threshold. Returns 1 if it is less than or equal to the threshold and 0 otherwise.
- 'EOWY'
End-of-water year values are reported and scaled. Any values that are NaNs are changed to 0s.
- 'Monthly'
Returns the monthly scaled data.
- 'WYMaxLTE'
Checks to see if the maximum water year value is less than or equal to a threshold. Returns 1 if it is less than or equal to the threshold and 0 otherwise. This can be used to determine if an entire water year is below a threshold. The water year is defined as October through September of the next year. For the first year, only January through September are evaluated as RiverWare does not typically export pre-simulation data.
- 'WYMinLTE'
Checks to see if the minimum water year value is less than or equal to a threshold. Returns 1 if it is less than or equal to the threshold and 0 otherwise. The water year is defined as October through September of the next year. For the first year, only January through September are evaluated as RiverWare does not typically export pre-simulation data.
See Also
Examples
# read in a csv file that contains the data
slot_agg_list(
system.file('extdata','SlotAggTable.csv',package = 'RWDataPlyr')
)
# or specify as a matrix
slot_agg_matrix <- matrix(
c("KeySlots.rdf", "Powell.Outflow", "AnnualSum", ".001", "powellAnnRel",
"KeySlots.rdf", "Mead.Pool Elevatoin", "AnnMinLTE", "1050", "meadLt1050"),
nrow = 2,
byrow = TRUE
)
slot_agg_list(slot_agg_matrix)