Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0baddb0
add more python
ldecicco-USGS Apr 29, 2026
20fd8f6
will this just work?
ldecicco-USGS Apr 29, 2026
7584089
PEAKS!
ldecicco-USGS Apr 30, 2026
aa4a2a6
Let's see about getting slides to render
ldecicco-USGS Apr 30, 2026
d8d7f5d
remove oooold articles
ldecicco-USGS Apr 30, 2026
62c1934
RStudio update
ldecicco-USGS Apr 30, 2026
05f34a4
add peaks
ldecicco-USGS Apr 30, 2026
dbb4a15
removing old vignettes
ldecicco-USGS Apr 30, 2026
7b4a49b
Add reticulate to GHActions
ldecicco-USGS Apr 30, 2026
3fd9f76
Merge pull request #885 from ldecicco-USGS/main
ldecicco-USGS Apr 30, 2026
6d6a8f0
Switch to samples in vignette
ldecicco-USGS Apr 30, 2026
2ee9add
Merge branch 'main' of github.com:DOI-USGS/dataRetrieval
ldecicco-USGS Apr 30, 2026
753b674
Merge pull request #886 from ldecicco-USGS/main
ldecicco-USGS Apr 30, 2026
8d92a4c
Getting GH actions working with python
ldecicco-USGS Apr 30, 2026
66fe712
Peaks in vignettes
ldecicco-USGS May 1, 2026
00b2d08
Add to NEWS
ldecicco-USGS May 1, 2026
04b555a
cleaned up doc code
ldecicco-USGS May 1, 2026
b600173
Adding an ERROR to uses where a time argument is input like this:
ldecicco-USGS May 4, 2026
e3402e8
some python updates
ldecicco-USGS May 5, 2026
021b11e
let's always rebuild (for now)
ldecicco-USGS May 5, 2026
8d20e65
More cleanup
ldecicco-USGS May 5, 2026
feae5d1
save fewer artifacts
ldecicco-USGS May 6, 2026
e5d1150
Merge branch 'develop' of github.com:DOI-USGS/dataRetrieval into develop
ldecicco-USGS May 6, 2026
13cdba8
try to fix pipeline
ldecicco-USGS May 6, 2026
252873c
no artifacts
ldecicco-USGS May 6, 2026
e193c38
?
ldecicco-USGS May 6, 2026
df780f2
formatting
ldecicco-USGS May 6, 2026
2bcb219
Update tutorials/quick_intro_deck.qmd
ldecicco-USGS May 7, 2026
27ee733
more cleanup
ldecicco-USGS May 7, 2026
beecb34
Merge branch 'develop' of github.com:ldecicco-USGS/dataRetrieval into…
ldecicco-USGS May 7, 2026
1eb8d80
Do we slim down the Docker image if we create the enviornment only in…
ldecicco-USGS May 7, 2026
d9b148b
try again
ldecicco-USGS May 7, 2026
458c92c
pipeline work
ldecicco-USGS May 7, 2026
f9d1c71
go back
ldecicco-USGS May 7, 2026
75df7a5
?
ldecicco-USGS May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ vignettes/Reference_Lists.Rmd
^[.]?air[.]toml$
^\.vscode$
environment.yml
^\.positai$
^\.claude$
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
any::ggplot2
any::sf
any::patchwork
any::maps
any::reticulate
any::leaflet
any::readxl
any::gridExtra
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ vignettes/*.html
vignettes/*.R
/.quarto/
**/*.quarto_ipynb
.positai
41 changes: 21 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ build-image:
services:
- name: ${DEVOPS_REGISTRY}usgs/docker:20-dind
alias: docker
rules:
- changes:
- .gitlab-ci.yml
- docker/Dockerfile
- environment.yml
script:
- echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin $CI_REGISTRY
- docker pull ${CI_REGISTRY_IMAGE}:latest || true
- docker build
-f docker/Dockerfile -t ${CI_REGISTRY_IMAGE}:latest .
- docker push --all-tags ${CI_REGISTRY_IMAGE}
artifacts:
expire_in: 5 minutes

buildcheck:
stage: check
Expand All @@ -70,7 +67,7 @@ buildcheck:
artifacts:
paths:
- "*.tar.gz"
expire_in: 1 week
expire_in: 1 hour

