RWDataPlyr (version 0.6.2)

rwslot_annual_sum: Simple aggregation functions for monthly matrix data

Description

rwslot_annual_sum() takes a matrix containing monthly data (months by traces), and sums the monthly data into annual data. Returns a years by traces matrix.

rwslot_annual_min() finds the minimum annual value for all years and traces.

rwslot_annual_max() finds the maximum annual value for all years and traces.

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 and flow 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.

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 rdf_get_slot(). Function will error if the rwslot does not contain "regular" monthly data, i.e., the data must start in January and end in December, or start in October and end in September (water year).

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 rdf_get_slot(), of mass in tons.

flow

A matrix (months by traces), such as that returned by rdf_get_slot(), of flow in acre-ft/month.

Value

rwslot_annual_sum() returns the annual sum as a matrix (years by traces).

rwslot_annual_min() returns a matrix (years by traces) with the maximum annual value for each year and trace.

rwslot_annual_max() returns a matrix (years by traces) with the maximum annual value for each year and trace.

rwslot_fwaac() returns a matrix of yearly data of the flow-weighted average annual concentration. Units are mg/L.

Functions

  • sumMonth2Annual: Deprecated version of rwslot_annual_sum().

See Also

rdf_get_slot()

Examples

Run this code
# NOT RUN {
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) 

# }

Run the code above in your browser using DataCamp Workspace