Skip to content

Commit

Permalink
Handling of nodata with wind_2min_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylweiss committed Jul 29, 2023
1 parent db866c4 commit cd866fa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
19 changes: 16 additions & 3 deletions R/az_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,26 @@ az_daily <- function(station_id = NULL, start_date = NULL, end_date = NULL) {
)) %>%
dplyr::filter(.data$meta_station_id != "az99") %>%
dplyr::mutate(datetime = lubridate::ymd(.data$datetime)) %>%
dplyr::mutate(wind_2min_timestamp = lubridate::with_tz(lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"), tzone = "America/Phoenix")) %>%
#convert NAs
dplyr::mutate(
dplyr::across(
tidyselect::where(is.numeric),
c(tidyselect::where(is.numeric)),
function(x)
dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x))
dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x)
)
) %>%
dplyr::mutate(
dplyr::across(
wind_2min_timestamp,
function(x)
dplyr::if_else(x == as.character(-99999), NA_character_, x)
)
) %>%
dplyr::mutate(
wind_2min_timestamp = lubridate::with_tz(
lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"),
tzone = "America/Phoenix"
)
)
return(out)
}
23 changes: 21 additions & 2 deletions R/az_hourly.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,33 @@ az_hourly <- function(station_id = NULL, start_date_time = NULL, end_date_time =
as.numeric
)) %>%
dplyr::filter(.data$meta_station_id != "az99") %>%
dplyr::mutate(date_datetime = lubridate::force_tz(lubridate::ymd_hms(.data$date_datetime), tzone = "America/Phoenix")) %>%
dplyr::mutate(wind_2min_timestamp = lubridate::with_tz(lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"), tzone = "America/Phoenix")) %>%
dplyr::mutate(
date_datetime =
lubridate::force_tz(
lubridate::ymd_hms(.data$date_datetime),
tzone = "America/Phoenix"
)
) %>%
#convert NAs
dplyr::mutate(
dplyr::across(
tidyselect::where(is.numeric),
function(x)
dplyr::if_else(x %in% c(-999, -9999, -99999, -7999, 999, 999.9, 9999), NA_real_, x))
) %>%
dplyr::mutate(
dplyr::across(
wind_2min_timestamp,
function(x)
dplyr::if_else(x == as.character(-99999), NA_character_, x)
)
) %>%
dplyr::mutate(
wind_2min_timestamp =
lubridate::with_tz(
lubridate::parse_date_time(.data$wind_2min_timestamp, orders = "ymdHMSz"),
tzone = "America/Phoenix"
)
)
return(out)
}

0 comments on commit cd866fa

Please sign in to comment.