... | ... | @@ -5,12 +5,16 @@ Exploration and Graphics for RivEr Trends (`EGRET`): |
|
|
An R-package for the analysis of long-term changes in water quality and streamflow,
|
|
|
including the water-quality method Weighted Regressions on Time, Discharge, and Season (WRTDS)
|
|
|
|
|
|
Evaluating long-term changes in river conditions (water quality and discharge) is an important use of hydrologic data. To carry out such evaluations, the hydrologist needs tools to facilitate several key steps in the process: acquiring the data records from a variety of sources, structuring it in ways that facilitate the analysis, routines that will process the data to extract information about changes that may be happening, and graphical techniques that can display findings about change. A pair of tightly linked R packages, called `dataRetrieval` and `EGRET` (Exploration and Graphics for RivEr Trends), have been developed for carrying out each of these steps in an integrated manner. They are designed to accept easily data from three sources: U.S. Geological Survey hydrologic data, Water Quality Portal Data (currently including U.S. Environmental Protection Agency (EPA) STORET data, and USDA STEWARDS data), and user-supplied flat files. The `dataRetrieval` package not only serves as a "front end" to the `EGRET` package, it can also be used to easily download many types of hydrologic data and organize it in ways that facilitate many other hydrologic applications. The `EGRET` package has components oriented towards the description of long-term changes in streamflow statistics (high flow, average flow, and low flow) as well as changes in water quality. For the water-quality analysis, it uses Weighted Regressions on Time, Discharge and Season (WRTDS) to describe long-term trends in both concentration and flux. `EGRET` also creates a wide range of graphical presentations of the water-quality data and of the WRTDS results. This report serves as a user guide to these two R packages, providing detailed guidance on installation and use of the software, documentation of the analysis methods used, as well as guidance on some of the kinds of questions and approaches that the software can facilitate.
|
|
|
Evaluating long-term changes in river conditions (water quality and discharge) is an important use of hydrologic data. To carry out such evaluations, the hydrologist needs tools to facilitate several key steps in the process: acquiring the data records from a variety of sources, structuring it in ways that facilitate the analysis, routines that will process the data to extract information about changes that may be happening, and graphical techniques that can display findings about change. The R package `EGRET` (Exploration and Graphics for RivEr Trends) was developed for carrying out each of these steps in an integrated manner. It is designed to accept easily data from three sources: U.S. Geological Survey hydrologic data, Water Quality Portal Data (currently including U.S. Environmental Protection Agency (EPA) STORET data, and USDA STEWARDS data), and user-supplied flat files. The `EGRET` package has components oriented towards the description of long-term changes in streamflow statistics (high flow, average flow, and low flow) as well as changes in water quality. For the water-quality analysis, it uses Weighted Regressions on Time, Discharge and Season (WRTDS) to describe long-term trends in both concentration and flux. `EGRET` also creates a wide range of graphical presentations of the water-quality data and of the WRTDS results. The following report serves as a user guide, providing detailed guidance on installation and use of the software, documentation of the analysis methods used, as well as guidance on some of the kinds of questions and approaches that the software can facilitate.
|
|
|
|
|
|
The link for the official USGS publication user guide is here:
|
|
|
|
|
|
[http://pubs.usgs.gov/tm/04/a10/](http://pubs.usgs.gov/tm/04/a10/)
|
|
|
|
|
|
Note: The "official EGRET User Guide" currently (2014-11-12) shows a workflow that has been superseded by
|
|
|
the workflow shown in this vignette. However the science and math is the User Guide is correct. The User
|
|
|
Guide is in the process of being updated and will be available at the URL shown above in the near future.
|
|
|
|
|
|
An recent presentation on an overview of `dataRetrieval` and `EGRET` can be found here:
|
|
|
[dataRetrieval and EGRET 2014-10-07.pdf](https://github.com/USGS-R/EGRET/blob/gh-pages/images/dataRetrieval%20and%20EGRET%202014-10-07.pdf?raw=true)
|
|
|
|
... | ... | @@ -18,11 +22,11 @@ Package Installation |
|
|
---------------------------------
|
|
|
|
|
|
To install the `EGRET` and `dataRetrieval` packages you need to be using R 3.0 or greater. Then use the following command:
|
|
|
|
|
|
```R
|
|
|
install.packages(c("dataRetrieval","EGRET"),
|
|
|
repos=c("http://usgs-r.github.com","http://cran.us.r-project.org"),
|
|
|
dependencies=TRUE)
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
Background Information
|
... | ... | @@ -45,18 +49,18 @@ Sample Workflow |
|
|
---------------
|
|
|
|
|
|
Load data from web services:
|
|
|
|
|
|
```R
|
|
|
library(dataRetrieval)
|
|
|
Daily <- getNWISDaily("06934500","00060","1979-10-01","2010-09-30")
|
|
|
Sample <-getNWISSample("06934500","00631","1970-10-01","2011-09-30")
|
|
|
INFO <-getNWISInfo("06934500","00631", interactive=FALSE)
|
|
|
Sample <-mergeReport(Daily, Sample)
|
|
|
eList <-mergeReport(INFO, Daily, Sample)
|
|
|
```
|
|
|
|
|
|
This is a sample workflow for a WRTDS trend analysis using `EGRET` on the Choptank River at Greensboro MD, for Nitrate:
|
|
|
|
|
|
library(dataRetrieval)
|
|
|
```R
|
|
|
library(EGRET)
|
|
|
|
|
|
############################
|
|
|
# Gather discharge data:
|
|
|
siteID <- "01491000" #Choptank River at Greensboro, MD
|
... | ... | @@ -76,43 +80,43 @@ This is a sample workflow for a WRTDS trend analysis using `EGRET` on the Chopta |
|
|
# Here user must input some values for
|
|
|
# the default (interactive=TRUE)
|
|
|
INFO<- getNWISInfo(siteID,parameter_cd)
|
|
|
INFO$shortName <- "Choptank River at Greensboro, MD"
|
|
|
INFO$shortName <- "Choptank River near Greensboro, MD"
|
|
|
|
|
|
# Merge discharge with sample data:
|
|
|
Sample <- mergeReport()
|
|
|
eList <- mergeReport(INFO, Daily, Sample)
|
|
|
############################
|
|
|
|
|
|
############################
|
|
|
# Check sample data:
|
|
|
boxConcMonth()
|
|
|
boxQTwice()
|
|
|
plotConcTime()
|
|
|
plotConcQ()
|
|
|
multiPlotDataOverview()
|
|
|
boxConcMonth(eList)
|
|
|
boxQTwice(eList)
|
|
|
plotConcTime(eList)
|
|
|
plotConcQ(eList)
|
|
|
multiPlotDataOverview(eList)
|
|
|
############################
|
|
|
|
|
|
############################
|
|
|
# Run WRTDS model:
|
|
|
modelEstimation()
|
|
|
eList <- modelEstimation(eList)
|
|
|
############################
|
|
|
|
|
|
############################
|
|
|
#Check model results:
|
|
|
|
|
|
#Require Sample + INFO:
|
|
|
plotConcTimeDaily()
|
|
|
plotFluxTimeDaily()
|
|
|
plotConcPred()
|
|
|
plotFluxPred()
|
|
|
plotResidPred()
|
|
|
plotResidQ()
|
|
|
plotResidTime()
|
|
|
boxResidMonth()
|
|
|
boxConcThree()
|
|
|
plotConcTimeDaily(eList)
|
|
|
plotFluxTimeDaily(eList)
|
|
|
plotConcPred(eList)
|
|
|
plotFluxPred(eList)
|
|
|
plotResidPred(eList)
|
|
|
plotResidQ(eList)
|
|
|
plotResidTime(eList)
|
|
|
boxResidMonth(eList)
|
|
|
boxConcThree(eList)
|
|
|
|
|
|
#Require Daily + INFO:
|
|
|
plotConcHist()
|
|
|
plotFluxHist()
|
|
|
plotConcHist(eList)
|
|
|
plotFluxHist(eList)
|
|
|
|
|
|
# Multi-line plots:
|
|
|
date1 <- "2000-09-01"
|
... | ... | @@ -120,7 +124,7 @@ This is a sample workflow for a WRTDS trend analysis using `EGRET` on the Chopta |
|
|
date3 <- "2009-09-01"
|
|
|
qBottom<-100
|
|
|
qTop<-5000
|
|
|
plotConcQSmooth(date1, date2, date3, qBottom, qTop,
|
|
|
plotConcQSmooth(eList, date1, date2, date3, qBottom, qTop,
|
|
|
concMax=2,qUnit=1)
|
|
|
q1 <- 10
|
|
|
q2 <- 25
|
... | ... | @@ -128,10 +132,10 @@ This is a sample workflow for a WRTDS trend analysis using `EGRET` on the Chopta |
|
|
centerDate <- "07-01"
|
|
|
yearEnd <- 2009
|
|
|
yearStart <- 2000
|
|
|
plotConcTimeSmooth(q1, q2, q3, centerDate, yearStart, yearEnd)
|
|
|
plotConcTimeSmooth(eList, q1, q2, q3, centerDate, yearStart, yearEnd)
|
|
|
|
|
|
# Multi-plots:
|
|
|
fluxBiasMulti()
|
|
|
fluxBiasMulti(eList)
|
|
|
|
|
|
#Contour plots:
|
|
|
clevel<-seq(0,2,0.5)
|
... | ... | @@ -139,17 +143,18 @@ This is a sample workflow for a WRTDS trend analysis using `EGRET` on the Chopta |
|
|
yearStart <- 2000
|
|
|
yearEnd <- 2010
|
|
|
|
|
|
plotContours(yearStart,yearEnd,qBottom,qTop,
|
|
|
plotContours(eList, yearStart,yearEnd,qBottom,qTop,
|
|
|
contourLevels = clevel,qUnit=1)
|
|
|
plotDiffContours(yearStart,yearEnd,
|
|
|
plotDiffContours(eList, yearStart,yearEnd,
|
|
|
qBottom,qTop,maxDiff,qUnit=1)
|
|
|
# modify this for your own computer file structure
|
|
|
savePath<-"/Users/rhirsch/Desktop/"
|
|
|
saveResults(savePath)
|
|
|
saveResults(savePath, eList)
|
|
|
```
|
|
|
|
|
|
This is a sample workflow for a flowHistory application for the entire record.
|
|
|
|
|
|
library(dataRetrieval)
|
|
|
```R
|
|
|
library(EGRET)
|
|
|
|
|
|
# Flow history analysis
|
... | ... | @@ -164,22 +169,22 @@ This is a sample workflow for a flowHistory application for the entire record. |
|
|
# the default (interactive=TRUE)
|
|
|
INFO<- getNWISInfo(siteID,"00060")
|
|
|
INFO$shortName <- "Choptank River at Greensboro, MD"
|
|
|
eList <- as.egret(INFO, Daily, NA, NA)
|
|
|
############################
|
|
|
|
|
|
############################
|
|
|
# Check flow history data:
|
|
|
annualSeries <- makeAnnualSeries()
|
|
|
plotFlowSingle(istat=7,qUnit="thousandCfs")
|
|
|
plotSDLogQ()
|
|
|
plotQTimeDaily(qLower=1,qUnit=3)
|
|
|
plotFour(qUnit=3)
|
|
|
plotFourStats(qUnit=3)
|
|
|
plotFlowSingle(eList, istat=7,qUnit="thousandCfs")
|
|
|
plotSDLogQ(eList)
|
|
|
plotQTimeDaily(eList, qLower=1,qUnit=3)
|
|
|
plotFour(eList qUnit=3)
|
|
|
plotFourStats(eList, qUnit=3)
|
|
|
############################
|
|
|
|
|
|
# modify this for your own computer file structure:
|
|
|
savePath<-"/Users/rhirsch/Desktop/"
|
|
|
saveResults(savePath)
|
|
|
|
|
|
saveResults(savePath, eList)
|
|
|
```
|
|
|
|
|
|
Subscribe
|
|
|
---------
|
... | ... | @@ -191,9 +196,12 @@ Additionally, to subscribe to an email list concerning updates to these R packag |
|
|
|
|
|
Version updates
|
|
|
---------------
|
|
|
###EGRET 2.0.0
|
|
|
* November 13, 2014
|
|
|
* New workflow
|
|
|
|
|
|
###EGRET 1.3.0
|
|
|
|
|
|
###EGRET 1.3.0
|
|
|
* July 31, 2014
|
|
|
* Modified the smoothing algorithm in flowHistory and WRTDS to reduce "edge effects". New smoother is the default, but original method is still available (see User Guide for details). The modified method tends to reduce curvature near the start and end of record. It has no effect during the middle years of the data set.
|
|
|
|
... | ... | |