Skip to contents

Convert an ensemble forecast to deterministic.

Usage

as_det(x, member = NULL, sub_model = NULL)

Arguments

x

A harp data frame or harp list

member

Does not need to be supplied if there is only one ensemble member in x. Otherwise can be the member number, or the full name of the member column to treat as deterministic.

sub_model

For multimodel ensembles there may be columns with the same member number. Set to the name of the sub-model to select member for that sub-model.

Value

A harp deterministic data frame.

Examples

as_det(ens_point_df, 0)
#> ::deterministic point forecast:: # A tibble: 48 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID   fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <dbl>  <dbl>
#>  1 point      2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.277 
#>  2 point      2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.650 
#>  3 point      2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.601 
#>  4 point      2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.427 
#>  5 point      2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.0798
#>  6 point      2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.762 
#>  7 point      2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.347 
#>  8 point      2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.488 
#>  9 point      2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.438 
#> 10 point      2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.662 
#> # ℹ 38 more rows
as_det(ens_grid_df, 1)
#> ::deterministic gridded forecast:: # A tibble: 24 × 5
#>    fcst_model fcst_dttm           lead_time valid_dttm               fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <geolist>
#>  1 grid       2021-01-01 00:00:00         0 2021-01-01 00:00:00   [5 × 5]
#>  2 grid       2021-01-01 00:00:00         1 2021-01-01 01:00:00   [5 × 5]
#>  3 grid       2021-01-01 00:00:00         2 2021-01-01 02:00:00   [5 × 5]
#>  4 grid       2021-01-01 00:00:00         3 2021-01-01 03:00:00   [5 × 5]
#>  5 grid       2021-01-01 00:00:00         4 2021-01-01 04:00:00   [5 × 5]
#>  6 grid       2021-01-01 00:00:00         5 2021-01-01 05:00:00   [5 × 5]
#>  7 grid       2021-01-01 00:00:00         6 2021-01-01 06:00:00   [5 × 5]
#>  8 grid       2021-01-01 00:00:00         7 2021-01-01 07:00:00   [5 × 5]
#>  9 grid       2021-01-01 00:00:00         8 2021-01-01 08:00:00   [5 × 5]
#> 10 grid       2021-01-01 00:00:00         9 2021-01-01 09:00:00   [5 × 5]
#> # ℹ 14 more rows
as_det(ens_point_list, 0)
#>  a
#> ::deterministic point forecast:: # A tibble: 48 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID   fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <dbl>  <dbl>
#>  1 a          2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.461 
#>  2 a          2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.674 
#>  3 a          2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.944 
#>  4 a          2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.169 
#>  5 a          2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.729 
#>  6 a          2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.191 
#>  7 a          2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.266 
#>  8 a          2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.0762
#>  9 a          2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.308 
#> 10 a          2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.630 
#> # ℹ 38 more rows
#> 
#>  b
#> ::deterministic point forecast:: # A tibble: 48 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID  fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <dbl> <dbl>
#>  1 b          2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.887
#>  2 b          2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.401
#>  3 b          2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.534
#>  4 b          2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.509
#>  5 b          2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.442
#>  6 b          2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.319
#>  7 b          2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.971
#>  8 b          2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.452
#>  9 b          2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.547
#> 10 b          2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.339
#> # ℹ 38 more rows
#> 

# Name the member column explicitly
as_det(ens_point_df, "point_mbr000")
#> ::deterministic point forecast:: # A tibble: 48 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID   fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <dbl>  <dbl>
#>  1 point      2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.277 
#>  2 point      2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.650 
#>  3 point      2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.601 
#>  4 point      2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.427 
#>  5 point      2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.0798
#>  6 point      2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.762 
#>  7 point      2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.347 
#>  8 point      2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.488 
#>  9 point      2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.438 
#> 10 point      2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.662 
#> # ℹ 38 more rows