Skip to content

Instantly share code, notes, and snippets.

@troyhill
Last active December 17, 2018 20:14
Show Gist options
  • Save troyhill/a7ab08949f3805118343d8534b06635e to your computer and use it in GitHub Desktop.
Save troyhill/a7ab08949f3805118343d8534b06635e to your computer and use it in GitHub Desktop.
WRTDS implementation using DataForEver data
### Weighted regression using time, discharge, and season
### Application of EGRET tools to DataForEver data
library(plyr)
library(SFNRC)
# Meta-analysis -----------------------------------------------------------
targStns <- c("S333", "S12A", "S12B", "S12C", "S12D") #, "S151", "S343", "S332")
targAnalyte <- "PHOSPHATE, TOTAL AS P"
test <- lapply(targStns, function(stnSelect)
modelEstimation(convertToEgret(stn = stnSelect, target_analyte = targAnalyte,
wq_data = wqDat, flow_data = hydDat)))
lapply(test, fluxBiasMulti)
lapply(test, plotConcHist)
mdiff <- 0.04
yearStart <- 1985
yearEnd <- 2015
lapply(test, plotDiffContours, yearStart, yearEnd, qBottom, qTop, qUnit = 1, maxDiff = mdiff)
# plotDiffContours(test[[1]], yearStart, yearEnd, qBottom, qTop, qUnit = 1, maxDiff = mdiff)
targStn <- "S12C"
targStns <- c("S333", "S12A", "S12D", "S12C", "S12D")
targAnalyte <- "PHOSPHATE, TOTAL AS P"
eList <- convertToEgret(stn = targStn, target_analyte = targAnalyte,
wq_data = wqDat, flow_data = hydDat)
############################
# Check sample data:
boxConcMonth(eList)
boxQTwice(eList)
### model
eList <- modelEstimation(eList)
############################
#Check model results:
#eList:
plotConcTimeDaily(eList)
plotConcPred(eList)
plotFluxPred(eList)
plotResidPred(eList)
plotResidQ(eList)
plotResidTime(eList)
boxResidMonth(eList)
#Require Daily + INFO:
plotConcHist(eList)
# Multi-line plots:
date1 <- "2000-09-01"
date2 <- "2005-09-01"
date3 <- "2009-09-01"
qBottom <- 1
qTop <- 10000
plotConcQSmooth(eList, date1, date2, date3, qBottom, qTop,
concMax=1,qUnit=1)
fluxBiasMulti(eList)
#Contour plots:
clevel<-seq(0,2,0.5)
maxDiff<-0.8
yearStart <- 2000
yearEnd <- 2010
plotContours(eList, yearStart,yearEnd, qBottom, qTop,
contourLevels = NA ,qUnit=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment