Subsets a MazamaSingleTimeseries object by date. This function always filters to day-boundaries. For sub-day filtering, use sts_filterDatetime().

Dates can be anything that is understood by MazamaCoreUtils::parseDatetime() including either of the following recommended formats:

  • "YYYYmmdd"

  • "YYYY-mm-dd"

Timezone determination precedence assumes that if you are passing in POSIXct values then you know what you are doing.

  1. get timezone from startdate if it is POSIXct

  2. use passed in timezone

  3. get timezone from sts

sts_filterDate(
  sts = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  unit = "sec",
  ceilingStart = FALSE,
  ceilingEnd = FALSE
)

Arguments

sts

MazamaSingleTimeseries sts object.

startdate

Desired start datetime (ISO 8601).

enddate

Desired end datetime (ISO 8601).

timezone

Olson timezone used to interpret dates.

unit

Units used to determine time at end-of-day.

ceilingStart

Logical instruction to apply ceiling_date to the startdate rather than floor_date

ceilingEnd

Logical instruction to apply ceiling_date to the enddate rather than floor_date

Value

A subset of the incoming sts time series object. (A list with meta and data dataframes.)

Note

The returned data will run from the beginning of startdate until the beginning of enddate -- i.e. no values associated with enddate will be returned. The exception being when enddate is less than 24 hours after startdate. In that case, a single day is returned.

Examples

library(MazamaTimeSeries)

example_sts %>%
  sts_filterDate(startdate = 20180808, enddate = 20180815) %>%
  sts_extractData() %>%
  head()
#> # A tibble: 6 × 19
#>   datetime            pm25_A pm25_B temperature humidity pressure pm1_atm_A
#>   <dttm>               <dbl>  <dbl>       <dbl>    <dbl>    <dbl>     <dbl>
#> 1 2018-08-08 07:00:00  10.2    9             78       41       NA      7.44
#> 2 2018-08-08 07:01:00   9.74   9.21          78       41       NA      7.93
#> 3 2018-08-08 07:02:00   9.56  NA             78       41       NA      7.33
#> 4 2018-08-08 07:03:00  NA      9.14          NA       NA       NA     NA   
#> 5 2018-08-08 07:04:00   9.44   8.55          78       41       NA      7.8 
#> 6 2018-08-08 07:05:00  10      9.66          78       41       NA      7.79
#> # ℹ 12 more variables: pm25_atm_A <dbl>, pm10_atm_A <dbl>, pm1_atm_B <dbl>,
#> #   pm25_atm_B <dbl>, pm10_atm_B <dbl>, uptime <dbl>, rssi <dbl>, memory <dbl>,
#> #   adc0 <dbl>, bsec_iaq <dbl>, datetime_A <dttm>, datetime_B <dttm>