rwslot_annual_sum {RWDataPlyr} | R Documentation |
Simple aggregation functions for monthly matrix data
Description
A family of functions that take a matrix containing monthly data (months by
traces) that has a "timespan" attribute, annualizes the data by summing, or
finding the minimum or maximum monthly values. Returns a years by traces
matrix. Matrices returned by rdf_get_slot()
have the timespan attribute
added to them.
Usage
rwslot_annual_sum(rwslot, multFactor = 1)
sumMonth2Annual(rwslot, multFactor = 1)
rwslot_annual_min(rwslot)
getMinAnnValue(rwslot)
rwslot_annual_max(rwslot)
getMaxAnnValue(rwslot)
rwslot_fwaac(mass, flow)
Arguments
rwslot |
A matrix (months by traces) such as that returned by
|
multFactor |
A factor the annual sum will be multiplied by. Can be used to convert from flow to volume, or to scale all results in another manor. |
mass |
A matrix (months by traces), such as that returned by
|
flow |
A matrix (months by traces), such as that returned by
|
Value
Other functions: Annual matrix (years x traces)
rwslot_fwaac()
: Annual matrix (years x traces). Units are mg/L.
Functions
-
sumMonth2Annual
: Deprecated version ofrwslot_annual_sum()
. -
rwslot_annual_min
: finds the minimum annual value for all years and traces. -
getMinAnnValue
: Deprecated version ofrwslot_annual_min()
. -
rwslot_annual_max
: finds the maximum annual value for all years and traces. -
getMaxAnnValue
: Deprecated version ofrwslot_annual_max()
. -
rwslot_fwaac
: calculates the flow-weighted average annual concentration (fwaac). Given mass and flow at the monthly basis, the flow-weighted average annual concentration is computed.mass
andflow
should be monthly data.rwslot_fwaac()
expects flow to be in acre-ft/month and mass to be in tons; however, there are no checks to ensure this is true. Return value will be in mg/L.
See Also
Examples
zz <- rdf_get_slot(keyRdf, 'Powell.Outflow')
# returns in original units, e.g., acre-ft
annualTotVal <- rwslot_annual_sum(zz)
# returns in scaled units, e.g., kaf
annualTotVal <- rwslot_annual_sum(zz, 0.001)
pe <- rdf_get_slot(keyRdf,'Mead.Pool Elevation')
peMax <- rwslot_annual_min(pe)
pe <- rdf_get_slot(keyRdf,'Mead.Pool Elevation')
peMax <- rwslot_annual_max(pe)
flow <- rdf_get_slot(keyRdf,'Powell.Outflow')
# make up mass, since it's not stored in the example data
rr <- matrix(
rnorm((nrow(flow) * ncol(flow)), mean = 1000, sd = 200),
nrow = nrow(flow),
ncol = ncol(flow)
)
mass <- flow / 1000000 * rr^2 - rr + 1500
fwaac <- rwslot_fwaac(mass, flow)