Closed dimfalk closed 5 months ago
library(netatmo.weather)
#> 0.5.17
Sys.time()
#> "2024-04-06 23:05:52 CEST"
#> == "2024-04-06 21:05:52 UTC"
p <- get_period(res = 60)
p
#>[1] 1708750800 1712437200
as.POSIXct(p, tz = "UTC")
'> [1] "2024-02-24 05:00:00 UTC" "2024-04-06 21:00:00 UTC"
obs <- get_measure(devices = stations_tiled[1, ],
period = p,
par = "temperature",
res = 60)
zoo::index(obs[[1]]) |> range()
#> "2024-02-24 05:00:00 UTC" "2024-04-06 19:00:00 UTC"
length(obs[[1]])
#> 1023
20:00
missing
Investigate behaviour without lubridate::floor_date(unit = "hour")
?
It seems like the last value of the interval queried is dismissed:
p <- get_period("2024-04-01 00:00/2024-04-02 00:00")
as.POSIXct(p, tz = "UTC")
#> "2024-04-01 UTC" "2024-04-02 UTC"
obs <- get_measure(devices = stations_tiled[1, ],
period = p,
par = "temperature",
res = 60)
zoo::index(obs[[1]]) |> range()
#> "2024-04-01 00:00:00 UTC" "2024-04-01 22:00:00 UTC"
length(obs[[1]])
#> 23
p <- get_period("2024-04-01 00:00/2024-04-02 00:00")
as.POSIXct(p, tz = "UTC")
#> "2024-04-01 00:00:00 UTC" "2024-04-02 01:00:00 UTC"
obs <- get_measure(devices = stations_tiled[1, ],
period = p,
par = "temperature",
res = 60)
zoo::index(obs[[1]]) |> range()
#> "2024-04-01 00:00:00 UTC" "2024-04-01 23:00:00 UTC"
length(obs[[1]])
#> 24
However, the raw API response provides 24 values using the upper request, so we're loosing the last one during processing:
{
"body": {
"1711929600": [
9.5
],
"1711933200": [
9.8
],
"1711936800": [
9.9
],
"1711940400": [
9.7
],
"1711944000": [
9.3
],
"1711947600": [
9.4
],
"1711951200": [
9.6
],
"1711954800": [
10.1
],
"1711958400": [
10.5
],
"1711962000": [
10.6
],
"1711965600": [
11
],
"1711969200": [
12.3
],
"1711972800": [
13.3
],
"1711976400": [
13.4
],
"1711980000": [
13.6
],
"1711983600": [
14.1
],
"1711987200": [
13.9
],
"1711990800": [
12.6
],
"1711994400": [
11.8
],
"1711998000": [
10.9
],
"1712001600": [
9.4
],
"1712005200": [
8.4
],
"1712008800": [
8.3
],
"1712012400": [
9.2
]
},
"status": "ok",
"time_exec": 0.08574914932250977,
"time_server": 1712438269
}
library(netatmo.weather)
#> 0.5.18
p <- get_period("2024-04-01/2024-04-02")
p
#> [1] 1711929600 1712016000
as.POSIXct(p, tz = "UTC")
#> [1] "2024-04-01 UTC" "2024-04-02 UTC"
obs <- get_measure(devices = stations_tiled[1, ],
period = p,
par = "temperature",
res = 5)
zoo::index(obs[[1]]) |> range()
#> [1] "2024-04-01 00:00:00 UTC" "2024-04-01 23:55:00 UTC"
# enforce `NA` values for missing timestamps
timeseriesIO::xts_make_equidistant(obs[[1]]) |> length()
#> [1] 288
obs <- get_measure(devices = stations_tiled[1, ],
period = p,
par = "temperature",
res = 60)
zoo::index(obs[[1]]) |> range()
#> [1] "2024-04-01 00:00:00 UTC" "2024-04-01 23:00:00 UTC"
length(obs[[1]])
#> [1] 24
23:55
missing