summarize_rainfall: Rainfall summary statistics

Description Usage Arguments Details Value See Also Examples

View source: R/summarize_rainfall.R

Description

Uses daily site data to calculate summary rainfall statistics for an annual season.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
summarize_rainfall(
  rain,
  start_month,
  end_month,
  start_day = 15,
  end_day = start_day,
  rain_cutoff = 1,
  na.rm = TRUE,
  wide = TRUE,
  id_index = 1,
  date_sep = "_"
)

Arguments

rain

data frame with daily rainfall data for each site

start_month

numeric starting month defining season (inclusive)

end_month

numeric ending month defining season (inclusive)

start_day

numeric day of starting month defining season (inclusive); defaults to 15

end_day

numeric day of ending month defining season (inclusive); defaults to start_day

rain_cutoff

numeric minimum value for daily rainfall to be counted as a rain day

na.rm

logical passed to summary statistic functions indicating treatment of NA values

wide

logical indicating whether or not to output as wide- formatted data

id_index

integer column index of unique site id

date_sep

character used to delimit variable prefix from date in column names; defaults to underscore ("_")

Details

User-defined seasons will be, at most, one year long, defined by the start_* and end_* parameters. Seasons can span across the new year, e.g. a season can start in November and end in March. Seasons are enumerated by the year in which they start; i.e. if a season starts in November and ends in March, the output for year YYYY will be based on the data from November and December of YYYY and January, February, and March of YYYY + 1.

By default, will return data in "long" format, with a column indicating the year the data correspond to (but see discussion of season enumeration above). If wide = TRUE, output will include a separate column for each statistic for each year (see Value). For example, if wide = FALSE and the data include daily measurements from 1997 to 2002, the output will have a column year and a column mean_season. For these same data, if wide = TRUE, there will be no year column, but instead it will contain columns mean_season_1997, mean_season_1998...mean_season_2002.

Value

tibble with rainfall summary statistics If wide = FALSE, returns values for each year for each site:

mean_season

Mean rainfall for the season

median_season

Median rainfall for the season

sd_season

Standard deviation of rainfall for the season

total_season

Total rainfall rainfall over the season

skew_season

Skew of rainfall for the season, where skew is defined by (mean - median)/sd

norain

Total number of days with rain less than rain_cutoff

raindays

Total number of days with rain greater than or equal to rain_cutoff

percent_raindays

Percentage of days in season with rain greater than or equal to rain_cutoff

dry

Longest stretch of days with less than rain_cutoff contained within the period; if rainfall was less than rain_cutoff for every day in defined season, the returned value will be zero

dry_start

Number of consecutive days at beginning of season with less than rain_cutoff of measured rain; if first day of season had rainfall greater than or equal to rain_cutoff, the returned value will be zero

dry_end

Number of consecutive days at end of season with less than rain_cutoff of measured rain; if last day of season had rainfall greater than or equal to rain_cutoff, the returned value will be zero

mean_period_total_season

Mean total seasonal rainfall across all seasons

sd_period_total_season

Standard deviation of total rainfall across all seasons

mean_period_norain

Mean number of days with rainfall less than rain_cutoff across all seasons

sd_period_norain

Standard deviation of number of days with rainfall less than rain_cutoff across all seasons

mean_period_raindays

Mean number of days with rainfall greater than or equal to rain_cutoff across all seasons

sd_period_norain

Standard deviation of number of days with rainfall greater than or equal to rain_cutoff across all seasons

mean_period_percent_raindays

Mean percentage of days in season with rain greater than or equal to rain_cutoff across all seasons

sd_period_percent_raindays

Standard deviation of percentage of days in season with rain greater than or equal to rain_cutoff across all seasons

dev_total_season

Amount by which season total rainfall deviates from the mean total rainfall across seasons

z_total_season

Difference of total seasonal rainfall and mean of total rainfall across seasons, divided by sd_period_total_season

dev_raindays

Difference in number of days with rainfall greater than or equal to rain_cutoff from the mean number of days with rainfall greater than or equal to rain_cutoff across seasons

dev_norain

Difference in number of days with rainfall less than rain_cutoff from the mean number of days with rainfall less than rain_cutoff across seasons

dev_percent_raindays

Difference in percentage of days with rainfall greater than or equal to rain_cutoff from the percentage of days with rainfall greater than or equal to rain_cutoff across seasons

z_percent_raindays

Difference in percentage of days with rainfall greater than or equal to rain_cutoff from mean_period_percent_raindays, divided by sd_period_percent_raindays

If wide = TRUE, all columns except those with *_period_* pattern are replaced with one column for each year. For example, if the data include daily measurements from 1997 to 2002, there will be no mean_season column in the output, but will instead have columns mean_season_1997, mean_season_1998...mean_season_2002.

See Also

summarize_temperature, par_summarize_rainfall

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
# Season defined by 15 March through 15 November
rain_summary <- summarize_rainfall(rain = rain_2yr,
                                   start_month = 3,
                                   end_month = 11)

# As example above, but output in "long" format
rain_summary <- summarize_rainfall(rain = rain_2yr,
                                   start_month = 3,
                                   end_month = 11,
                                   wide = FALSE)

# Season defined by 30 November through 15 March
rain_summary <- summarize_rainfall(rain = rain_2yr,
                                   start_month = 11,
                                   end_month = 3,
                                   start_day = 30,
                                   end_day = 15)

## End(Not run)

jcoliver/weathercommand documentation built on Sept. 12, 2021, 3:28 a.m.