ms_scale_flux_by_area: Scale stream or precipitation chemical flux by watershed area

View source: R/ms_scale_flux_by_area.R

ms_scale_flux_by_areaR Documentation

Scale stream or precipitation chemical flux by watershed area

Description

MacroSheds chemical flux is scaled to watershed area by default (kg/ha/d). This function converts chemical flux to kg/d. If You generated precipitation chemical flux yourself with ms_calc_watershed_precip(), it is in kg/d and this function may be needed.

Usage

ms_scale_flux_by_area(d)

Arguments

d

data.frame. A data.frame in MacroSheds format (see details), containing stream or precipitation flux data. A data.frame in MacroSheds format is generated by ms_load_product().

Details

MacroSheds reports all chemical flux on a per area basis (kg/ha/d) to facilitate comparison of watersheds of different sizes. If you've unscaled MacroSheds flux data with ms_undo_scale_flux_by_area(), or generated precipitation flux with ms_calc_watershed_precip(), you can use this function to convert from kg/d to kd/ha/d. To download MacroSheds data, see ms_download_core_data().

MacroSheds format (only site_code and val columns required as inputs to this function):

header value column_definition
date Date in YYYY-mm-dd
site_code A unique identifier for each MacroSheds site, identical to primary source site code where possible. See ms_load_sites().
grab_sample Boolean integer indicating whether the observation was obtained via grab sample or installed sensor. 1 = TRUE (grab sample), 0 = FALSE (installed sensor).
var Variable code. See ms_load_variables().
val Data value. See ms_load_variables() for units.
ms_status Boolean integer. 0 = clean value. 1 = questionable value. See "Technical Validation" section of the MacroSheds data paper for details.
ms_interp Boolean integer. 0 = measured or imputed by primary source. 1 = interpolated by MacroSheds. See "Temporal Imputation and Aggregation" section of the MacroSheds data paper for details.
val_err The combined standard uncertainty associated with the corresponding data point, if estimable. See "Detection Limits and Propagation of Uncertainty" section of the MacroSheds data paper for details.

Value

returns a data.frame in MacroSheds format with stream or precipitation chemical flux in kg/ha/d.

Author(s)

Spencer Rhea

Mike Vlah, vlahm13@gmail.com

Wes Slaughter

See Also

ms_undo_scale_flux_by_area()

Examples

ms_root <- 'data/macrosheds'
ms_download_core_data(macrosheds_root = ms_root,
                      domains = 'hbef')
d <- ms_load_product(macrosheds_root = ms_root,
                     prodname = 'stream_flux_inst_scaled',
                     domains = 'hbef',
                     filter_vars = 'NO3_N')

d <- ms_undo_scale_flux_by_area(d)
d <- ms_scale_flux_by_area(d)

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