Skip to content

Commit

Permalink
Merge pull request #50 from uace-azmet/warn-missing-data
Browse files Browse the repository at this point in the history
Adding a warning if missing data in API
  • Loading branch information
jeremylweiss authored Aug 9, 2023
2 parents 5d703f0 + 600bb2a commit b22d074
Show file tree
Hide file tree
Showing 6 changed files with 6,439 additions and 7 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# azmetr (development version)

- Transfered maintainance of package to Jeremy Weiss
- `az_daily()` and `az_hourly()` now print a warning if there is any missing data for the combination of dates and stations requested
- Transferred maintenance of package to Jeremy Weiss
- Timestamp for hourly and daily maximum two-minute sustained wind speeds, `wind_2min_timestamp` now appears in downloaded data
- Variable type for hourly and daily `wind_2min_timestamp` now is date-time instead of character with correct time zone, `tzone = "America/Phoenix"`
- Values for hourly `date_datetime` variable now have `tzone = "America/Phoenix"` assigned
Expand Down
20 changes: 15 additions & 5 deletions R/az_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,21 @@ az_daily <- function(station_id = NULL, start_date = NULL, end_date = NULL) {
}
)
}
if(nrow(out) == 0) {
warning("No data retrieved from API")
#return 0x0 tibble for type consistency
return(tibble::tibble())
}

if(nrow(out) == 0) {
warning("No data retrieved from API")
#return 0x0 tibble for type consistency
return(tibble::tibble())
}

#Check if any data is missing
n_obs <- out %>%
dplyr::summarise(n = dplyr::n(), .by = dplyr::all_of("meta_station_id")) %>%
dplyr::filter(.data$n < as.numeric(lubridate::period(params$time_interval), "day") + 1)
if(nrow(n_obs) != 0) {
warning("Some requested data were unavailable")
}

# Wrangle output ----------------------------------------------------------
out <- out %>%
#move metadata to beginning
Expand Down
9 changes: 9 additions & 0 deletions R/az_hourly.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ az_hourly <- function(station_id = NULL, start_date_time = NULL, end_date_time =
#return 0x0 tibble
return(tibble::tibble())
}

#Check if any data is missing
n_obs <- out %>%
dplyr::summarise(n = dplyr::n(), .by = dplyr::all_of("meta_station_id")) %>%
dplyr::filter(.data$n < as.numeric(lubridate::period(params$time_interval), "hour"))
if(nrow(n_obs) != 0) {
warning("Some requested data were unavailable")
}

# Wrangle output ----------------------------------------------------------
out <- out %>%
#move metadata to beginning
Expand Down
2 changes: 1 addition & 1 deletion man/station_info.Rd

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

Loading

0 comments on commit b22d074

Please sign in to comment.