unittests:
stage: test
Expand All @@ -91,7 +88,7 @@ unittests:
x'
artifacts:
when: always
expire_in: 1 week
expire_in: 1 hour
paths:
- test-out.xml
reports:
Expand All @@ -112,6 +109,8 @@ longtest:
- if: $RUN_LONG_TESTS == "FALSE"
when: always
- when: never
artifacts:
expire_in: 5 minutes

pages:
stage: end
Expand All @@ -129,18 +128,20 @@ pages:
artifacts:
paths:
- $PAGES_OUTDIR
expire_in: 1 week
expire_in: 1 hour

Validate Inventory:
stage: end
only:
- main
image: ${INTERNAL_REGISTRY}software/software-management:latest
script:
- software-management review
--project "${CI_PROJECT_PATH}"
--ref "${CI_COMMIT_BRANCH}"
--type "provisional"
--token "${GIT_TOKEN_CUSTOM}"
tags:
- chs-shared
stage: end
only:
- main
image: ${INTERNAL_REGISTRY}software/software-management:latest
script:
- software-management review
--project "${CI_PROJECT_PATH}"
--ref "${CI_COMMIT_BRANCH}"
--type "provisional"
--token "${GIT_TOKEN_CUSTOM}"
tags:
- chs-shared
artifacts:
expire_in: 5 minutes
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ Encoding: UTF-8
BuildVignettes: true
VignetteBuilder: knitr
BugReports: https://github.com/DOI-USGS/dataRetrieval/issues
RoxygenNote: 7.3.3
Roxygen: list(markdown = TRUE)
Config/roxygen2/version: 8.0.0
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export(read_waterdata_latest_daily)
export(read_waterdata_metadata)
export(read_waterdata_monitoring_location)
export(read_waterdata_parameter_codes)
export(read_waterdata_peaks)
export(read_waterdata_ratings)
export(read_waterdata_samples)
export(read_waterdata_stats_daterange)
Expand Down
9 changes: 8 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ dataRetrieval 2.7.25
===================
* Added read_waterdata_ratings to access USGS rating curves with
new modern endpoint.
* Added read_waterdata_peaks to access USGS peak data with
new modern endpoint.
* Increase flexibility of chunking by monitoring_location_id by
including it as an argument in each relevant function.
including it as an argument in each relevant waterdata OGC function.
* Clean up deprecated code.
* Updated retry strategy to include retry_on_failure = TRUE.
* Added countries, methods, method-categories, method-citations, and
citations to possible values in read_waterdata_metadata.
* Added field_measurements_series_id argument to read_waterdata_field_measurement
* Removed NWIS tests
* Introduce an error if user inputs a numeric to any of the "time" arguments.
Because it is impossible to tell if they intended Dates or POSIX, we cannot
know for sure and therefore could add incorrect filters to the query.
* The "id" column that comes back from read_waterdata_fiel_meta was changed to
field_measurements_series_id to match the expectation of `read_waterdata_field_measurements`



