Unverified Commit 08ee437d authored by Laura A DeCicco's avatar Laura A DeCicco Committed by GitHub
Browse files

Merge pull request #581 from ldecicco-USGS/master

Failing gracefully
parents f62b51b5 5f94aff2
......@@ -32,7 +32,8 @@ obs_url <- paste("https://cida.usgs.gov/ngwmn_cache/sos?request=GetObservation",
"observedProperty=urn:ogc:def:property:OGC:GroundWaterLevel",
"responseFormat=text/xml",
"featureOfInterest=VW_GWDP_GEOSERVER.USGS.403836085374401",sep="&")
data <- importNGWMN(obs_url)
data_returned <- importNGWMN(obs_url)
}
......
......@@ -66,22 +66,31 @@ obs_url <- constructNWISURL(site_id,property,
\donttest{
data <- importRDB1(obs_url)
urlMultiPcodes <- constructNWISURL("04085427",c("00060","00010"),
startDate,endDate,"dv",statCd=c("00003","00001"),"tsv")
multiData <- importRDB1(urlMultiPcodes)
multiData <- importRDB1(urlMultiPcodes)
unitDataURL <- constructNWISURL(site_id,property,
"2020-10-30","2020-11-01","uv",format="tsv") #includes timezone switch
unitData <- importRDB1(unitDataURL, asDateTime=TRUE)
unitData <- importRDB1(unitDataURL, asDateTime=TRUE)
qwURL <- constructNWISURL(c('04024430','04024000'),
c('34247','30234','32104','34220'),
"2010-11-03","","qw",format="rdb")
"2010-11-03","","qw",format="rdb")
qwData <- importRDB1(qwURL, asDateTime=TRUE, tz="America/Chicago")
iceSite <- '04024000'
start <- "2015-11-09"
end <- "2015-11-24"
urlIce <- constructNWISURL(iceSite,"00060",start, end,"uv",format="tsv")
ice <- importRDB1(urlIce, asDateTime=TRUE)
iceNoConvert <- importRDB1(urlIce, convertType=FALSE)
ice <- importRDB1(urlIce, asDateTime=TRUE)
iceNoConvert <- importRDB1(urlIce, convertType=FALSE)
}
# User file:
filePath <- system.file("extdata", package="dataRetrieval")
......
......@@ -35,11 +35,14 @@ rawSampleURL <- constructWQPURL('USGS-01594440','01075', '', '')
rawSample <- importWQP(rawSampleURL)
rawSampleURL_NoZip <- constructWQPURL('USGS-01594440','01075', '', '', zip=FALSE)
rawSample2 <- importWQP(rawSampleURL_NoZip, zip=FALSE)
STORETex <- constructWQPURL('WIDNR_WQX-10032762','Specific conductance', '', '')
STORETdata <- importWQP(STORETex)
STORETdata <- importWQP(STORETex)
}
}
\seealso{
\code{\link{readWQPdata}}, \code{\link{readWQPqw}}, \code{\link{whatWQPsites}}
......
......@@ -28,6 +28,8 @@ URL <- paste(baseURL, "sites=01646500",
"statCd=00003",
"parameterCd=00060",sep="&")
\donttest{
timesereies <- importWaterML2(URL, asDateTime=TRUE, tz="UTC")
}
}
}
......@@ -24,9 +24,9 @@ Retrieve site data from the National Ground Water Monitoring Network \url{https:
}
\examples{
\donttest{
#one site
#one site
site <- "USGS.430427089284901"
oneSite <- readNGWMNsites(siteNumbers = site)
oneSite <- readNGWMNsites(siteNumbers = site)
#non-USGS site
site <- "MBMG.103306"
......
......@@ -67,6 +67,7 @@ See examples below for ideas of constructing queries.
\examples{
\donttest{
# Examples not run for time considerations
dataTemp <- readNWISdata(stateCd="OH",parameterCd="00010", service="dv")
instFlow <- readNWISdata(sites="05114000", service="iv",
parameterCd="00060",
......@@ -87,32 +88,35 @@ bBoxEx <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010")
startDate <- as.Date("2013-10-01")
endDate <- as.Date("2014-09-30")
waterYear <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010",
waterYear <- readNWISdata(bBox=c(-83,36.5,-82.5,36.75), parameterCd="00010",
service="dv", startDate=startDate, endDate=endDate)
siteInfo <- readNWISdata(stateCd="WI", parameterCd="00010",
hasDataTypeCd="iv", service="site")
temp <- readNWISdata(bBox=c(-83,36.5,-81,38.5), parameterCd="00010", service="site",
temp <- readNWISdata(bBox=c(-83,36.5,-82.5,36.75), parameterCd="00010", service="site",
seriesCatalogOutput=TRUE)
wiGWL <- readNWISdata(stateCd="WI",service="gwlevels")
meas <- readNWISdata(state_cd="WI",service="measurements",format="rdb_expanded")
wiGWL <- readNWISdata(stateCd = "WI", service = "gwlevels")
meas <- readNWISdata(state_cd = "WI", service = "measurements",
format = "rdb_expanded")
waterYearStat <- readNWISdata(site=c("01646500"),service="stat",statReportType="annual",
statYearType="water", missingData="on")
waterYearStat <- readNWISdata(site = c("01646500"),
service = "stat",
statReportType="annual",
statYearType = "water",
missingData = "on")
monthlyStat <- readNWISdata(site=c("01646500"),
service="stat",
statReportType="monthly")
dailyStat <- readNWISdata(site=c("01646500"),
service="stat",
statReportType="daily",
statType=c("p25","p50","p75","min","max"),
parameterCd="00060")
dailyRI <- readNWISdata(stateCd = "Rhode Island", parameterCd = "00060")
statReportType="monthly")
dailyStat <- readNWISdata(site = c("01646500"),
service = "stat",
statReportType = "daily",
statType = c("p25","p50","p75","min","max"),
parameterCd = "00060")
arg.list <- list(site="03111548",
statReportType="daily",
statType=c("p25","p50","p75","min","max"),
parameterCd="00060")
arg.list <- list(site = "03111548",
statReportType = "daily",
statType = c("p25","p50","p75","min","max"),
parameterCd = "00060")
allDailyStats_2 <- readNWISdata(arg.list, service="stat")
#' # use county names to get data
......@@ -124,20 +128,19 @@ dailyStaffordVA <- readNWISdata(stateCd = "Virginia",
va_counties <- c("51001","51003","51005","51007","51009","51011","51013","51015")
va_counties_data <- readNWISdata(startDate = "2015-01-01", endDate = "2015-12-31",
parameterCd = "00060", countycode = va_counties)
site_id <- '01594440'
rating_curve <- readNWISdata(service = "rating", site_no = site_id, file_type="base")
all_sites_base <- readNWISdata(service = "rating", file_type="base")
all_sites_core <- readNWISdata(service = "rating", file_type="corr")
all_sites_exsa <- readNWISdata(service = "rating", file_type="exsa")
all_sites_24hrs <- readNWISdata(service = "rating", file_type="exsa", period = 24)
today <- readNWISdata(service="iv", startDate = Sys.Date(),
parameterCd = "00060", siteNumber = "05114000")
peak_data <- readNWISdata(service = "peak",
site_no = c("01594440","040851325"),
range_selection = "data_range")
}
}
\seealso{
......
......@@ -28,6 +28,7 @@ Imports data from NWIS about meaured parameter based on user-supplied parameter
This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes}
}
\examples{
paramINFO <- readNWISpCode(c('01075','00060','00931'))
paramINFO <- readNWISpCode(c('01075','00060','00931', NA))
}
......
......@@ -70,8 +70,10 @@ Imports data from USGS site file site. This function gets data from here: \url{h
}
\examples{
\donttest{
siteINFO <- readNWISsite('05114000')
siteINFOMulti <- readNWISsite(c('05114000','09423350'))
}
}
\keyword{USGS}
......
......@@ -65,6 +65,7 @@ parameterCd <- '00060'
startDate <- "2014-10-10"
endDate <- "2014-10-10"
\donttest{
rawData <- readNWISuv(site_id,parameterCd,startDate,endDate)
rawData_today <- readNWISuv(site_id, parameterCd, Sys.Date(),Sys.Date())
......@@ -79,8 +80,8 @@ centralTime <- readNWISuv(site_id,parameterCd,
# Adding 'Z' to the time indicates to the web service to call the data with UTC time:
GMTdata <- readNWISuv(site_id,parameterCd,
"2014-10-10T00:00Z", "2014-10-10T23:59Z")
}
}
}
\seealso{
\code{\link{renameNWISColumns}}, \code{\link{importWaterML1}}
......
......@@ -61,6 +61,7 @@ for more information.
}
\examples{
\donttest{
availableData <- whatNWISdata(siteNumber = '05114000')
# To find just unit value ('instantaneous') data:
uvData <- whatNWISdata(siteNumber = '05114000',service="uv")
......@@ -68,6 +69,7 @@ uvDataMulti <- whatNWISdata(siteNumber = c('05114000','09423350'),service=c("uv"
flowAndTemp <- whatNWISdata(stateCd = "WI", service = "uv",
parameterCd = c("00060","00010"),
statCd = "00003")
}
}
\keyword{USGS}
......
......@@ -36,7 +36,9 @@ Mapper format is used
}
\examples{
\donttest{
siteListPhos <- whatNWISsites(stateCd="OH",parameterCd="00665")
oneSite <- whatNWISsites(sites="05114000")
}
}
......@@ -73,10 +73,12 @@ The \code{readWQPsummary} function has
}
\examples{
\donttest{
site1 <- whatWQPsamples(siteid="USGS-01594440")
type <- "Stream"
sites <- whatWQPsamples(countycode="US:55:025",siteType=type)
}
\donttest{
......@@ -85,12 +87,14 @@ sites <- whatWQPmetrics(countycode="US:55:025",siteType=type)
lakeSites <- whatWQPmetrics(siteType = "Lake, Reservoir, Impoundment", statecode = "US:55")
}
\donttest{
site1 <- whatWQPsites(siteid="USGS-01594440")
type <- "Stream"
sites <- whatWQPsites(countycode="US:55:025",
characteristicName = "Phosphorus",
siteType=type)
}
\donttest{
site1 <- readWQPsummary(siteid="USGS-07144100",
......
......@@ -375,9 +375,8 @@ test_that("400 errors return a verbose error", {
url <- "https://waterservices.usgs.gov/nwis/site/?stateCd=IA&bBox=-92.821445,42.303044,-92.167168,42.646524&format=mapper"
expect_error(getWebServiceData(url))
expect_equal(tryCatch(getWebServiceData(url), error = function(e) e$message), "HTTP Status 400 - syntactic error: Only one Major filter can be supplied. Found [bbox] and [stateCd]. Please remove the extra major filter[s].")
expect_message(getWebServiceData(url))
})
test_that("internal functions",{
......
......@@ -43,7 +43,7 @@ test_that("External importRDB1 tests", {
format="tsv",
statCd = "laksjd")
# And....now there's data there:
expect_error(importRDB1(url))
expect_null(importRDB1(url))
})
context("importRDB")
......@@ -130,7 +130,7 @@ test_that("External importWaterML1 test", {
url <- constructNWISURL("05212700", "00060", "2014-01-01", "2014-01-10",'dv', statCd = "00001")
noData <- importWaterML1(url)
expect_true(class(attr(noData,"url"))=="character")
expect_true(all(dim(noData)==0))
expect_true(all(dim(noData) == c(0, 4)))
url <- constructNWISURL(service = 'iv', site = c('02319300','02171500'),
startDate = "2015-04-04", endDate = "2015-04-05")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment