Trims the date range of a mts_monitor object to local time date boundaries which are within the range of data. This has the effect of removing partial-day data records at the start and end of the timeseries and is useful when calculating full-day statistics.

By default, multi-day periods of all-missing data at the beginning and end of the timeseries are removed before trimming to date boundaries. If trimEmptyDays = FALSE all records are retained except for partial days beyond the first and after the last date boundary.

Day boundaries are calculated using the specified timezone or, if NULL, from monitor$meta$timezone.

monitor_trimDate(monitor = NULL, timezone = NULL, trimEmptyDays = TRUE)

Arguments

monitor

mts_monitor object.

timezone

Olson timezone used to interpret dates.

trimEmptyDays

Logical specifying whether to remove days with no data at the beginning and end of the time range.

Value

A subset of the given mts_monitor object. (A list with meta and data dataframes.)

Examples

library(AirMonitor)

# Non-day boundaries
monitor <-
  Camp_Fire %>%
  monitor_filterDatetime(
    "2018111502",
    "2018112206",
    timezone = "America/Los_Angeles"
  )

monitor %>%
  monitor_timeRange(timezone = "America/Los_Angeles")
#> [1] "2018-11-15 02:00:00 PST" "2018-11-22 05:00:00 PST"

# Trim to full days only
monitor %>%
  monitor_trimDate() %>%
  monitor_timeRange(timezone = "America/Los_Angeles")
#> [1] "2018-11-16 00:00:00 PST" "2018-11-21 23:00:00 PST"