Skip to content

Commit

Permalink
used same pattern that we use in national-flow-observations, which is…
Browse files Browse the repository at this point in the history
… using readNWISdv and readNWISuv (instead of readNWISdata). This allows start and end dates to be set to "".
  • Loading branch information
limnoliver committed Jul 24, 2020
1 parent fc4ca7e commit a665825
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 2_nwis_pull/cfg/nwis_pull_params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ parameterCd:
- "00010"

startDate:
- "1900-01-01"
- ""

endDate:
- "2020-01-28"
- ""

20 changes: 15 additions & 5 deletions 2_nwis_pull/src/nwis_pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,21 @@ get_nwis_data <- function(data_file, partition, nwis_pull_params, service, verbo
nwis_pull_params$service <- service
nwis_pull_params$site <- partition$site_no

if (service == 'dv') { nwis_pull_params$statCd <- '00003' }
if (service == 'dv') {
nwis_pull_params$statCd <- '00003'

# do the data pull
nwis_dat_time <- system.time({
nwis_dat <- do.call(readNWISdv, nwis_pull_params)
})
}

# do the data pull
nwis_dat_time <- system.time({
nwis_dat <- do.call(readNWISdata, nwis_pull_params)
})
if (service == 'uv') {
# do the data pull
nwis_dat_time <- system.time({
nwis_dat <- do.call(readNWISuv, nwis_pull_params)
})
}

if (verbose){
message(sprintf(
Expand All @@ -126,6 +135,7 @@ get_nwis_data <- function(data_file, partition, nwis_pull_params, service, verbo
nwis_dat_time['elapsed'],
nrow(nwis_dat)))
}

# make nwis_dat a tibble, converting either from data.frame (the usual case) or
# NULL (if there are no results)
nwis_dat <- as_data_frame(nwis_dat)
Expand Down

0 comments on commit a665825

Please sign in to comment.