rwslot_aggs: Simple aggregation functions for monthly matrix data

rwslot_annual_sumR 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 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), and the rwslot must have the timespan attribute.

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

Other functions: Annual matrix (years x traces)

rwslot_fwaac(): Annual matrix (years x traces). Units are mg/L.

Functions

  • sumMonth2Annual: Deprecated version of rwslot_annual_sum().

  • rwslot_annual_min: finds the minimum annual value for all years and traces.

  • getMinAnnValue: Deprecated version of rwslot_annual_min().

  • rwslot_annual_max: finds the maximum annual value for all years and traces.

  • getMaxAnnValue: Deprecated version of rwslot_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 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.

See Also

rdf_get_slot()

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) 


BoulderCodeHub/RWDataPlyr documentation built on May 8, 2023, 3:55 a.m.