ms_run_egret: Run the WRTDS model through EGRET for MacroSheds data

View source: R/ms_run_egret.R

ms_run_egretR Documentation

Run the WRTDS model through EGRET for MacroSheds data

Description

ms_run_egret prepares data for the EGRET package and runs the Weighted Regression on Time, Discharge, and Season (WRTDS) model.

Usage

ms_run_egret(
  stream_chemistry,
  discharge,
  prep_data = TRUE,
  run_egret = TRUE,
  kalman = FALSE,
  quiet = FALSE,
  site_data = NULL
)

Arguments

stream_chemistry

data.frame in MacroSheds format (see MacroSheds EDI Must contain only one stream chemistry variable and one site_code to comply with WRTDS. A tibble of stream chemistry, in MacroSheds format, can be generated by ms_load_product().

discharge

data.frame in MacroSheds format (see MacroSheds EDI Must contain discharge for only one site_code to comply with WRTDS. A tibble of discharge, in MacroSheds format, can be generated by ms_load_product().

prep_data

logical. Should data be thinned/altered to follow EGRET recommendations? See details for more information.

run_egret

logical. If FALSE, the EGRET model will not be run and an EGRET eList will be returned. This argument is intended for those who want to change default parameters in the EGRET model but need data in the eList format.

quiet

logical. Should warnings be printed to console?

site_data

tibble. Default NULL, if you are using a non-MacroSheds site you must supply a tibble with the columns: site_code, ws_area_ha, latitude, longitude. If using a MacroSheds site you can leave this argument NULL and the MacroSheds site_data table will be retrieved.

Kalman

logical. Should EGRET run the Kalman filter on WRTDS results? See EGRET::WRTDSKalman() for more information.

Details

WRTDS is a model to predict stream chemistry at a daily time step based on the season, discharge, and time since last grab sample. This model is useful for calculating flux when sampling is sparse (greater than a weekly sampling frequency). For more information on the WRTDS and EGRET package see https://github.com/USGS-R/EGRET.

prep_data will remove NAs from the dataset, set all 0 values in stream chemistry dataset to the minimum value in the dataset (this is required because EGRET will fail if there are 0 values in a dataset), remove years with fewer than 6 chemistry samples, and remove datetimes when there is chemistry but no discharge data reported.

Value

returns a list in the EGRET format with model results.

Author(s)

Spencer Rhea

Mike Vlah, vlahm13@gmail.com

Wes Slaughter

See Also

ms_load_product(), ms_conversions()


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