Skip to contents

Format return periods and calculate trapezoidal integration weights for a Sector or Case object, optionally including the global summary.

Usage

format_flood(x, add_total = TRUE)

Arguments

x

An object of class Sector or Case.

add_total

Logical scalar (default TRUE), whether to include the "global" summary row when x is a Case with multiple sectors.

Value

If x is a Sector: a matrix with 2 rows (period and weight) and flood events as columns. If x is a Case: a named list of such matrices for each sector (and "global" if add_total = TRUE).

Details

Integration weights are computed from return periods using calculate_weight().

  • For a Sector object, return periods in x["flood"] are extracted and bound into a 2-row matrix (period and weight).

  • For a Case object, return periods are retrieved from x["period"] across all sectors. If add_total = TRUE (default) and multiple sectors are present, the "global" aggregation row is retained; otherwise it is excluded.

Author

Frédéric Grelot, frederic.grelot.1994_cran@m4x.org

Examples

case = import_case(
    system.file("extdata", "case", "complete.ods", package = "floodam.cba")
)
#> import Case from /tmp/RtmpvMoJJK/temp_libpath2b69f6f14b9e9/floodam.cba/extdata/case/complete.ods
#>  ... done
format_flood(case)
#> $sector_1
#>           min      med     max
#> period 10.000 100.0000 1.0e+03
#> weight  0.045   0.0495 4.5e-03
#> 
#> $sector_2
#>         min    med   max
#> period 5.00 50.000 5e+02
#> weight 0.09  0.099 9e-03
#> 
#> $sector_3
#>                min     med          max
#> period 10.00000000 75.0000 1.000000e+03
#> weight  0.04333333  0.0495 6.166667e-03
#> 
#> $global
#>               min     med          max
#> period 8.33333333 75.0000 8.333333e+02
#> weight 0.05333333  0.0594 6.066667e-03
#> 
format_flood(case["sector"][[1]])
#>           min      med     max
#> period 10.000 100.0000 1.0e+03
#> weight  0.045   0.0495 4.5e-03