Expand Down
3 changes: 2 additions & 1 deletion R/AAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pkg.env <- new.env()
"continuous",
"field-measurements-metadata",
"combined-metadata",
"channel-measurements"
"channel-measurements",
"peaks"
)
collections <- c(
"parameter-codes",
Expand Down
43 changes: 31 additions & 12 deletions R/construct_api_requests.R
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ switch_arg_id <- function(ls, id_name, service) {
#' dataRetrieval:::format_api_dates(end)
#' dataRetrieval:::format_api_dates(end, TRUE)
#'
#' end <- c(NA, as.POSIXct("2021-01-01 12:15:00"))
#' end <- as.POSIXct(c(NA, "2021-01-01 12:15:00"))
#' dataRetrieval:::format_api_dates(end)
#'
#' start_end <- as.POSIXct(c("2021-01-01 12:15:00",
Expand Down Expand Up @@ -370,38 +370,57 @@ switch_arg_id <- function(ls, id_name, service) {
#' start <- "2025-10-01"
#' end <- Sys.Date()
#' dataRetrieval:::format_api_dates(c(start, end), date = TRUE)
#'
#' # This is a problem because the first value forces the
#' # vector to be numeric, and then we don't really
#' # know if the 2nd value is a Date (number of days since 1970)
#' # or if it's a date/time (number of seconds..)
#' half_range <- c(NA, as.Date("2025-01-01"))
#' # Will error:
#' #dataRetrieval:::format_api_dates(half_range, date = FALSE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't error for me, but it did appear to interpret as a numeric timestamp, meaning I got "../1970-01-01T05:34:49Z" as output

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if I pushed the "stop" command up after you pulled? I get:

> half_range <- c(NA, as.Date("2025-01-01"))
> dataRetrieval:::format_api_dates(half_range, date = FALSE)
Error in dataRetrieval:::format_api_dates(half_range, date = FALSE) : 
  A time query was entered as numeric. This could lead to errors.
Check any time queries that might have been automatically converted to numeric.
This could happen if you use c(NA, as.Date(Sys.Date())) instead of
as.Date(c(NA, Sys.Date()) for example.

#' # Better way to do it:
#' better_half <- as.Date(c(NA, "2025-01-01"))
#' dataRetrieval:::format_api_dates(better_half, date = FALSE)
format_api_dates <- function(datetime, date = FALSE) {
if (is.character(datetime)) {
datetime[datetime == ""] <- NA
datetime <- toupper(datetime)
}

if (all(is.na(datetime))) {
return(NA)
}

if (all(is.null(datetime))) {
if (all(is.na(datetime)) | all(is.null(datetime))) {
return(NA)
}

if (length(datetime) > 2) {
stop("datetime should only include 1-2 values")
}

if (is.numeric(datetime)) {
# Until we can figure out a way to know if the
# original input was suppose to be Date or Posix
# We can't determine what the user meant.
stop(
"A time query was entered as numeric. This could lead to errors.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way I can think to do this would be to check the expression passed within the function call, but that gets into substitute and related territory that I know we want to avoid. Otherwise, the function could change to accept separate date_start/end arguments or a list instead of a vector. I can't think of other ways.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most workflows I've seen are using that use characters, Date objects, or POSIX. All of those are fine, and any numeric is unintentional. So I'm comfortable leaving this as an error. I assume the time it will come up most is something like:

df <- read_waterdata_sample(some stuff)
df_range <- range(df$time)
cont_df <- read_waterdata_daily(time = c(NA, df_range[2])

If we plaster examples and tutorials with stuff like:

cont_df <- read_waterdata_continuous(time = as.Date(c(NA, df_range[2]))

I think we'll be OK.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good plan.

Check any time queries that might have been automatically converted to numeric.
This could happen if you use c(NA, as.Date(Sys.Date())) instead of
as.Date(c(NA, Sys.Date()) for example."
)
}

if (length(datetime) == 1) {
# If the user has "P" or the "/" we assume they know what they are doing
if (
grepl("P", datetime, ignore.case = TRUE) |
grepl("/", datetime)
) {
return(datetime)
}

if (date) {
datetime <- get_Date(datetime)
} else {
if (date) {
datetime <- get_Date(datetime)
} else {
datetime1 <- get_dateTime(datetime)
datetime <- lubridate::format_ISO8601(datetime1, usetz = "Z")
}
datetime1 <- get_dateTime(datetime)
datetime <- lubridate::format_ISO8601(datetime1, usetz = "Z")
}
} else if (length(datetime) == 2) {
if (date) {
Expand Down
2 changes: 1 addition & 1 deletion R/dataRetrieval-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ NULL
# "monitoring-locations", "latest-continuous",
# "field-measurements", "latest-daily",
# "continuous", "field-measurements-metadata",
# "combined-metadata", "channel-measurements")
# "combined-metadata", "channel-measurements", "peaks")
#
# property_list <- list()
# for(service in services){
Expand Down
74 changes: 31 additions & 43 deletions R/readNWISunit.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,10 @@
#' endDate <- "2014-10-10"
#' \donttest{
#'
#' rawData <- readNWISuv(site_id, parameterCd, startDate, endDate)
#' #rawData <- readNWISuv(site_id, parameterCd, startDate, endDate)
#'
#' rawData_today <- readNWISuv(site_id, parameterCd, Sys.Date(), Sys.Date())
#' #rawData_today <- readNWISuv(site_id, parameterCd, Sys.Date(), Sys.Date())
#'
#' timeZoneChange <- readNWISuv(
#' c("04024430", "04024000"), parameterCd,
#' "2013-11-03", "2013-11-03"
#' )
#'
#' centralTime <- readNWISuv(site_id, parameterCd,
#' "2014-10-10T12:00", "2014-10-10T23:59",
#' tz = "America/Chicago"
#' )
#'
#' # 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"
#' )
#' }
readNWISuv <- function(
siteNumbers,
Expand Down Expand Up @@ -171,12 +156,12 @@ readNWISuv <- function(
#' @seealso [constructNWISURL()], [importRDB1()]
#' @export
#' @examplesIf is_dataRetrieval_user()
#' site_ids <- c("01594440", "040851325")
#' #site_ids <- c("01594440", "040851325")
#' \donttest{
#' data <- readNWISpeak(site_ids)
#' data2 <- readNWISpeak(site_ids, asDateTime = FALSE)
#' stations <- c("06011000")
#' peakdata <- readNWISpeak(stations, convertType = FALSE)
#' #data <- readNWISpeak(site_ids)
#' #data2 <- readNWISpeak(site_ids, asDateTime = FALSE)
#' #stations <- c("06011000")
#' #peakdata <- readNWISpeak(stations, convertType = FALSE)
#' }
readNWISpeak <- function(
siteNumbers,
Expand All @@ -185,8 +170,11 @@ readNWISpeak <- function(
asDateTime = TRUE,
convertType = TRUE
) {
message(new_nwis_message())

.Deprecated(
new = "read_waterdata_peaks",
package = "dataRetrieval",
msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_peaks."
)
# Doesn't seem to be a peak xml service
url <- constructNWISURL(
siteNumbers = siteNumbers,
Expand Down Expand Up @@ -276,8 +264,8 @@ readNWISpeak <- function(
#' @examplesIf is_dataRetrieval_user()
#' site_id <- "01594440"
#' \donttest{
#' data <- readNWISrating(site_id, "base")
#' attr(data, "RATING")
#' #data <- readNWISrating(site_id, "base")
#' #attr(data, "RATING")
#' }
readNWISrating <- function(siteNumber, type = "base", convertType = TRUE) {
.Deprecated(
Expand Down Expand Up @@ -354,28 +342,28 @@ readNWISrating <- function(siteNumber, type = "base", convertType = TRUE) {
#' @export
#' @examplesIf is_dataRetrieval_user()
#' \donttest{
#' x1 <- readNWISstat(
#' siteNumbers = c("02319394"),
#' parameterCd = c("00060"),
#' statReportType = "annual"
#' )
#' # x1 <- readNWISstat(
#' # siteNumbers = c("02319394"),
#' # parameterCd = c("00060"),
#' # statReportType = "annual"
#' # )
#'
#' # all the annual mean discharge data for two sites
#' x2 <- readNWISstat(
#' siteNumbers = c("02319394", "02171500"),
#' parameterCd = c("00010", "00060"),
#' statReportType = "annual"
#' )
#' #x2 <- readNWISstat(
#' # siteNumbers = c("02319394", "02171500"),
#' # parameterCd = c("00010", "00060"),
#' # statReportType = "annual"
#' # )
#'
#' # Request p25, p75, and mean values for temperature and discharge for the 2000s
#' # Note that p25 and p75 were not available for temperature, and return NAs
#' x <- readNWISstat(
#' siteNumbers = c("02171500"),
#' parameterCd = c("00010", "00060"),
#' statReportType = "daily",
#' statType = c("mean", "median"),
#' startDate = "2000", endDate = "2010"
#' )
#' #x <- readNWISstat(
#' # siteNumbers = c("02171500"),
#' # parameterCd = c("00010", "00060"),
#' # statReportType = "daily",
#' # statType = c("mean", "median"),
#' # startDate = "2000", endDate = "2010"
#' # )
#' }
readNWISstat <- function(
siteNumbers,
Expand Down
Loading
Loading