smash.hydrograph_segmentation#

smash.hydrograph_segmentation(model, gauge='all', peak_quant=0.995, peak_value=0, max_duration=240, by='obs')[source]#

Compute segmentation information of flood events over all catchments of Model.

Parameters:
modelModel

Primary data structure of the hydrological model smash.

gaugestr or list[str, …], default ‘all’

Type of gauge for segmentation. There are two ways to specify it:

  • An alias among 'all' (all gauge codes) or 'dws' (most downstream gauge code(s))

  • A gauge code or any sequence of gauge codes. The gauge code(s) given must belong to the gauge codes defined in the Model.mesh

>>> gauge = "dws"
>>> gauge = "V3524010"
>>> gauge = ["V3524010", "V3515010"]
peak_quantfloat or int, default 0.995

Events will be selected if their discharge peaks exceed the peak_quant-quantile of the observed or simulated (depending on the value of by) discharge time series.

peak_valuefloat or int, default 0

Events will be selected if their discharge peaks exceed the peak_value threshold of the observed or simulated (depending on the value of by) discharge time series (in m3/s). This is a complementary criterion to peak_quant even if peak_quant is not defined. Set peak_quant to 0 to disable it and use only peak_value.

max_durationfloat, default 240

The expected maximum duration of an event (in hours). If multiple events are detected, their duration may exceed this value.

bystr, default ‘obs’

Compute segmentation information based on observed ('obs') or simulated ('sim') discharges. A simulation (forward run or optimization) is required to obtain the simulated discharge when by is 'sim'.

Returns:
segmentationpandas.DataFrame

Flood events information obtained from segmentation algorithm. The dataframe has 7 columns which are

  • 'code' : the catchment code.

  • 'start' : the beginning of event.

  • 'end' : the end of event.

  • 'multipeak' : whether the event has multiple peaks.

  • 'maxrainfall' : the moment that the maximum precipitation is observed.

  • 'flood' : the moment that the maximum discharge is observed.

  • 'season' : the season in which the event occurs.

Examples

>>> from smash.factory import load_dataset
>>> setup, mesh = load_dataset("cance")
>>> model = smash.Model(setup, mesh)

Perform segmentation algorithm and display flood events information

>>> hydro_seg = smash.hydrograph_segmentation(model)
>>> hydro_seg
       code               start                   flood  season
0  V3524010 2014-11-03 03:00:00 ... 2014-11-04 19:00:00  autumn
1  V3515010 2014-11-03 10:00:00 ... 2014-11-04 20:00:00  autumn
2  V3517010 2014-11-03 08:00:00 ... 2014-11-04 16:00:00  autumn
[3 rows x 7 columns]

Access all flood events information for a single gauge

>>> hydro_seg[hydro_seg["code"] == "V3524010"]
       code               start  ...               flood  season
0  V3524010 2014-11-03 03:00:00  ... 2014-11-04 19:00:00  autumn
[1 rows x 7 columns]

Lower the peak_quant to potentially retrieve more events

>>> hydro_seg = smash.hydrograph_segmentation(model, peak_quant=0.99)
>>> hydro_seg
       code               start  ...               flood  season
0  V3524010 2014-10-10 04:00:00  ... 2014-10-13 02:00:00  autumn
1  V3524010 2014-11-03 03:00:00  ... 2014-11-04 19:00:00  autumn
2  V3515010 2014-10-10 04:00:00  ... 2014-10-13 00:00:00  autumn
3  V3515010 2014-11-03 10:00:00  ... 2014-11-04 20:00:00  autumn
4  V3517010 2014-10-09 15:00:00  ... 2014-10-10 23:00:00  autumn
5  V3517010 2014-11-03 08:00:00  ... 2014-11-04 16:00:00  autumn
[6 rows x 7 columns]

Once again, access all flood events information for a single gauge

>>> hydro_seg[hydro_seg["code"] == "V3524010"]
       code               start  ...               flood  season
0  V3524010 2014-10-10 04:00:00  ... 2014-10-13 02:00:00  autumn
1  V3524010 2014-11-03 03:00:00  ... 2014-11-04 19:00:00  autumn
[2 rows x 7 columns]