Skip to content
Snippets Groups Projects
Commit 37ae6cb2 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Simple formatting edits to pretty up the code.

parent d3ae11f1
No related branches found
No related tags found
1 merge request!60Final CRAN 2.1 updates.
......@@ -45,7 +45,6 @@ readNWISpCode <- function(parameterCd){
newData <- importRDB1(url,asDateTime = FALSE)
} else {
#TODO: add else...
fullURL <- "http://nwis.waterdata.usgs.gov/nwis/pmcodes/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&format=rdb&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units"
fullPcodeDownload <- importRDB1(fullURL)
newData <- fullPcodeDownload[fullPcodeDownload$parameter_cd %in% parameterCd,]
......
......@@ -121,10 +121,12 @@ readWQPqw <- function(siteNumbers,parameterCd,startDate="",endDate=""){
if(pcodeCheck){
siteInfo <- whatWQPsites(siteid=paste0(siteNumbers,collapse=";"),
pCode=paste0(parameterCd,collapse=";"), startDateLo=startDate, startDateHi=endDate)
pCode=paste0(parameterCd,collapse=";"),
startDateLo=startDate, startDateHi=endDate)
} else {
siteInfo <- whatWQPsites(siteid=paste0(siteNumbers,collapse=";"),
characteristicName=paste0(parameterCd,collapse=";"), startDateLo=startDate, startDateHi=endDate)
characteristicName=paste0(parameterCd,collapse=";"),
startDateLo=startDate, startDateHi=endDate)
}
siteInfoCommon <- data.frame(station_nm=siteInfo$MonitoringLocationName,
......@@ -147,7 +149,8 @@ readWQPqw <- function(siteNumbers,parameterCd,startDate="",endDate=""){
if(any(variableInfo$parameterCd != "")){
pCodeToName <- pCodeToName
varExtras <- pCodeToName[pCodeToName$parm_cd %in% unique(variableInfo$parameterCd[!is.na(variableInfo$parameterCd)]),]
varExtras <- pCodeToName[pCodeToName$parm_cd %in%
unique(variableInfo$parameterCd[!is.na(variableInfo$parameterCd)]),]
names(varExtras)[names(varExtras) == "parm_cd"] <- "parameterCd"
variableInfo <- merge(variableInfo, varExtras, by="parameterCd")
}
......
......@@ -73,17 +73,17 @@ whatNWISdata <- function(siteNumbers,service="all",parameterCd="all",statCd="all
}
if(!("all" %in% parameterCd)){
parameterCdCheck <- all(nchar(parameterCd) == 5) & all(!is.na(suppressWarnings(as.numeric(parameterCd))))
if(parameterCdCheck){
if(any(!is.na(parameterCd))){
pcodeCheck <- all(nchar(parameterCd) == 5) & all(!is.na(suppressWarnings(as.numeric(parameterCd))))
pCodeInfo <- readNWISpCode(parameterCd)
if(nrow(pCodeInfo) != length(parameterCd)){
badPcodes <- parameterCd[!(parameterCd %in% pCodeInfo$parameter_cd)]
warning("The following parameterCds seem mistyped:",paste(badPcodes,collapse=","), "and will be ignored.")
parameterCd <- unique(pCodeInfo$parameter_cd)
if(!pcodeCheck){
badIndex <- which(nchar(parameterCd) != 5 | is.na(suppressWarnings(as.numeric(parameterCd))))
stop("The following pCodes appear mistyped:",paste(parameterCd[badIndex],collapse=","))
} else {
parameterCdCheck <- readNWISpCode(parameterCd)
}
}
}
......
......@@ -44,8 +44,6 @@ siteNumber <- '01594440'
startDate <- '1985-01-01'
endDate <- ''
pCode <- c("00060","00010")
\donttest{
# Not running for time considerations
url_daily <- constructNWISURL(siteNumber,pCode,
startDate,endDate,'dv',statCd=c("00003","00001"))
url_unit <- constructNWISURL(siteNumber,pCode,"2012-06-28","2012-06-30",'iv')
......@@ -58,7 +56,6 @@ url_daily_tsv <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv',
url_rating <- constructNWISURL(siteNumber,service="rating",ratingType="base")
url_peak <- constructNWISURL(siteNumber, service="peak")
url_meas <- constructNWISURL(siteNumber, service="meas")
}
}
\keyword{USGS}
\keyword{data}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment