Skip to content

Commit

Permalink
Merge pull request #374 from ldecicco-USGS/main
Browse files Browse the repository at this point in the history
Fixes #373
  • Loading branch information
ldecicco-USGS authored Oct 16, 2023
2 parents 57fd93f + dd97889 commit e1630e6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ jobs:
steps:
- uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196

- uses: r-lib/actions/setup-pandoc@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-pandoc@4a9a68ffb70ac0fc90d9683fae64a0d779f7d0fe

- uses: r-lib/actions/setup-r@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-r@3e80f8fe880a36a9f35bf3e832f1bef8af687b69
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-r-dependencies@e93f9af25505a6e249a7ae3bbaaa9413db8a0de4
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/check-r-package@d26c5f95c4f10c7444cec87a1effe7d8af8897b8
with:
upload-snapshots: true
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196

- uses: r-lib/actions/setup-r@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-r@3e80f8fe880a36a9f35bf3e832f1bef8af687b69

- uses: r-lib/actions/setup-pandoc@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-pandoc@4a9a68ffb70ac0fc90d9683fae64a0d779f7d0fe

- name: Query dependencies
run: |
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
EGRET 3.0.9
===========
* Bug fix for the monthly concentration trend results in runPairs.
* Formatting and style updates in plotMonthTrend

EGRET 3.0.8
===========
* Added GenConc to tableResult function
Expand Down
35 changes: 26 additions & 9 deletions R/blankTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
#' @param eList named list with at least the Daily dataframe
#' @keywords water-quality statistics
#' @return eList named list with modified Daily data frame.
#' @details
#' The startBlank and endBlank arguments should generally coincide with the starting and
#' ending date of the period of analysis that is being used. startBlank should be
#' placed fairly close to the start of the period of no data and endBlank should
#' be placed fairly close to the end of the period of no data. They do not eliminate
#' any water quality data from the set of data being used to estimate the model,
#' they only eliminate results computed for the specified blank period. If the data
#' set has more than one large data gap the \code{blankTime()} function can be used
#' multiple times to blank out multiple sets of results.
#'
#' @export
#' @examples
#' startBlank = "2004-10-01"
Expand All @@ -20,15 +30,22 @@ blankTime<-function(eList, startBlank, endBlank) {

localDaily <- getDaily(eList)

startBlank<-as.Date(startBlank)
endBlank<-as.Date(endBlank)
startJulian<-as.numeric(julian(startBlank,origin=as.Date("1850-01-01")))
endJulian<-as.numeric(julian(endBlank,origin=as.Date("1850-01-01")))
bad<-ifelse(localDaily$Julian>=startJulian&localDaily$Julian<=endJulian,TRUE,FALSE)
localDaily$ConcDay<-ifelse(bad,NA,localDaily$ConcDay)
localDaily$FluxDay<-ifelse(bad,NA,localDaily$FluxDay)
localDaily$FNConc<-ifelse(bad,NA,localDaily$FNConc)
localDaily$FNFlux<-ifelse(bad,NA,localDaily$FNFlux)
startBlank <- as.Date(startBlank)
endBlank <- as.Date(endBlank)
startJulian <- as.numeric(julian(startBlank,origin=as.Date("1850-01-01")))
endJulian <- as.numeric(julian(endBlank,origin=as.Date("1850-01-01")))
bad <- localDaily$Julian >= startJulian &
localDaily$Julian <= endJulian
localDaily$ConcDay <- ifelse(bad,NA,localDaily$ConcDay)
localDaily$FluxDay <- ifelse(bad,NA,localDaily$FluxDay)
localDaily$FNConc <- ifelse(bad,NA,localDaily$FNConc)
localDaily$FNFlux <- ifelse(bad,NA,localDaily$FNFlux)

wrtdsK <- all(c("GenConc", "GenFlux") %in% names(localDaily))
if(wrtdsK){
localDaily$GenConc <- ifelse(bad,NA,localDaily$GenConc)
localDaily$GenFlux <- ifelse(bad,NA,localDaily$GenFlux)
}

eList$Daily <- localDaily

Expand Down
2 changes: 1 addition & 1 deletion R/errorStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ errorStats <- function(eList) {

eListR <- makeAugmentedSample(eList)
Sample <- eListR$Sample
n <- length(Sample$Dates)
# n <- length(Sample$Date)
Sample$Pred <- log(Sample$rObserved) - Sample$rResid
Sample$trueFlux <- Sample$rObserved * Sample$Q * 86.4
Sample$trueLogF <- log(Sample$trueFlux)
Expand Down
8 changes: 6 additions & 2 deletions R/readNWISSample.r
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ readNWISSample <- function(siteNumber,
expanded = TRUE)
totalColumns <- c("sample_dt", "remark_cd", "result_va")

extras <- rawSample[, c("medium_cd", "hyd_cond_cd", "samp_type_cd",
extras <- rawSample[, c("sample_dt", "medium_cd", "hyd_cond_cd", "samp_type_cd",
"hyd_event_cd", "dqi_cd", "rpt_lev_cd")]

if(length(unique(rawSample$medium_cd)) > 1){
Expand All @@ -80,9 +80,13 @@ readNWISSample <- function(siteNumber,
if(nrow(rawSample) > 0){
compressedData <- compressData(rawSample[,totalColumns],
verbose = verbose)

Sample <- populateSampleColumns(compressedData)
if(!multi_pcodes){
Sample <- cbind(Sample, extras)
Sample <- merge(x = Sample, y = extras,
by.x = "Date",
by.y = "sample_dt",
all.x = TRUE)
}

} else {
Expand Down
4 changes: 2 additions & 2 deletions R/setupYears.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ setupYears <- function(localDaily, paLong = 12, paStart = 10) {

numYears <- nrow(StartEndSeq)

DecYear<-rep(NA,numYears)
DecYear <- rep(NA,numYears)
Q <- rep(NA,numYears)
Conc <- rep(NA,numYears)
Flux <- rep(NA,numYears)
Expand Down Expand Up @@ -158,7 +158,7 @@ setupYears <- function(localDaily, paLong = 12, paStart = 10) {

AnnualResults <- AnnualResults[!is.na(AnnualResults$DecYear),]

AnnualResults <- na.omit(AnnualResults)
# AnnualResults <- na.omit(AnnualResults)

return(AnnualResults)
}
10 changes: 10 additions & 0 deletions man/blankTime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-plotFours-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plotFours-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-4-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e1630e6

Please sign in to comment.