Subsets an AirSensor object by datetime. This function
allows for sub-day filtering as opposed to sensor_filterDate()
which
always filters to day-boundaries. Filtering will be performed with
>= startdate
and < enddate
so that the startdate
timestep will be included in the output but the enddate
will not.
Datetimes can be anything that is understood by
MazamaCoreUtils::parseDatetime()
. For non-POSIXct
values,
the recommended format is "YYYY-mm-dd HH:MM:SS"
.
Timezone determination precedence assumes that if you are passing in POSIXct times then you know what you are doing.
get timezone from startdate
if it is POSIXct
use passed in timezone
get timezone from sensor
sensor_filterDatetime(
sensor = NULL,
startdate = NULL,
enddate = NULL,
timezone = NULL
)
An AirSensor object.
Desired start datetime (ISO 8601).
Desired end datetime (ISO 8601).
Olson timezone used to interpret dates.
A subset of the given sensor object.
library(AirSensor)
example_sensor %>%
sensor_extractData() %>%
dplyr::pull("datetime") %>%
range()
#> [1] "2022-07-01 00:00:00 UTC" "2022-07-07 23:00:00 UTC"
example_sensor %>%
sensor_filterDatetime(
startdate = "2022-07-02 06:00:00",
enddate = "2022-07-03 18:00:00",
timezone = "UTC"
) %>%
sensor_extractData() %>%
dplyr::pull("datetime") %>%
range()
#> [1] "2022-07-02 06:00:00 UTC" "2022-07-03 17:00:00 UTC"