Skip to content

Commit

Permalink
Merge pull request #129 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
gwlevels to rdb
  • Loading branch information
ldecicco-USGS committed Jun 30, 2015
2 parents 070b712 + cfda167 commit ccd734a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data
Version: 2.2.3
Version: 2.3.0
Date: 2015-06-29
Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "[email protected]"),
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
dataRetrieval 2.3.0
===========
* Converted all Water Quality Portal queries to sorted=no to greatly improve retrieval times
* Converted gwlevels in readNWISdata to rdb


dataRetrieval 2.2.0
===========
* Changed the output of tz_cd (in all *NWIS functions) to the timezone that is reported in the data frame. Before this version, it was the time zone reported by NWIS. This was confusing however since the dateTime columns default to UTC.
Expand Down
16 changes: 6 additions & 10 deletions R/readNWISdata.r
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#' "drain_area_va","obs_count_nu"),service="qw")
#' temp <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010", service="site",
#' seriesCatalogOutput=TRUE)
#' wiGWL <- readNWISdata(stateCd="WI",service="gwlevels")
#' }
readNWISdata <- function(service="dv", ...){

Expand Down Expand Up @@ -153,7 +154,7 @@ readNWISdata <- function(service="dv", ...){
tz <- ""
}

if(service == "site"){
if(service %in% c("site","gwlevels")){
format <- "rdb"
}

Expand All @@ -162,14 +163,15 @@ readNWISdata <- function(service="dv", ...){
baseURL <- paste0(baseURL,service,"/?format=",format,"&")
urlCall <- paste0(baseURL,urlCall)

if(service == "site"){
if(format == "rdb"){
possibleError <- tryCatch({
retval <- importRDB1(urlCall, asDateTime = FALSE, qw = FALSE, tz = tz)
retval <- importRDB1(urlCall, asDateTime = (service == "qwdata"),
qw = (service == "qwdata"), tz = tz)
}, error = function(e) {
stop(e, "with url:", urlCall)
})

} else if (service != "qwdata") {
} else {
possibleError <- tryCatch({
retval <- importWaterML1(urlCall, asDateTime = ("iv" == service), tz= tz)
}, error = function(e) {
Expand Down Expand Up @@ -202,12 +204,6 @@ readNWISdata <- function(service="dv", ...){
}
}

} else {
possibleError <- tryCatch({
retval <- importRDB1(urlCall, asDateTime = TRUE, qw = TRUE)
}, error = function(e) {
stop(e, "with url:", urlCall)
})
}

return(retval)
Expand Down
2 changes: 1 addition & 1 deletion R/readWQPqw.r
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ readWQPqw <- function(siteNumbers,parameterCd,startDate="",endDate="",tz=""){
startDateLo=startDate, startDateHi=endDate)
} else {
siteInfo <- whatWQPsites(siteid=paste0(siteNumbers,collapse=";"),
characteristicName=paste0(parameterCd,collapse=";"),
characteristicName=URLencode(paste0(parameterCd,collapse=";")),
startDateLo=startDate, startDateHi=endDate)
}

Expand Down
1 change: 1 addition & 0 deletions man/readNWISdata.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ qwData <- readNWISdata(bBox=c(-82.5,41.52,-81,41),startDate=as.Date("2000-01-01"
"drain_area_va","obs_count_nu"),service="qw")
temp <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010", service="site",
seriesCatalogOutput=TRUE)
wiGWL <- readNWISdata(stateCd="WI",service="gwlevels")
}
}
\seealso{
Expand Down
14 changes: 12 additions & 2 deletions tests/testthat/tests_userFriendly_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,15 @@ test_that("NWIS dv tests", {
expect_that(nrow(notActive) == 0, is_true())
})



test_that("WQP qw tests", {
testthat::skip_on_cran()
nameToUse <- 'Specific conductance'
pcodeToUse <- '00095'

INFO_WQP <- readWQPqw('USGS-04024315',pcodeToUse, startDate = "", endDate = "")
expect_is(INFO_WQP$ActivityStartDateTime, 'POSIXct')

INFO2 <- readWQPqw('WIDNR_WQX-10032762',nameToUse, startDate = "", endDate = "")
expect_is(INFO2$ActivityStartDateTime, 'POSIXct')

})

0 comments on commit ccd734a

Please sign in to comment.