Skip to content

Commit

Permalink
Merge pull request #275 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
update version
  • Loading branch information
ldecicco-USGS authored Aug 26, 2016
2 parents 9c00e51 + 047bb46 commit 805fb9c
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 5 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: dataRetrieval
Type: Package
Title: Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data
Version: 2.5.12
Date: 2016-08-08
Version: 2.6.0
Date: 2016-08-26
Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "[email protected]"),
person("Laura", "DeCicco", role = c("aut","cre"),
Expand All @@ -13,7 +13,7 @@ Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "[email protected]"),
person("Lindsay","Carr", role=c("ctb"),
email = "[email protected]"),
person("David","Watkins", role=c("ctb"),
person("David","Watkins", role=c("aut"),
email = "[email protected]"))
Description: Collection of functions to help retrieve U.S. Geological Survey
(USGS) and U.S. Environmental Protection Agency (EPA) water quality and
Expand Down
35 changes: 35 additions & 0 deletions man/readNGWMNlevels.Rd

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

41 changes: 41 additions & 0 deletions man/readNGWMNsites.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/tests_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,48 @@ test_that("General NWIS retrievals working", {
multiSite <- readNWISdata(sites=c("04025500","040263491"), service="iv",
parameterCd="00060")
expect_is(multiSite$dateTime, 'POSIXct')
# saveRDS(multiSite, "rds/multiSite.rds")

bBoxEx <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010")
expect_that(length(unique(bBoxEx$site_no)) > 1, is_true())
# saveRDS(bBoxEx, "rds/bBoxEx.rds")

startDate <- as.Date("2013-10-01")
endDate <- as.Date("2014-09-30")
waterYear <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010",
service="dv", startDate=startDate, endDate=endDate)
# saveRDS(waterYear, "rds/waterYear.rds")
expect_is(waterYear$dateTime, 'POSIXct')

siteInfo <- readNWISdata(stateCd="WI", parameterCd="00010",hasDataTypeCd="iv",
service="site")
# saveRDS(siteInfo,"rds/siteInfo.rds")
expect_is(siteInfo$station_nm, "character")

qwData <- readNWISdata(bBox=c(-82.5,41.52,-81,41),startDate=as.Date("2000-01-01"),
drain_area_va_min=50, qw_count_nu=50,qw_attributes="expanded",
qw_sample_wide="wide",list_of_search_criteria=c("lat_long_bounding_box",
"drain_area_va","obs_count_nu"),service="qw")
# saveRDS(qwData, "rds/qwData.rds")
expect_is(qwData$startDateTime, "POSIXct")

url <- "http://waterservices.usgs.gov/nwis/dv/?site=09037500&format=rdb&ParameterCd=00060&StatCd=00003&startDT=1985-10-02&endDT=2012-09-06"
dv <- importRDB1(url, asDateTime = FALSE)

urlEmpty <- "http://nwis.waterdata.usgs.gov/nwis/qwdata?multiple_site_no=413437087150601&sort_key=site_no&group_key=NONE&inventory_output=0&begin_date=&end_date=&TZoutput=0&param_group=NUT,INN&qw_attributes=0&format=rdb&qw_sample_wide=0&rdb_qw_attributes=expanded&date_format=YYYY-MM-DD&rdb_compression=value&list_of_search_criteria=multiple_site_no"
dv <- importRDB1(urlEmpty, asDateTime = FALSE)
# saveRDS(dv, "rds/emptyDV.rds")
expect_that(nrow(dv) == 0, is_true())

dailyStat <- readNWISdata(site=c("03112500","03111520"),service="stat",statReportType="daily",
statType=c("p25","p50","p75","min","max"),parameterCd="00065",convertType=FALSE)
# saveRDS(dailyStat,"rds/dailyStat.rds")
expect_that(length(dailyStat$min_va) > 1, is_true())
expect_is(dailyStat$p25_va,"character")

waterYearStat <- readNWISdata(site=c("03112500"),service="stat",statReportType="annual",
statYearType="water", missingData="on")
# saveRDS(waterYearStat, "rds/waterYearStat.rds")
expect_is(waterYearStat$mean_va,"numeric")
expect_is(waterYearStat$parameter_cd,"character")
})
Expand Down
13 changes: 11 additions & 2 deletions tests/testthat/tests_imports.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test_that("CRAN-friendly importWaterML1 test", {
fileName <- "WaterML1Example.xml"
fullPath <- file.path(filePath, fileName)
importUserWML1 <- importWaterML1(fullPath, asDateTime = TRUE)

# saveRDS(importUserWML1, "rds/importUserWML1.rds")
# default is to turn dates to characters
expect_is(importUserWML1$dateTime, 'POSIXct')

Expand All @@ -83,6 +83,7 @@ test_that("External importWaterML1 test", {
obs_url <- constructNWISURL(siteNumber,property,startDate,endDate,'dv')

data <- importWaterML1(obs_url,TRUE)
# saveRDS(data, "rds/dvWML1.rds")
expect_is(data$dateTime, 'POSIXct')

groundWaterSite <- "431049071324301"
Expand All @@ -91,6 +92,7 @@ test_that("External importWaterML1 test", {
groundwaterExampleURL <- constructNWISURL(groundWaterSite, NA,
startGW,endGW, service="gwlevels")
groundWater <- importWaterML1(groundwaterExampleURL)
# saveRDS(groundWater, "rds/groundwater.rds")

expect_is(groundWater$dateTime, 'character')

Expand All @@ -103,6 +105,7 @@ test_that("External importWaterML1 test", {
siteNumber <- c('01480015',"04085427") #one site seems to have lost it's 2nd dd
obs_url <- constructNWISURL(siteNumber,c("00060","00010"),startDate,endDate,'dv')
data <- importWaterML1(obs_url)
# saveRDS(data, "rds/twoWML1.rds")
expect_that(length(unique(data$site_no)) == 2, is_true())
expect_that(ncol(data) == 8, is_true()) # 3 data, 3 remark codes, and 4 (agency, site, dateTime, tz)

Expand All @@ -114,6 +117,7 @@ test_that("External importWaterML1 test", {
inactiveAndActive <- c("07334200","05212700")
inactiveAndActive <- constructNWISURL(inactiveAndActive, "00060", "2014-01-01", "2014-01-10",'dv')
inactiveAndActive <- importWaterML1(inactiveAndActive)
# saveRDS(inactiveAndActive, "rds/inactiveAndActive.rds")
expect_that(length(unique(inactiveAndActive$site_no)) == 1, is_true())

#raw XML
Expand All @@ -138,23 +142,28 @@ test_that("External importWaterML1 test", {
})

context("importWaterML2")

test_that("importWaterML2 internal test", {
filePath <- system.file("extdata", package="dataRetrieval")
fileName <- "WaterML2Example.xml"
fullPath <- file.path(filePath, fileName)
UserData <- importWaterML2(fullPath)
# saveRDS(UserData, "rds/UserData.rds")
expect_is(UserData$value, 'numeric')
expect_is(UserData$qualifier, 'character')

})

test_that("importWaterML2 external test", {
testthat::skip_on_cran()
url <- "http://waterservices.usgs.gov/nwis/iv/?format=waterml,2.0&sites=01646500&parameterCd=00060,00065"
data <- importWaterML2(url)
# saveRDS(data, "rds/externalML2.rds")
expect_is(data$value, 'numeric')
expect_gt(nrow(data),0)
})

})


context("importWQP_noCRAN")

Expand Down

0 comments on commit 805fb9c

Please sign in to comment.