Maintenance scheduled for Thursday, February 27th at 15:00 MDT. Expected downtime <1 hour.

...
 
Commits (164)
^Meta$
^doc$
.git
EGRET.Rproj
appveyor.yml
......@@ -5,8 +7,6 @@ appveyor.yml
.gitignore
.travis.yml
vignettes/figure
vignettes/EGRET-concordance.tex
vignettes/EGRET.bbl
^\.Rproj/.RData
^.*\.Rproj$
^\.Rproj\.user$
......@@ -14,14 +14,28 @@ README.Rmd
README_files/
CONDUCT.md
DISCLAIMER.md
LICENSE.md
code.json
vignettes/Chop.OPbase.RData
vignettes/eListOut.RData
vignettes/eListOutChop.RData
vignettes/eListOutNoWall.RData
vignettes/eListColumbia.RData
vignettes/eListMerced.RData
vignettes/eListMiss.RData
vignettes/Green.Cl.RData
hexSticker.R
code.json
^docs$
EGRET.Rcheck
vignettes/References_WRTDS.Rmd
vignettes/References_Extend.Rmd
vignettes/References_Region.Rmd
vignettes/Regional_studies.bib
vignettes/Extend_Method.bib
vignettes/SeasonalFraction.Rmd
vignettes/streamflow_trend.Rmd
vignettes/data_prep.Rmd
vignettes/Conwingo.PO4.RData
vignettes/plotOne.R
vignettes/runPairsMonths.R
vignettes/TrendByMonth.Rmd
vignettes/Making WRTDS_K flux estimates.Rmd
vignettes/functionsForK.R
vignettes/rockCr.tp.RData
vignettes/test.RData
_pkgdown.yml
pkgdown/favicon/*
vignettes/css/*
vignettes/img/*
......@@ -6,41 +6,38 @@
language: r
cache: packages
dist: trusty
matrix:
include:
- os: linux
r: release
- os: linux
r: devel
env: R_CODECOV=true
- r: release
after_success:
- travis_wait 20 R -e 'covr::coveralls()'
before_deploy: Rscript -e 'remotes::install_cran("pkgdown")'
deploy:
provider: script
script: Rscript -e 'pkgdown::deploy_site_github(verbose = TRUE)'
skip_cleanup: true
- r: devel
addons:
apt:
packages:
- libcurl4-openssl-dev
repos:
CRAN: https://cloud.r-project.org
USGS: https://owi.usgs.gov/R
env:
global:
- R_BUILD_ARGS="--no-vignettes --no-manual"
- R_CHECK_ARGS="--no-vignettes --no-manual --as-cran"
- NOT_CRAN="true"
- _R_CHECK_FORCE_SUGGESTS_=false
warnings_are_errors: true
r_github_packages:
- jimhester/covr
script:
- |
R CMD build .
travis_wait 20 R CMD check EGRET*tar.gz
after_success:
- if [[ "${R_CODECOV}" ]]; then travis_wait 20 R -e 'covr::coveralls()'; fi
notifications:
email:
on_success: change
......
Package: EGRET
Type: Package
Title: Exploration and Graphics for RivEr Trends (EGRET)
Version: 3.0.0
Title: Exploration and Graphics for RivEr Trends
Version: 3.0.3.9000
Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "rhirsch@usgs.gov",
comment=c(ORCID="0000-0002-4534-075X")),
......@@ -13,7 +13,9 @@ Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
person("Jennifer","Murphy", role = c("ctb")))
Description: Statistics and graphics for streamflow history,
water quality trends, and the statistical modeling algorithm: Weighted
Regressions on Time, Discharge, and Season (WRTDS).
Regressions on Time, Discharge, and Season (WRTDS). The modeling
method is introduced and discussed in Hirsch et al. (2010) <doi:10.1111/j.1752-1688.2010.00482.x>,
and expanded in Hirsch and De Cicco (2015) <doi:10.3133/tm4A10>.
License: CC0
Depends:
R (>= 3.0)
......@@ -30,14 +32,18 @@ Imports:
foreach
Suggests:
EGRETci,
xtable,
knitr,
rmarkdown,
extrafont,
testthat,
rkt,
doParallel,
parallel
parallel,
pkgdown,
png,
dplyr,
zyp,
lubridate
LazyLoad: yes
LazyData: yes
BugReports: https://github.com/USGS-R/EGRET/issues
......@@ -49,4 +55,4 @@ Copyright: This software is in the public domain because it contains materials
the United States Department of Interior. For more information, see the
official USGS copyright policy at
https://www.usgs.gov/visual-id/credit_usgs.html#copyright
RoxygenNote: 6.1.0
RoxygenNote: 6.1.1
License
=======
Unless otherwise noted, This project is in the public domain in the United
States because it contains materials that originally came from the United
States Geological Survey, an agency of the United States Department of
Interior. For more information, see the official USGS copyright policy at
https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits
Additionally, we waive copyright and related rights in the work
worldwide through the CC0 1.0 Universal public domain dedication.
CC0 1.0 Universal Summary
-------------------------
This is a human-readable summary of the
[Legal Code (read the full text)][1].
### No Copyright
The person who associated a work with this deed has dedicated the work to
the public domain by waiving all of his or her rights to the work worldwide
under copyright law, including all related and neighboring rights, to the
extent allowed by law.
You can copy, modify, distribute and perform the work, even for commercial
purposes, all without asking permission.
### Other Information
In no way are the patent or trademark rights of any person affected by CC0,
nor are the rights that other persons may have in the work or in how the
work is used, such as publicity or privacy rights.
Unless expressly stated otherwise, the person who associated a work with
this deed makes no warranties about the work, and disclaims liability for
all uses of the work, to the fullest extent permitted by applicable law.
When using or citing the work, you should not imply endorsement by the
author or the affirmer.
[1]: https://creativecommons.org/publicdomain/zero/1.0/legalcode
......@@ -24,7 +24,7 @@
#' @author Robert M. Hirsch \email{rhirsch@@usgs.gov}, Laura De Cicco \email{ldecicco@@usgs.gov}
#' @references Hirsch, R.M., and De Cicco, L.A., 2014, User guide to Exploration and Graphics for RivEr Trends
#' (EGRET) and dataRetrieval: R packages for hydrologic data: U.S. Geological Survey Techniques and Methods book 4,
#' chap. A10, 94 p., \url{https://dx.doi.org/10.3133/tm4A10}
#' chap. A10, 94 p., \url{https://doi.org/10.3133/tm4A10}
#' @keywords water-quality graphics streamflow statistics
NULL
......
......@@ -114,7 +114,7 @@ boxQTwice<-function(eList,
ylim=c(yInfo$bottom,yInfo$top),
main=plotTitle,cex=cex,ylab=yLabel,
cex.main=cex.main,
cex.axis=cex.axis, las=las,yaxt = "n",yaxs="i",
cex.axis=cex.axis, las=las,yaxs="i",
log=logScaleText,yaxt="n",
...)
axis(2,tcl=tcl,las=las,at=yInfo$ticks,cex.axis=cex.axis,labels=yTicksLab)
......
......@@ -24,7 +24,11 @@
#' plotFluxQ(eList_full)
as.egret <- function(INFO, Daily, Sample=NA, surfaces=NA) {
if(!all(is.na(Daily))){
if(exists("Daily") && !all(is.na(Daily))){
if(!("Q" %in% names(Daily))){
stop("Missing column 'Q' in Daily dataframe.")
}
expectedCols <- c("Date","Q","LogQ","Julian","Month","Day","DecYear","MonthSeq")
if(!all(expectedCols %in% names(Daily))){
......@@ -40,7 +44,7 @@ as.egret <- function(INFO, Daily, Sample=NA, surfaces=NA) {
}
}
if(!all(is.na(Sample))){
if(exists("Sample") && !all(is.na(Sample))){
if(any(duplicated(Sample$Date))){
message("\nThere are ",sum(duplicated(Sample$Date))," duplicated Sample dates.")
}
......@@ -48,30 +52,26 @@ as.egret <- function(INFO, Daily, Sample=NA, surfaces=NA) {
Sample <- Sample[order(Sample$Date, decreasing = FALSE),]
message("\nThe Sample data frame was sorted chronologically.")
}
if(!all((c("ConcLow","ConcHigh","Uncen","ConcAve") %in% names(Sample)))){
message("\nPlease double check that the Sample dataframe is correctly defined.")
message("\nMissing columns:", c("ConcLow","ConcHigh","Uncen","ConcAve")[!(c("ConcLow","ConcHigh","Uncen","ConcAve") %in% names(Sample))])
}
}
eList <- list(INFO=INFO,
Daily=Daily,
Sample=Sample,
surfaces=surfaces)
if(!is.na(Daily) && !("Q" %in% names(Daily))){
stop("Missing column 'Q' in Daily dataframe.")
}
if(!is.na(Sample) && !all((c("ConcLow","ConcHigh","Uncen","ConcAve") %in% names(Sample)))){
message("\nPlease double check that the Sample dataframe is correctly defined.")
message("\nMissing columns:", c("ConcLow","ConcHigh","Uncen","ConcAve")[!(c("ConcLow","ConcHigh","Uncen","ConcAve") %in% names(Sample))])
}
if(!any(c("param.units", "shortName", "paramShortName", "constitAbbrev", "drainSqKm") %in% names(INFO))){
if(exists("INFO") && !any(c("param.units", "shortName", "paramShortName", "constitAbbrev", "drainSqKm") %in% names(INFO))){
message("\nPlease double check that the INFO dataframe is correctly defined.")
}
if(!is.na(surfaces) && 14 != nrow(surfaces)){
if(exists("surfaces") && isTRUE(14 != nrow(surfaces))){
message("\nPlease double check that the surfaces matrix is correctly defined.")
}
eList <- list(INFO=INFO,
Daily=Daily,
Sample=Sample,
surfaces=surfaces)
attr(eList, "param.units") <- INFO$param.units
attr(eList, "shortName") <- INFO$shortName
attr(eList, "paramShortName") <- INFO$paramShortName
......
......@@ -26,7 +26,7 @@
#' numDays <- length(Daily$DecYear)
#' DecLow <- Daily$DecYear[1]
#' DecHigh <- Daily$DecYear[numDays]
#' \dontrun{
#' \donttest{
#' SampleCrossV <- estCrossVal(numDays,DecLow,DecHigh,Sample)
#' }
estCrossVal<-function(DecLow,DecHigh, Sample, windowY = 7, windowQ = 2,
......
......@@ -26,7 +26,7 @@
#' INFO$nVectorYear<-surfaceIndexParameters[['nVectorYear']]
#' eList$INFO <- INFO
#' #################################################
#' \dontrun{
#' \donttest{
#' Daily <- estDailyFromSurfaces(eList)
#' }
estDailyFromSurfaces <- function(eList, localsurfaces = NA, localDaily = NA) {
......
......@@ -30,7 +30,7 @@
#' @export
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#' \donttest{
#' surfaces <- estSurfaces(eList)
#'
#' surfaceStart <- "1984-10-01"
......
......@@ -34,7 +34,7 @@
#' flowStart,
#' flowEnd,
#' stringsAsFactors = FALSE)
#' \dontrun{
#' \donttest{
#' newEList <- flexFN(eList, dateInfo)
#' plotFluxHist(newEList)
#' flexPlotAddOn(newEList)
......@@ -137,7 +137,7 @@ flexFN <- function(eList, dateInfo, localsurfaces = NA, oldSurface = FALSE,
#' flowStart,
#' flowEnd,
#' stringsAsFactors = FALSE)
#' \dontrun{
#' \donttest{
#' newEList <- flexFN(eList, dateInfo)
#' plotFluxHist(newEList)
#' flexPlotAddOn(newEList)
......
......@@ -29,18 +29,11 @@
#' @export
#' @examples
#' eList <- Choptank_eList
#' fluxBiasMulti(eList)
#' # Water year:
#' \dontrun{
#' pdf("fluxBiasMulti.pdf", height=9, width=8)
#' fluxBiasMulti(eList)
#' dev.off()
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList,paStart=6,paLong=3)
#' pdf("fluxBiasMultiSummer.pdf", height=9, width=8)
#' fluxBiasMulti(eList)
#' dev.off()
#' }
fluxBiasMulti<-function (eList, qUnit = 2, fluxUnit = 3, moreTitle = "WRTDS",
cex = 0.7, cex.axis = 1.1,cex.main=1.1,randomCensored=FALSE,
col="black", lwd=1,...){
......
#' Compute the flux bias statistic: (mean of estimated flux - mean of observed flux) / mean of observed flux
#' Compute the flux bias statistic: (mean of estimated flux - mean of observed flux) / mean of estimated flux
#'
#' Computes three versions of the flux bias:
#' The first where all censored values are set to their miniumum.
......
......@@ -10,6 +10,9 @@
#' @param padPercent number used to pad the max and min if not specified
#' @param concentration logical if concentration=TRUE, labels returned as concentration units, otherwise flux units.
#' @param units character concentration units. Typically found in INFO$param.units.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param prettyDate logical use 'pretty' limits for date axis if TRUE, or force the yearStart/yearEnd as limits if FALSE
#' @keywords graphics water-quality statistics
#' @export
......@@ -32,6 +35,7 @@ generalAxis <- function(x,
tinyPlot = FALSE,
padPercent = 5,
concentration = TRUE,
usgsStyle = FALSE,
prettyDate = TRUE) {
......@@ -56,7 +60,23 @@ generalAxis <- function(x,
if (tinyPlot){
label <- paste("Conc. (",units,")",sep="")
} else {
label <- paste("Concentration in", units)
if(usgsStyle){
localUnits <- toupper(units)
possibleGoodUnits <- c("mg/l","mg/l as N", "mg/l as NO2",
"mg/l as NO3","mg/l as P","mg/l as PO3","mg/l as PO4","mg/l as CaCO3",
"mg/l as Na","mg/l as H","mg/l as S","mg/l NH4" )
allCaps <- toupper(possibleGoodUnits)
if(localUnits %in% allCaps){
label <- "Concentration, in milligrams per liter"
} else {
label <- paste("Concentration, in",units)
}
} else {
label <- paste("Concentration in", units)
}
}
} else {
label <- ""
......
......@@ -25,7 +25,7 @@
#'
#' siteNumber <- '01491000'
#' pCode <- '00631'
#' \dontrun{
#' \donttest{
#' Daily <- readNWISDaily(siteNumber,'00060', '1984-10-01', '')
#' Sample <- readNWISSample(siteNumber,pCode, '1984-10-01', '')
#' INFO <- readNWISInfo(siteNumber,pCode,interactive=FALSE)
......@@ -49,12 +49,12 @@ mergeReport <- function(INFO, Daily, Sample = NA, surfaces=NA, verbose = TRUE, i
dataOverview(Daily, Sample)
}
if(!is.na(Daily) && !("Q" %in% names(Daily))){
if(exists("Daily") && !all(is.na(Daily)) && !("Q" %in% names(Daily))){
message("Please double check that the Daily dataframe is correctly defined.")
}
if(!any(c("param.units", "shortName", "paramShortName", "constitAbbrev", "drainSqKm") %in% names(INFO))){
if(exists("INFO") && !any(c("param.units", "shortName", "paramShortName", "constitAbbrev", "drainSqKm") %in% names(INFO))){
message("Please double check that the INFO dataframe is correctly defined.")
}
......
......@@ -24,17 +24,8 @@
#' Any of these values can be NA, not all EGRET functions will work with missing parts of the named list eList.
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#'
#' #Run an estimation adjusting windowQ from default:
#' eList <- modelEstimation(eList, windowQ=5)
#'
#' library(doParallel)
#' nCores <- parallel::detectCores() - 1
#' cl <- makePSOCKcluster(nCores)
#' registerDoParallel(cl)
#' eList <- modelEstimation(eList, windowQ=5, run.parallel = TRUE)
#' stopCluster(cl)
#' \donttest{
#' eList <- modelEstimation(eList)
#' }
modelEstimation<-function(eList,
windowY=7, windowQ=2, windowS=0.5,
......
This diff is collapsed.
......@@ -10,10 +10,8 @@
#' @seealso \code{\link{plot1of15}}
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#' pdf("plot15.pdf",heigh=10,width=8)
#' \donttest{
#' plot15(eList, yearStart=1990,yearEnd=2000)
#' dev.off()
#' }
plot15<-function(eList, yearStart,yearEnd){
# plotName<-paste(savePath,"plot15.",localINFO$staAbbrev,".ps",sep="")
......
......@@ -27,6 +27,9 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param col.pred color of flow normalized line on plot, see ?par 'Color Specification'
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
......@@ -43,7 +46,7 @@
#' plotConcHist(eList)
plotConcHist<-function(eList, yearStart = NA, yearEnd = NA,
concMax = NA, printTitle = TRUE,
tinyPlot = FALSE,
tinyPlot = FALSE,usgsStyle = FALSE,
plotFlowNorm = TRUE, plotAnnual = TRUE,
cex=0.8, cex.axis=1.1,cex.main=1.1,
lwd=2, col="black", col.pred="green", customPar=FALSE,...){
......@@ -99,7 +102,7 @@ plotConcHist<-function(eList, yearStart = NA, yearEnd = NA,
combinedY <- c(localAnnualResults$Conc,localAnnualResults$FNConc[localAnnualResults$DecYear>xInfo$bottom & localAnnualResults$DecYear<xInfo$top])
yInfo <- generalAxis(x=combinedY, minVal=0, maxVal=concMax, padPercent=5,
tinyPlot=tinyPlot,units=localINFO$param.units)
tinyPlot=tinyPlot,units=localINFO$param.units, usgsStyle = usgsStyle)
genericEGRETDotPlot(x=NA, y=NA,
xTicks=xInfo$ticks, yTicks=yInfo$ticks,xDate=TRUE,
......
......@@ -19,6 +19,9 @@
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param randomCensored logical. Show censored values as randomized.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @seealso \code{\link{selectDays}}, \code{\link{genericEGRETDotPlot}}
......@@ -30,10 +33,11 @@
#' plotConcPred(eList, logScale=TRUE)
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotConcPred(eList)
#' plotConcPred(eList, usgsStyle=TRUE)
plotConcPred<-function(eList, concMax = NA, logScale=FALSE,
printTitle = TRUE,tinyPlot=FALSE,cex=0.8, cex.axis=1.1,
cex.main=1.1, customPar=FALSE,col="black",lwd=1, randomCensored = FALSE,...){
cex.main=1.1, customPar=FALSE,col="black",lwd=1,
randomCensored = FALSE, usgsStyle = FALSE,...){
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -62,8 +66,23 @@ plotConcPred<-function(eList, concMax = NA, logScale=FALSE,
xLab<-"Est. Conc."
yLab<-"Obs. Conc."
} else {
xLab<-paste("Estimated Concentration in",localINFO$param.units)
yLab<-paste("Observed Concentration in",localINFO$param.units)
if(usgsStyle){
localUnits <- toupper(localINFO$param.units)
localUnits <- gsub(" ","", localUnits)
if(length(grep("MG/L",localUnits)) > 0){
xLab <- "Estimated concentration, in milligrams per liter"
yLab <- "Observed concentration, in milligrams per liter"
} else {
xLab <- paste("Estimated concentration, in",units)
yLab <- paste("Observed concentration, in" ,units)
}
} else {
xLab<-paste("Estimated Concentration in",localINFO$param.units)
yLab<-paste("Observed Concentration in",localINFO$param.units)
}
}
if (logScale){
......
......@@ -39,7 +39,7 @@
#' plotConcQ(eList, logScale=TRUE)
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotConcQ(eList)
#' plotConcQ(eList, usgsStyle = TRUE)
plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,randomCensored=FALSE,
concMax = NA, concMin =NA, printTitle = TRUE, cex=0.8, cex.axis=1.1,cex.main=1.1,
usgsStyle=FALSE,
......@@ -93,7 +93,9 @@ plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,randomCen
yLow<-localSample$ConcLow
yHigh<-localSample$ConcHigh
yInfo <- generalAxis(x=yHigh, maxVal=concMax, minVal=yMin, tinyPlot=tinyPlot,logScale=logScale,units=localINFO$param.units)
yInfo <- generalAxis(x=yHigh, maxVal=concMax, minVal=yMin,
tinyPlot=tinyPlot,logScale=logScale,
units=localINFO$param.units, usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x, y=yHigh,
xlim=c(xInfo$bottom, xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
......@@ -112,7 +114,7 @@ plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,randomCen
}
yHigh <- localSample$rObserved
yInfo <- generalAxis(x=yHigh, maxVal=concMax, minVal=yMin, tinyPlot=tinyPlot,logScale=logScale,units=localINFO$param.units)
yInfo <- generalAxis(x=yHigh, maxVal=concMax, minVal=yMin, tinyPlot=tinyPlot,logScale=logScale,units=localINFO$param.units, usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x[Uncen == 1], y=yHigh[Uncen == 1],
xlim=c(xInfo$bottom, xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
......
......@@ -45,6 +45,9 @@
#' @param colors color vector of lines on plot, see ?par 'Color Specification'. Defaults to c("black","red","green")
#' @param lineVal vector of line types. Defaults to c(1,1,1) which is a solid line for each line. Options: 0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash
#' @param edgeAdjust logical specifying whether to use the modified method for calculating the windows at the edge of the record. The modified method tends to reduce curvature near the start and end of record. Default is TRUE.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords water-quality statistics graphics
#' @export
......@@ -56,15 +59,17 @@
#' qLow<-1
#' qHigh<-100
#' eList <- Choptank_eList
#' \donttest{
#' plotConcQSmooth(eList, date1,date2,date3,qLow,qHigh)
#' plotConcQSmooth(eList, date1,date2,date3,qLow,qHigh,logScale=TRUE)
#' }
plotConcQSmooth<-function(eList, date1,date2,date3,qLow,qHigh,qUnit = 2, legendLeft = 0,legendTop = 0,
concMax = NA, concMin=NA, bw = FALSE, printTitle = TRUE, printValues = FALSE,
minNumObs = 100, minNumUncen = 50,
colors=c("black","red","green"),printLegend=TRUE,
windowY = 7, windowQ = 2, windowS = 0.5,tinyPlot=FALSE, customPar=FALSE,
lwd=2,cex=0.8, cex.axis=1.1,cex.main=1.1, cex.legend=1.2,lineVal=c(1,1,1),logScale=FALSE,
edgeAdjust=TRUE,...) {
edgeAdjust=TRUE, usgsStyle = FALSE,...) {
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -131,7 +136,7 @@ plotConcQSmooth<-function(eList, date1,date2,date3,qLow,qHigh,qUnit = 2, legendL
if(tinyPlot){
xLab=qUnit@qUnitTiny
} else {
xLab=qUnit@qUnitExpress
xLab=ifelse(usgsStyle, qUnit@unitUSGS, qUnit@qUnitExpress)
}
if(logScale){
......@@ -144,7 +149,7 @@ plotConcQSmooth<-function(eList, date1,date2,date3,qLow,qHigh,qUnit = 2, legendL
xInfo <- generalAxis(x, maxVal=qHigh, minVal=qLow, logScale=TRUE, tinyPlot=tinyPlot)
combinedY <- c(y[1,], y[2,],y[3,])
yInfo <- generalAxis(combinedY, maxVal=concMax, minVal=concMin, logScale=logScale,
tinyPlot=tinyPlot, units=localINFO$param.units)
tinyPlot=tinyPlot, units=localINFO$param.units, usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x, y=y[1,],
xTicks=xInfo$ticks, yTicks=yInfo$ticks,
......
......@@ -32,6 +32,9 @@
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width.
#' @param randomCensored logical. Show censored values as randomized.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters.
#' @keywords graphics water-quality statistics
#' @export
......@@ -48,7 +51,8 @@
plotConcTime<-function(eList, qUnit = 2, yearStart = NA, yearEnd = NA,
qLower = NA, qUpper = NA, randomCensored=FALSE,
tinyPlot = FALSE, concMax = NA, concMin = NA, printTitle = TRUE,logScale=FALSE,
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,col="black",lwd=1,...){
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,
col="black",lwd=1, usgsStyle = FALSE,...){
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -124,7 +128,7 @@ plotConcTime<-function(eList, qUnit = 2, yearStart = NA, yearEnd = NA,
yHigh<-subSample$ConcHigh
yInfo <- generalAxis(x=yHigh, minVal=minYLow, maxVal=concMax, logScale=logScale,
tinyPlot=tinyPlot,units=attr(eList, "param.units"))
tinyPlot=tinyPlot,units=localINFO$param.units, usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x, y=yHigh,
xlim=c(xInfo$bottom,xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
......@@ -156,7 +160,7 @@ plotConcTime<-function(eList, qUnit = 2, yearStart = NA, yearEnd = NA,
yHigh <- subSample$rObserved
yInfo <- generalAxis(x=yHigh, minVal=minYLow, maxVal=concMax, logScale=logScale,
tinyPlot=tinyPlot,units=attr(eList, "param.units"))
tinyPlot=tinyPlot,units=attr(eList, "param.units"), usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x[Uncen == 1], y=yHigh[Uncen == 1],
xlim=c(xInfo$bottom,xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
......
......@@ -27,6 +27,9 @@
#' @param lwd number line width
#' @param randomCensored logical. Show censored values as randomized.
#' @param prettyDate logical use 'pretty' limits for date axis if TRUE, or force the yearStart/yearEnd as limits if FALSE
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters
#' @keywords graphics water-quality statistics
#' @export
......@@ -41,7 +44,8 @@
#' plotConcTimeDaily(eList)
plotConcTimeDaily<-function(eList, yearStart=NA, yearEnd=NA, tinyPlot = FALSE,
concMax = NA, printTitle = TRUE,cex=0.8, cex.axis=1.1,randomCensored=FALSE,
cex.main=1.1, customPar=FALSE,col="black",lwd=1,prettyDate=TRUE,...){
cex.main=1.1, customPar=FALSE,col="black",lwd=1,
prettyDate=TRUE, usgsStyle = FALSE,...){
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -86,7 +90,8 @@ plotConcTimeDaily<-function(eList, yearStart=NA, yearEnd=NA, tinyPlot = FALSE,
yCombined <- c(yHigh,subDaily$ConcDay)
yInfo <- generalAxis(x = yCombined, minVal = yBottom, maxVal = concMax,
tinyPlot = tinyPlot, padPercent = 5,units=localINFO$param.units)
tinyPlot = tinyPlot, padPercent = 5,units=localINFO$param.units,
usgsStyle = usgsStyle)
genericEGRETDotPlot(x=xSample, y=yHigh, xTicks=xInfo$ticks, yTicks=yInfo$ticks,
xlim=c(xInfo$bottom,xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
......@@ -106,7 +111,7 @@ plotConcTimeDaily<-function(eList, yearStart=NA, yearEnd=NA, tinyPlot = FALSE,
yCombined <- c(yHigh,subDaily$ConcDay)
yInfo <- generalAxis(x = yCombined, minVal = yBottom, maxVal = concMax,
tinyPlot = tinyPlot, padPercent = 5,units=localINFO$param.units)
tinyPlot = tinyPlot, padPercent = 5,units=localINFO$param.units,usgsStyle = usgsStyle)
genericEGRETDotPlot(x=xSample[subSample$Uncen == 1], y=yHigh[subSample$Uncen == 1], xTicks=xInfo$ticks, yTicks=yInfo$ticks,
xlim=c(xInfo$bottom,xInfo$top), ylim=c(yInfo$bottom,yInfo$top),
ylab=yInfo$label,plotTitle=plotTitle,cex.axis=cex.axis,col=col,lwd=lwd,cex=cex,
......
......@@ -42,6 +42,9 @@
#' @param colors color vector of lines on plot, see ?par 'Color Specification'. Defaults to c("black","red","green")
#' @param lineVal vector of line types. Defaults to c(1,1,1) which is a solid line for each line. Options: 0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash
#' @param edgeAdjust logical specifying whether to use the modified method for calculating the windows at the edge of the record. The modified method tends to reduce curvature near the start and end of record. Default is TRUE.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters
#' @keywords water-quality statistics graphics
#' @export
......@@ -61,7 +64,7 @@ plotConcTimeSmooth<-function (eList, q1, q2, q3, centerDate, yearStart, yearEnd,
printValues = FALSE, tinyPlot=FALSE, minNumObs = 100, minNumUncen = 50,
windowY = 10, windowQ = 2, windowS = 0.5, cex.main = 1.1, lwd = 2, printLegend = TRUE,
cex.legend = 1.2, cex=0.8, cex.axis=1.1, customPar=FALSE,lineVal=c(1,1,1),logScale=FALSE,
edgeAdjust=TRUE,...){
edgeAdjust=TRUE, usgsStyle = FALSE,...){
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -156,7 +159,8 @@ plotConcTimeSmooth<-function (eList, q1, q2, q3, centerDate, yearStart, yearEnd,
xInfo <- generalAxis(x=x, minVal=yearStart, maxVal=yearEnd, tinyPlot=tinyPlot)
combinedY <- c(y[1,], y[2,],y[3,])
yInfo <- generalAxis(x=combinedY, minVal=concMin, maxVal=yTop,
tinyPlot=tinyPlot,logScale=logScale, units=localINFO$param.units)
tinyPlot=tinyPlot,logScale=logScale, units=localINFO$param.units,
usgsStyle = usgsStyle)
genericEGRETDotPlot(x=x, y=y[1, ],
xTicks=xInfo$ticks, yTicks=yInfo$ticks,
......
......@@ -31,9 +31,9 @@
#' @param yTicks vector of yTick labels and marks that will be plotted in log space. (for example yTicks = c(3, 5, 10, 20, 50, 100, 200, 400). The first and last values determine the range of the y axis. If NA, the tick marks will be automatically generated.
#' @param cex.main magnification to be used for main titles relative to the current setting of cex
#' @param cex.axis magnification to be used for axis annotation relative to the current setting of cex
#' @param tick.lwd line width for axis ticks, default is 2
#' @param lwd numeric, line width of flowDuration curve, default is 1
#' @param tcl numeric, length of tick marks in inches, default is 0.1
#' @param tick.lwd line width for axis ticks, default is 1
#' @param lwd numeric, line width of flowDuration curve, default is 2
#' @param tcl numeric, length of tick marks in inches, default is 0.03
#' @param color.palette a function that creates a color palette for the contour plot. Default goes from white to gray to blue to red
#' using the function \code{colorRampPalette(c("white","gray","blue","red"))}. A few preset options are heat.colors, topo.colors, and terrain.colors.
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters
......@@ -69,9 +69,9 @@
#' contourLevels = clevel,customPar=TRUE,printTitle=FALSE,flowDuration=FALSE)
plotContours<-function(eList, yearStart, yearEnd, qBottom=NA, qTop=NA, whatSurface = 3,
qUnit = 2, contourLevels = NA, span = 60, pval = 0.05,
printTitle = TRUE, vert1 = NA, vert2 = NA, horiz = NA, tcl=0.1,
flowDuration = TRUE, customPar=FALSE, yTicks=NA,tick.lwd=2,usgsStyle = FALSE,
lwd=1,cex.main=1,cex.axis=1,color.palette=colorRampPalette(c("white","gray","blue","red")),...) {
printTitle = TRUE, vert1 = NA, vert2 = NA, horiz = NA, tcl=0.03,
flowDuration = TRUE, customPar=FALSE, yTicks=NA,tick.lwd=1,usgsStyle = FALSE,
lwd=2,cex.main=1,cex.axis=1,color.palette=colorRampPalette(c("white","gray","blue","red")),...) {
localINFO <- getInfo(eList)
localDaily <- getDaily(eList)
......@@ -200,7 +200,7 @@ plotContours<-function(eList, yearStart, yearEnd, qBottom=NA, qTop=NA, whatSurfa
logY <- log(y,10)
filled.contour(x,log(y,10),surft,levels=contourLevels,xlim=c(yearStart,yearEnd),
ylim=c(log(yTicks[1],10),log(yTicks[nYTicks],10)),
xlab="",xaxs="i",yaxs="i",cex.main=cex.main,
xaxs="i",yaxs="i",
color.palette=color.palette, # ...,
plot.axes={
......@@ -222,8 +222,11 @@ plotContours<-function(eList, yearStart, yearEnd, qBottom=NA, qTop=NA, whatSurfa
segments(rep(grconvertX(grconvertX(par("usr")[2],from="user",to="inches")-tcl,from="inches",to="user"),length(yTicks)), log(yTicks,10), rep(yearEnd,length(yTicks)),log(yTicks,10), lwd = tick.lwd)
},
plot.title = {
if(printTitle) title(main = plotTitle,outer=TRUE,cex.main=cex.main, line=-3)
mtext(yLab,2,cex=cex.main,line=2,las=0)
if(printTitle) {
title(main = plotTitle, ylab = yLab,cex.main = cex.main)
} else {
title(main = NULL, ylab = yLab)
}
}
)
......
......@@ -69,10 +69,10 @@
#' customPar=TRUE,flowDuration=FALSE)
plotDiffContours<-function (eList, year0, year1,
qBottom=NA, qTop=NA, maxDiff=NA,
whatSurface = 3, tcl=0.1,
whatSurface = 3, tcl=0.03,
qUnit = 2, span = 60, pval = 0.05, printTitle = TRUE, plotPercent = FALSE,
vert1 = NA, vert2 = NA, horiz = NA, flowDuration = TRUE, yTicks=NA,tick.lwd=2,
lwd=1,cex.main=0.95,cex.axis=1,customPar=FALSE,usgsStyle = FALSE,
vert1 = NA, vert2 = NA, horiz = NA, flowDuration = TRUE, yTicks=NA,tick.lwd=1,
lwd=2,cex.main=0.95,cex.axis=1,customPar=FALSE,usgsStyle = FALSE,
color.palette=colorRampPalette(c("blue","white","red")),...) {
localINFO <- getInfo(eList)
......@@ -218,7 +218,7 @@ plotDiffContours<-function (eList, year0, year1,
filled.contour(x, log(y, 10), difft, levels = contourLevels,
xlim = c(0,1), ylim = c(log(yTicks[1],
10), log(yTicks[nYTicks], 10)), #main = plotTitle,
xlab = "", xaxs = "i", yaxs = "i", cex.main = cex.main,
xaxs = "i", yaxs = "i",
plot.axes = {
axis(1, tcl = 0, at = xTicks, labels = xLabels, cex.axis=0.9*cex.axis)
axis(2, tcl = 0, las = 1, at = log(yTicks, 10),
......@@ -238,8 +238,11 @@ plotDiffContours<-function (eList, year0, year1,
},
plot.title = {
if(printTitle) title(main = plotTitle,outer=TRUE,cex.main=cex.main, line=-3)
mtext(yLab,2,cex=cex.main,line=2,las=0)
if(printTitle) {
title(main = plotTitle, ylab = yLab,cex.main = cex.main)
} else {
title(main = NULL, ylab = yLab)
}
},
color.palette=color.palette,...)
......
......@@ -44,15 +44,6 @@
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotFlowSingle(eList, 1)
#' \dontrun{
#' siteNumber <- '01010000'
#' StartDate <- ''
#' EndDate <- '2014-10-01'
#' Daily <- readNWISDaily(siteNumber, '00060', StartDate, EndDate)
#' INFO <- readNWISInfo(siteNumber, '00060', interactive = FALSE)
#' eList <- as.egret(INFO, Daily)
#' plotFlowSingle(eList, 5)
#' }
plotFlowSingle<-function(eList, istat,yearStart=NA, yearEnd = NA,
qMax = NA, printTitle = TRUE, tinyPlot = FALSE, customPar=FALSE,
runoff = FALSE, qUnit = 1, printStaName = TRUE, printPA = TRUE, usgsStyle=FALSE,
......
......@@ -39,14 +39,13 @@
#' yearEnd <- 2010
#' eList <- Choptank_eList
#' # Water year:
#' \dontrun{
#' \donttest{
#' plotFluxHist(eList)
#' plotFluxHist(eList, yearStart, yearEnd, fluxUnit = 1)
#' plotFluxHist(eList, yearStart, yearEnd, fluxUnit = 'kgDay')
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotFluxHist(eList)
#'
#' plotFluxHist(eList) #'
#' }
plotFluxHist<-function(eList, yearStart = NA, yearEnd = NA,
fluxUnit = 9, fluxMax = NA, printTitle = TRUE, usgsStyle = FALSE,
......
......@@ -24,6 +24,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param randomCensored logical. Show censored values as randomized.
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels.
......@@ -41,7 +42,7 @@
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotFluxTimeDaily(eList)
plotFluxTimeDaily<-function (eList, yearStart=NA, yearEnd=NA,
tinyPlot = FALSE, fluxUnit = 3, fluxMax = NA,
tinyPlot = FALSE, fluxUnit = 3, fluxMax = NA, randomCensored=FALSE,
printTitle = TRUE, usgsStyle = FALSE, cex=0.8, cex.axis=1.1,cex.main=1.1,
customPar=FALSE,col="black",lwd=1,prettyDate=TRUE,...) {
......@@ -106,6 +107,11 @@ plotFluxTimeDaily<-function (eList, yearStart=NA, yearEnd=NA,
""
}
if (tinyPlot) {
yLab <- fluxUnit@unitExpressTiny
} else {
yLab <- ifelse(usgsStyle,fluxUnit@unitUSGS,fluxUnit@unitExpress)
}
###################################
yBottom <- 0
......@@ -115,24 +121,41 @@ plotFluxTimeDaily<-function (eList, yearStart=NA, yearEnd=NA,
yCombined <- c(yHigh,subDaily$ConcDay*subDaily$Q*fluxFactor)
yInfo <- generalAxis(x=yCombined, minVal=yBottom, maxVal=fluxMax, tinyPlot=tinyPlot,padPercent=5)
if(!randomCensored){
if (tinyPlot) {
yLab <- fluxUnit@unitExpressTiny
yInfo <- generalAxis(x=yCombined, minVal=yBottom, maxVal=fluxMax, tinyPlot=tinyPlot,padPercent=5)
genericEGRETDotPlot(x=xSample, y=yHigh,
xlim = c(xInfo$bottom, xInfo$top), ylim = c(yInfo$bottom, yInfo$top),
xTicks=xInfo$ticks, yTicks=yInfo$ticks,
ylab = yLab, customPar=customPar,cex=cex,
plotTitle=plotTitle, tinyPlot=tinyPlot,cex.axis=cex.axis,
cex.main=cex.main,col=col,lwd=lwd, xDate=TRUE,...
)
censoredSegments(yBottom=yInfo$bottom,yLow=yLow,yHigh=yHigh,x=xSample,Uncen=Uncen,col=col,lwd=lwd)
} else {
yLab <- ifelse(usgsStyle,fluxUnit@unitUSGS,fluxUnit@unitExpress)
if(!("rObserved" %in% names(localSample))){
eList <- makeAugmentedSample(eList)
localSample <- eList$Sample
subSample<-localSample[localSample$DecYear>=yearStart & localSample$DecYear<= yearEnd,]
}
yCombined <- c(yHigh,subDaily$rObserved*subDaily$Q*fluxFactor)
yInfo <- generalAxis(x=yCombined, minVal=yBottom, maxVal=fluxMax, tinyPlot=tinyPlot,padPercent=5)
genericEGRETDotPlot(x=xSample, y=yHigh,
xlim = c(xInfo$bottom, xInfo$top), ylim = c(yInfo$bottom, yInfo$top),
xTicks=xInfo$ticks, yTicks=yInfo$ticks,
ylab = yLab, customPar=customPar,cex=cex,
plotTitle=plotTitle, tinyPlot=tinyPlot,cex.axis=cex.axis,
cex.main=cex.main,col=col,lwd=lwd, xDate=TRUE,...
)
points(x=xSample[Uncen == 0], y=yHigh[Uncen == 0], pch=1,cex=cex,col=col)
}
genericEGRETDotPlot(x=xSample, y=yHigh,
xlim = c(xInfo$bottom, xInfo$top), ylim = c(yInfo$bottom, yInfo$top),
xTicks=xInfo$ticks, yTicks=yInfo$ticks,
ylab = yLab, customPar=customPar,cex=cex,
plotTitle=plotTitle, tinyPlot=tinyPlot,cex.axis=cex.axis,
cex.main=cex.main,col=col,lwd=lwd, xDate=TRUE,...
)
lines(xDaily, subDaily$ConcDay*subDaily$Q*fluxFactor,col=col,lwd=lwd)
censoredSegments(yBottom=yInfo$bottom,yLow=yLow,yHigh=yHigh,x=xSample,Uncen=Uncen,col=col,lwd=lwd)
if (!tinyPlot) mtext(title2,side=3,line=-1.5)
}
\ No newline at end of file
......@@ -26,7 +26,7 @@
#' @seealso \code{\link{plotFlowSingle}}
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#' \donttest{
#' #Water year:
#' plotFour(eList)
#' # Graphs consisting of Jun-Aug
......
......@@ -25,7 +25,7 @@
#' @seealso \code{\link{plotFlowSingle}}
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#' \donttest{
#' # Water year:
#' plotFourStats(eList)
#' # Graphs consisting of Jun-Aug
......
......@@ -23,6 +23,9 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param usgsStyle logical option to use USGS style guidelines. Setting this option
#' to TRUE does NOT guarantee USGS complience. It will only change automatically
#' generated labels.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
......@@ -37,7 +40,8 @@
#' plotResidQ(eList)
plotResidQ<-function (eList, qUnit = 2,
tinyPlot = FALSE, stdResid = FALSE, printTitle = TRUE,col="black",lwd=1,
cex=0.8, cex.axis=1.1,cex.main=1.1,rmSciX=FALSE, customPar=FALSE,randomCensored=FALSE,...){
cex=0.8, cex.axis=1.1,cex.main=1.1,rmSciX=FALSE, customPar=FALSE,
randomCensored=FALSE,usgsStyle=FALSE,...){
localINFO <- getInfo(eList)
localSample <- getSample(eList)
......@@ -73,7 +77,7 @@ plotResidQ<-function (eList, qUnit = 2,
xLab <- qUnit@qUnitTiny
yLab <- ifelse(stdResid, "Standardized residual", "Residual")
} else {
xLab <- qUnit@qUnitExpress
xLab <- ifelse(usgsStyle, qUnit@unitUSGS, qUnit@qUnitExpress)
yLab <- ifelse(stdResid, "Standardized residual in natural log units", "Residual in natural log units")
}
......
......@@ -29,7 +29,7 @@
#' @seealso \code{\link{selectDays}}, \code{\link{genericEGRETDotPlot}}
#' @examples
#' eList <- Choptank_eList
#' \dontrun{
#' \donttest{
#' # Water year:
#' plotSDLogQ(eList)
#' plotSDLogQ(eList, 1998,2000)
......
......@@ -9,7 +9,7 @@
#' @return INFO dataframe
#' @export
#' @examples
#' \dontrun{
#' \donttest{
#' library(dataRetrieval)
#' INFO <- readNWISsite('01594440')
#' parameterCd <- "01075"
......
......@@ -9,7 +9,7 @@
#' @return INFO dataframe
#' @export
#' @examples
#' \dontrun{
#' \donttest{
#' library(dataRetrieval)
#' INFO <- readNWISsite('01594440')
#' siteNumber <- "01594440"
......
......@@ -12,7 +12,7 @@
#' @export
#' @seealso \code{\link[dataRetrieval]{readWQPqw}}
#' @examples
#' \dontrun{
#' \donttest{
#' library(dataRetrieval)
#'
#' rawWQP <- readWQPqw('21FLEECO_WQX-IMPRGR80','Phosphorus', '', '')
......@@ -30,11 +30,15 @@ processQWData <- function(data,pCode=TRUE){
qualifier[grep("DETECTED NOT QUANTIFIED",detectText)] <- "<"
qualifier[grep("BELOW QUANTIFICATION LIMIT",detectText)] <- "<"
qualifier[!is.na(data$DetectionQuantitationLimitMeasure.MeasureValue) &&
qualifier[!is.na(data$DetectionQuantitationLimitMeasure.MeasureValue) &
data$ResultMeasureValue < data$DetectionQuantitationLimitMeasure.MeasureValue] <- "<"
correctedData<-ifelse((nchar(qualifier)==0),data$ResultMeasureValue,data$DetectionQuantitationLimitMeasure.MeasureValue)
test <- data.frame(data$USGSPCode)
if(pCode){
test <- data.frame(data$USGSPCode)
} else {
test <- data.frame(data$CharacteristicName)
}
test$dateTime <- data$ActivityStartDate
......
......@@ -37,7 +37,7 @@
#' @examples
#' # These examples require an internet connection to run
#' # Automatically gets information about site 05114000 and temperature
#' \dontrun{
#' \donttest{
#' INFO <- readNWISInfo('05114000','00010')
#' }
readNWISInfo <- function(siteNumber, parameterCd,interactive=TRUE){
......@@ -81,7 +81,7 @@ readNWISInfo <- function(siteNumber, parameterCd,interactive=TRUE){
#' # Automatically gets information about site 01594440 and temperature, no interaction with user
#' nameToUse <- 'Specific conductance'
#' pcodeToUse <- '00095'
#' \dontrun{
#' \donttest{
#' INFO <- readWQPInfo('USGS-04024315',pcodeToUse)
#'
#' INFO2 <- readWQPInfo('WIDNR_WQX-10032762',nameToUse)
......@@ -221,12 +221,17 @@ readWQPInfo <- function(siteNumber, parameterCd, interactive=TRUE){
#' @export
#' @examples
#' filePath <- system.file("extdata", package="EGRET")
#' filePath <- paste(filePath,"/",sep="")
#' fileName <- 'infoTest.csv'
#' INFO <- readUserInfo(filePath,fileName, separator=",",interactive=FALSE)
readUserInfo <- function(filePath,fileName,hasHeader=TRUE,separator=",",interactive=TRUE){
totalPath <- paste(filePath,fileName,sep="")
# Keeping things backwards compatible:
if("/" == substr(filePath, nchar(filePath), nchar(filePath))){
filePath <- substr(filePath, 1, nchar(filePath)-1)
}
totalPath <- file.path(filePath, fileName)
if(file.exists(totalPath)){
siteInfo <- read.delim(
totalPath,
......@@ -326,8 +331,13 @@ readUserInfo <- function(filePath,fileName,hasHeader=TRUE,separator=",",interact
}
}
localUnits <- toupper(siteInfo$param.units)
if(length(grep("MG/L", localUnits)) == 0){
localUnits <- toupper(siteInfo$param.units)
possibleGoodUnits <- c("mg/l","mg/l as N", "mg/l as NO2",
"mg/l as NO3","mg/l as P","mg/l as PO3","mg/l as PO4","mg/l as CaCO3",
"mg/l as Na","mg/l as H","mg/l as S","mg/l NH4" )
allCaps <- toupper(possibleGoodUnits)
if(!(localUnits %in% allCaps)){
if(interactive){
message("Required concentration units are mg/l. \nThe INFO dataframe indicates:",siteInfo$param.units,
"\nFlux calculations will be wrong if units are not consistent")
......
#' Import NWIS Daily Data for EGRET analysis
#'
#' Imports daily data from NWIS web service. This function gets the data from here: \url{https://waterservices.usgs.gov/}
#' A list of parameter codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/}
#' A list of statistic codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
#'
#' @param siteNumber character USGS site number. This is usually an 8 digit number
#' @param parameterCd character USGS parameter code. This is usually an 5 digit number.
......@@ -33,7 +31,7 @@
#' }
#' @seealso \code{\link[dataRetrieval]{readNWISdv}}, \code{\link{populateDaily}}
#' @examples
#' \dontrun{
#' \donttest{
#'
#' Daily <- readNWISDaily('01594440','00060', '1985-01-01', '1985-03-31')
#' DailySuspSediment <- readNWISDaily('01594440','80154', '1985-01-01', '1985-03-31',convert=FALSE)
......
#' Import NWIS Sample Data for EGRET analysis
#'
#' Imports data from NWIS web service. This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/qwdata/}
#' Imports data from NWIS web service.
#' A list of parameter and statistic codes can be found here: \url{https://help.waterdata.usgs.gov/codes-and-parameters}
#' For raw data, use \code{\link[dataRetrieval]{readNWISqw}} from the dataRetrieval package. This function will retrieve the raw data, and compress it (summing constituents). See
#' section 3.2.4 of the vignette for more details.
......@@ -32,7 +32,7 @@
#' @seealso \code{\link{compressData}}, \code{\link{populateSampleColumns}},
#' \code{\link[dataRetrieval]{readNWISqw}}
#' @examples
#' \dontrun{
#' \donttest{
#' # These examples require an internet connection to run
#'
#' Sample_01075 <- readNWISSample('01594440','01075', '1985-01-01', '1985-03-31')
......
......@@ -35,7 +35,7 @@
#' @examples
#' filePath <- system.file("extdata", package="EGRET")
#' fileName <- 'ChoptankRiverNitrate.csv'
#' Sample <- readUserSample(filePath,fileName, separator=";",interactive=FALSE)
#' Sample <- readUserSample(filePath,fileName, separator=";",verbose=FALSE)
readUserSample <- function (filePath,fileName,hasHeader=TRUE,separator=",", verbose=TRUE, interactive=NULL){
if(!is.null(interactive)) {
......
......@@ -33,7 +33,7 @@
#' \code{\link[dataRetrieval]{readWQPqw}}, \code{\link{compressData}}, \code{\link{populateSampleColumns}}
#' @examples
#' # These examples require an internet connection to run
#' \dontrun{
#' \donttest{
#' Sample_All <- readWQPSample('WIDNR_WQX-10032762','Specific conductance', '', '')
#' }
readWQPSample <- function(siteNumber,characteristicName,startDate,endDate,verbose = TRUE, interactive=NULL){
......
......@@ -32,8 +32,10 @@
#' to the first Date in eList$Sample.
#' @param sampleEndDate The Date (as character in YYYY-MM-DD) of the last sample to be used.
#' Default is NA which sets it to the last Date in eList$Sample.
#' @param paLong numeric integer specifying the length of the period of analysis, in months, 1<=paLong<=12, default is 12.
#' @param paStart numeric integer specifying the starting month for the period of analysis, 1<=paStart<=12, default is 10 (used when period is water year).
#' @param paLong numeric integer specifying the length of the period of analysis, in months, 1<=paLong<=12.
#' Default is NA, which will use the paLong in the eList$INFO data frame. See also \code{\link{setPA}}.
#' @param