dimfalk / netatmo.weather

R wrapper for Netatmo Weather API
GNU General Public License v3.0
3 stars 0 forks source link

`get_measure()`: handle NULL meta data in case of missing time series data #85

Closed dimfalk closed 3 months ago

dimfalk commented 3 months ago
e <- get_extent("Dortmund")

stations <- get_publicdata(ext = e, tiles = TRUE)

# load("stations_dortmund.rda")

p <- get_period("2024-06-29")

obs <- get_measure(devices = stations, 
                   period = p, 
                   par = "sum_rain", 
                   res = 5)

# load("obs_dortmund.rda")

hymet::xtslist_summarize(obs)
#> Error in `tibble::tibble()` at hymet/R/xtslist_summarize.R:46:5:
#> ! Tibble columns must have compatible sizes.
#> • Size 226: Existing data.
#> • Size 232: Column `sum`.
#> ℹ Only values of size one are recycled.
#> Run `rlang::last_trace()` to see where the error occurred.
lapply(obs, attr, "STAT_ID") |> length()
#> [1] 232

lapply(obs, attr, "STAT_ID") |> unlist() |> length()
#> [1] 226

which(lapply(obs, attr, "STAT_ID") |> lapply(is.null) == TRUE) |> as.integer()
#> [1]  29  41  96 137 150 162