ms_calc_vwc: Calculates chemical fluxes

View source: R/ms_calc_vwc.R

ms_calc_vwcR Documentation

Calculates chemical fluxes

Description

Calculates stream discharge and precipitation fluxes of chemicals from Q (discharge or precipitation) and chemistry data.

Usage

ms_calc_vwc(chemistry, q, q_type, agg = "yearly", verbose = TRUE)

Arguments

chemistry

data.frame. A data.frame of precipitation or stream chemistry data in MacroSheds format and in units of mg/L.

q

data.frame. A data.frame of precipitation or stream discharge in MacroSheds format and in units of mm or L/s, respectively.

q_type

character. Either 'precipitation' or 'discharge'.

verbose

logical. Default TRUE; prints more information to console.

Details

Chemical Volume Weighted Concentration (VWC) is 'traditionally' calculated as VWC = sum(concentrations * volumes) / sum(volumes) over a given period. Because we have discharge (a rate), rather than volume, we could scale it to the sample interval and then use the equation above. For simplicity, we use this instead, which works out the same: VWC = mean(concentrations * discharges) / mean(discharges) Note also that we're starting from flux here, for computational efficiency, so the "concentrations * volumes" part is already computed, and it's a rate too. That means the modified equation is: VWC = mean(fluxes) / mean(discharges). There are two minor introductions of error. The first is that we don't omit discharge values from the denominator that lack a corresponding flux value (this is expensive, and not doing it should rarely skew the results). The second is that a "month" is considered 30 days here, which only affects filtering by coverage.

Value

returns a tibble of stream or precipitation chemical flux for every timestep where discharge/precipitation and chemistry are reported. Output units are kg/ha/timestep.

Author(s)

Spencer Rhea

Mike Vlah, vlahm13@gmail.com

Wes Slaughter

See Also

ms_calc_flux, ms_synchronize_timestep(), ms_conversions(), ms_scale_flux_by_area(), ms_undo_scale_flux_by_area()

Examples

#' ### Load some MacroSheds data:
ms_root = 'data/macrosheds'
ms_download_core_data(macrosheds_root = ms_root,
                      domains = 'hbef')

chemistry <- ms_load_product(macrosheds_root = ms_root,
                             prodname = 'stream_chemistry',
                             site_codes = c('w1', 'w3', 'w6'),
                             filter_vars = c('NO3_N', 'Cl', 'Na'))

q <- ms_load_product(macrosheds_root = ms_root,
                     prodname = 'discharge',
                     site_codes = c('w1', 'w3', 'w6'))

flux <- ms_calc_vwc(chemistry = chemistry,
                     q = q,
                     q_type = 'discharge')

MacroSHEDS/macrosheds documentation built on Oct. 30, 2024, 11:15 a.m.