Skip to contents

Given a data frame of ensemble forecasts the ensemble mean, the ensemble standard deviation (spread), ensemble variance, ensemble minimum, and ensemble are calculated.

Usage

ens_stats(
  .fcst,
  mean = TRUE,
  sd = TRUE,
  var = FALSE,
  min = FALSE,
  max = FALSE,
  keep_members = FALSE,
  ...
)

# S3 method for harp_ens_point_df
ens_stats(
  .fcst,
  mean = TRUE,
  sd = TRUE,
  var = FALSE,
  min = FALSE,
  max = FALSE,
  keep_members = FALSE,
  median = FALSE,
  ...
)

Arguments

.fcst

A harp_ens_grid_df or harp_ens_point_df data frame, or a harp_list containing data frames with those classes.

mean

Logical. Whether to compute the ensemble mean.

sd

Logical. Whether to compute the ensemble standard deviation.

var

Logical. Whether to compute the ensemble variance.

min

Logical. Whether to compute the ensemble minumum.

max

Logical. Whether to compute the ensemble maximum.

keep_members

Logical. Whether to keep the ensemble members in the returned object. The default is to only return the statistics.

...

Not used.

median

Logical. Whether to compute the ensemble median.

Value

An object of the same class as .fcst with columns for the ensemble statistics

Details

By default only the ensemble mean and standard deviation are computed. Note that the ensemble median is not yet implemented for gridded data.

Examples

ens_stats(ens_point_df)
#> # A tibble: 48 × 6
#>    fcst_dttm           lead_time valid_dttm            SID ens_mean ens_sd
#>  * <dttm>                  <dbl> <dttm>              <dbl>    <dbl>  <dbl>
#>  1 2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001    0.533 0.362 
#>  2 2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001    0.597 0.0752
#>  3 2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001    0.528 0.104 
#>  4 2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001    0.552 0.177 
#>  5 2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001    0.306 0.320 
#>  6 2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001    0.434 0.463 
#>  7 2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001    0.377 0.0425
#>  8 2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001    0.273 0.304 
#>  9 2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001    0.692 0.359 
#> 10 2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001    0.562 0.141 
#> # ℹ 38 more rows
ens_stats(ens_point_df, keep_members = TRUE)
#> ::ensemble point forecast:: # A tibble: 48 × 8
#>    fcst_dttm           lead_time valid_dttm            SID point_mbr000
#>    <dttm>                  <dbl> <dttm>              <dbl>        <dbl>
#>  1 2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001       0.277 
#>  2 2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001       0.650 
#>  3 2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001       0.601 
#>  4 2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001       0.427 
#>  5 2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001       0.0798
#>  6 2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001       0.762 
#>  7 2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001       0.347 
#>  8 2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001       0.488 
#>  9 2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001       0.438 
#> 10 2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001       0.662 
#> # ℹ 38 more rows
#> # ℹ 3 more variables: point_mbr001 <dbl>, ens_mean <dbl>, ens_sd <dbl>
ens_stats(ens_point_df, var = TRUE, min = TRUE, max = TRUE)
#> # A tibble: 48 × 9
#>    fcst_dttm           lead_time valid_dttm            SID ens_mean ens_sd
#>  * <dttm>                  <dbl> <dttm>              <dbl>    <dbl>  <dbl>
#>  1 2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001    0.533 0.362 
#>  2 2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001    0.597 0.0752
#>  3 2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001    0.528 0.104 
#>  4 2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001    0.552 0.177 
#>  5 2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001    0.306 0.320 
#>  6 2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001    0.434 0.463 
#>  7 2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001    0.377 0.0425
#>  8 2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001    0.273 0.304 
#>  9 2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001    0.692 0.359 
#> 10 2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001    0.562 0.141 
#> # ℹ 38 more rows
#> # ℹ 3 more variables: ens_var <dbl>, ens_min <dbl>, ens_max <dbl>
ens_stats(ens_grid_list)
#>  a
#> # A tibble: 24 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm          ens_mean  ens_sd
#>  * <chr>      <dttm>                  <dbl> <dttm>              <geolis> <geoli>
#>  1 a          2021-01-01 00:00:00         0 2021-01-01 00:00:00  [5 × 5] [5 × 5]
#>  2 a          2021-01-01 00:00:00         1 2021-01-01 01:00:00  [5 × 5] [5 × 5]
#>  3 a          2021-01-01 00:00:00         2 2021-01-01 02:00:00  [5 × 5] [5 × 5]
#>  4 a          2021-01-01 00:00:00         3 2021-01-01 03:00:00  [5 × 5] [5 × 5]
#>  5 a          2021-01-01 00:00:00         4 2021-01-01 04:00:00  [5 × 5] [5 × 5]
#>  6 a          2021-01-01 00:00:00         5 2021-01-01 05:00:00  [5 × 5] [5 × 5]
#>  7 a          2021-01-01 00:00:00         6 2021-01-01 06:00:00  [5 × 5] [5 × 5]
#>  8 a          2021-01-01 00:00:00         7 2021-01-01 07:00:00  [5 × 5] [5 × 5]
#>  9 a          2021-01-01 00:00:00         8 2021-01-01 08:00:00  [5 × 5] [5 × 5]
#> 10 a          2021-01-01 00:00:00         9 2021-01-01 09:00:00  [5 × 5] [5 × 5]
#> # ℹ 14 more rows
#> 
#>  b
#> # A tibble: 24 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm          ens_mean  ens_sd
#>  * <chr>      <dttm>                  <dbl> <dttm>              <geolis> <geoli>
#>  1 b          2021-01-01 00:00:00         0 2021-01-01 00:00:00  [5 × 5] [5 × 5]
#>  2 b          2021-01-01 00:00:00         1 2021-01-01 01:00:00  [5 × 5] [5 × 5]
#>  3 b          2021-01-01 00:00:00         2 2021-01-01 02:00:00  [5 × 5] [5 × 5]
#>  4 b          2021-01-01 00:00:00         3 2021-01-01 03:00:00  [5 × 5] [5 × 5]
#>  5 b          2021-01-01 00:00:00         4 2021-01-01 04:00:00  [5 × 5] [5 × 5]
#>  6 b          2021-01-01 00:00:00         5 2021-01-01 05:00:00  [5 × 5] [5 × 5]
#>  7 b          2021-01-01 00:00:00         6 2021-01-01 06:00:00  [5 × 5] [5 × 5]
#>  8 b          2021-01-01 00:00:00         7 2021-01-01 07:00:00  [5 × 5] [5 × 5]
#>  9 b          2021-01-01 00:00:00         8 2021-01-01 08:00:00  [5 × 5] [5 × 5]
#> 10 b          2021-01-01 00:00:00         9 2021-01-01 09:00:00  [5 × 5] [5 × 5]
#> # ℹ 14 more rows
#>