Skip to contents

The function computes maximum temperature indicators from grouped data. Expects temperature in celsius degrees.

Usage

summarise_temp_max(.x, value_var, normals_df)

Arguments

.x

grouped data, created with dplyr::group_by()

value_var

name of the variable with temperature values.

normals_df

normals data, created with summarise_normal()

Value

A tibble.

Details

The heat waves indicators are computed based on climatological normals, created with the summarise_normal() function and passed with the normals_df argument. Keys to join the normals data must be present (like id, year, and month) and use the same names.

The following indicators are computed for each group.

  • count Count of data points

  • normal_mean Climatological normal mean, from normals_df argument

  • normal_p10 Climatological 10th percentile, from normals_df argument

  • normal_p90 Climatological 90th percentile, from normals_df argument

  • mean Average

  • median Median

  • sd Standard deviation

  • se Standard error

  • max Maximum value

  • min Minimum value

  • p10 10th percentile

  • p25 25th percentile

  • p75 75th percentile

  • p90 90th percentile

  • heat_waves_3d Count of heat waves occurences, with 3 or more consecutive days with maximum temperature above the climatological normal value plus 5 celsius degrees

  • heat_waves_5d Count of heat waves occurences, with 5 or more consecutive days with maximum temperature above the climatological normal value plus 5 celsius degrees

  • hot_days Count of warm days, when the maximum temperature is above the normal 90th percentile

  • t_25 Count of days with temperatures above or equal to 25 celsius degrees

  • t_30 Count of days with temperatures above or equal to 30 celsius degrees

  • t_35 Count of days with temperatures above or equal to 35 celsius degrees

  • t_40 Count of days with temperatures above or equal to 40 celsius degrees

Examples

# Compute monthly normals
normals <- temp_max_data |>
  # Identify month
  dplyr::mutate(month = lubridate::month(date)) |>
  # Group by id variable and month
  dplyr::group_by(code_muni, month) |>
  summarise_normal(date_var = date, value_var = value, year_start = 1961, year_end = 1990) |>
  dplyr::ungroup()

# Compute indicators
temp_max_data |>
 # Identify year
 dplyr::mutate(year = lubridate::year(date)) |>
 # Identify month
 dplyr::mutate(month = lubridate::month(date)) |>
 # Group by id variable, year and month
 dplyr::group_by(code_muni, year, month) |>
 # Compute maximum temperature indicators
 summarise_temp_max(value_var = value, normals_df = normals) |>
 # Ungroup
 dplyr::ungroup()
#> # A tibble: 3,024 × 24
#>    code_muni  year month count normal_mean normal_p10 normal_p90  mean median
#>        <int> <dbl> <dbl> <int>       <dbl>      <dbl>      <dbl> <dbl>  <dbl>
#>  1   3106200  1961     1    31        27.9       24.0       31.2  25.9   26.1
#>  2   3106200  1961     2    28        28.5       25.5       30.9  28.2   28.7
#>  3   3106200  1961     3    31        28.3       25.4       30.9  28.3   28.9
#>  4   3106200  1961     4    30        27.2       24.6       29.6  28.1   28.1
#>  5   3106200  1961     5    31        25.8       22.8       28.3  25.5   25.5
#>  6   3106200  1961     6    30        24.7       21.9       27.3  24.8   24.9
#>  7   3106200  1961     7    31        24.4       20.9       27.2  25.2   25.1
#>  8   3106200  1961     8    31        26.1       22.2       29.8  27.8   27.7
#>  9   3106200  1961     9    30        27.1       22.6       31.1  31.8   32.7
#> 10   3106200  1961    10    31        27.5       23.0       31.5  28.4   29.3
#> # ℹ 3,014 more rows
#> # ℹ 15 more variables: sd <dbl>, se <dbl>, max <dbl>, min <dbl>, p10 <dbl>,
#> #   p25 <dbl>, p75 <dbl>, p90 <dbl>, heat_waves_3d <int>, heat_waves_5d <int>,
#> #   hot_days <int>, t_25 <int>, t_30 <int>, t_35 <int>, t_40 <int>