Skip to contents

Count number of days that were suitable for growth

Usage

count_growing_days(
  dat,
  ...,
  heat_threshold = 18,
  n_hours = 24,
  trend_threshold = 4,
  superchill_threshold = -0.7,
  max_season = 540,
  full_season = TRUE,
  rm_gap_days = FALSE,
  gap_length = 2,
  gap_warning = 6,
  quiet = TRUE
)

Arguments

dat

Data frame with at least three columns: TIMESTAMP (must be possible to convert to POSIXct), DEPTH, and VALUE. If column VARIABLE is included, it must have one unique entry. May also include columns with grouping variables passed to .... Other columns will be ignored.

...

Additional columns in dat to use as grouping variables. Results are automatically grouped by SEASON and DEPTH.

heat_threshold

The threshold for heat stress. Default is heat_threshold = 18). Every observation above heat_threshold triggers an n-hour heat stress interval.

n_hours

Length of heat stress interval in hours (default is n_hours = 24).

trend_threshold

The threshold for "trending up". Default is trend_threshold = 4. The last observation above trend_threshold that does not return below trend_threshold triggers the beginning of the growing season for each DEPTH and group in ....

superchill_threshold

The threshold for "superchill". Default is superchill_threshold = -0.7. The first observation below superchill_threshold triggers the end of the growing season for each group in DEPTH and ....

max_season

The length of the growing season in months for groups that have no temperature observations below superchill_threshold. Default is max_season = 540 days (~18 months). Note: units are days because adding 18 months to August 30 or August 31 results in NA (because February 30 and February 31 are not real dates).

full_season

Logical argument. The default, full_season = TRUE will only return data for groups with a full season of data (e.g., START_SEASON and END_SEASON as returned by identify_growing_seasons(dat, full_season = TRUE) are both NOT NA).

If full_season = FALSE, data for all groups will be returned; the START_SEASON and END_SEASON dates default to the first and last timestamp in ... and DEPTH.

rm_gap_days

Logical argument indicating whether to remove days with data gaps when counting n_growing_days.

gap_length

The length of time in hours to consider a sampling gap. Default is gap_length = 2 hours, which is twice the sampling interval of the least frequent sensor. The total sample gap length (sum of all sample gaps) is subtracted from the number of stocked days to calculate the number of growing days.

gap_warning

The length of time in hours to consider a substantial sampling gap. A warning can be printed if any gaps exceed this duration. Default is gap_warning = 6 hours.

quiet

Logical argument to suppress Warning message when gap lengths exceed gap_warning. If quiet = TRUE, the Warning will not be printed.

Value

Returns a tibble with columns: ..., DEPTH, SEASON, START_SEASON (minimum TIMESTAMP for each group), END_SEASON (maximum TIMESTAMP for each group), STOCKED_DAYS

(difftime(END_SEASON, START_SEASON, units = "days")), n_filtered_days (calculated from identify_heat_stress_events), and n_growing_days

(STOCKED_DAYS - n_filtered_days).

Details

Days suitable for growth are days that remain after applying season and heat stress filters. Option to remove days with data gaps (otherwise the assumption is that the temperature on these days is the average temperature of the data series).

Results are automatically grouped by SEASON and DEPTH.

Runs filter_in_growing_seasons() if no SEASON column in the data. If there is not a full season of data, make sure to set argument full_season = FALSE or add a SEASON column to dat.