convertToEgret: Convert DataForEver output to EGRET-compatible input

View source: R/convertToEgret.R

convertToEgretR Documentation

Convert DataForEver output to EGRET-compatible input

Description

Convert DataForEver output to EGRET-compatible input

Usage

convertToEgret(
  stn,
  target_analyte,
  wq_data = NULL,
  flow_data = NULL,
  qConvert = 1,
  interact = FALSE,
  paStart = 10,
  paLong = 12,
  watershedKm = 1,
  removeNegativeFlow = TRUE
)

Arguments

stn

target station. Not case-sensitive.

target_analyte

Water quality parameter of interest. Internally converted to R-friendly form (no commas, hyphens, spaces).

wq_data

water quality dataframe. Product of getDFE or getDBHYDRO. In the convertEgret output, the date range in wq_data is modified to be the intersection of wq_data and flow_data

flow_data

flow dataframe. Product of getDFE or getDBHYDROhydro. If set to NA, a dataframe of flow = 1.1 m3/s is created and used for analysis. This workaround is designed to allow WRTDS on stations without discharge data (e.g., open-water stations) but may not be mathematically sound.

qConvert

a conversion factor applied to the flow data. Default is 1 (no conversion). Use 1/0.0283168 to convert cfs to cubic meters per second.

interact

logical Option for interactive mode. If true, there is user interaction for error handling and data checks. FALSE by default

paStart

Starting month of period of analysis. Defaults to 10. Used in most EGRET functions

paLong

Length in number of months of period of analysis. Defaults to 12. Used in most EGRET functions

watershedKm

Watershed area in km2, used to calculate runoff. Defaults to 1

removeNegativeFlow

logical, defaults to TRUE. Indicates whether negative flow data should be removed during pre-processing. EGRET tools do not accommodate negative flows.

Value

a list as created by mergeReport

Examples

targStn <- "S333"
targAnalyte <- "PHOSPHATE, TOTAL AS P"

### subsetting occurs inside the function, so this prep is not necessary
# wq_dat <- wqDat[(wqDat$station %in% targStn) & (wqDat$param %in% targAnalyte), ]
# flow_dat <- hydDat[hydDat$station %in% targStn, ]
## Not run:  # 20190404: this example causes Appveyor to fail
eList <- convertToEgret(stn = targStn, target_analyte = targAnalyte, 
     wq_data = wqDat, flow_data = hydDat)
     
eList_NA <- convertToEgret(stn = targStn, target_analyte = targAnalyte, 
     wq_data = wqDat, flow_data = NA)

est        <- modelEstimation(eList)
est_woFlow <- modelEstimation(eList_NA)

### not quite the same
plotConcPred(est)
plotConcPred(est_woFlow)
     
     
## End(Not run)

troyhill/SFNRC documentation built on Dec. 30, 2024, 4:32 p.m.