Flood Modeling#
The flood model can be imported using the following command. The flood model has been build using the following literature resources
[SanchezMunozDominguezGarciaMartinezG+20]
from IPython.display import display, HTML
import plotly.graph_objects as go
import plotly.io as pio
pio.renderers.default = "notebook_connected"
from erad.models.hazard import FloodModel, FloodModelArea
An instance of FloodModel requires to pieces of information,
- timestamp: The timestamp for the flood event 
- affected_areas: list of area affected the flood represented by FloodModelArea 
Each area affected by flooding is represented by polygon with water level and flowrate.
This enables users to define mutiple areas affected by a given flodd with uniwue parameters.
from datetime import datetime
from gdm.quantities import Distance
from shapely.geometry import Polygon
from erad.quantities import Speed
flood_area = FloodModelArea(
    affected_area=Polygon(
        [
            (-120.93036, 36.60144),
            (-120.91072, 36.60206),
            (-120.91127, 36.5712),
            (-120.93405, 36.58100),
        ]
    ),
    water_velocity=Speed(50, "meter/second"),
    water_elevation=Distance(10, "feet"),
)
flood = FloodModel(
    name="flood 1",
    timestamp=datetime.now(),
    affected_areas=[flood_area],
)
flood.pprint()
FloodModel( name='flood 1', timestamp=datetime.datetime(2025, 10, 28, 17, 34, 59, 528280), affected_areas=[ FloodModelArea( name='', affected_area=<POLYGON ((-120.93 36.601, -120.911 36.602, -120.911 36.571, -120.934 36.581...>, water_velocity=<Quantity(50, 'meter / second')>, water_elevation=<Quantity(10, 'foot')> ) ] )
An example of the FloodModel can be built using the example() methods for testing purposes.
flood_example = FloodModel.example()
flood_example.pprint()
FloodModel( name='flood 1', timestamp=datetime.datetime(2025, 10, 28, 17, 34, 59, 551365), affected_areas=[ FloodModelArea( name='', affected_area=<POLYGON ((-120.93 36.601, -120.911 36.602, -120.911 36.571, -120.934 36.581...>, water_velocity=<Quantity(50, 'meter / second')>, water_elevation=<Quantity(10, 'foot')> ) ] )
Plotting the Flood Model#
fig = go.Figure()
flood_example.plot(figure=fig)
display(HTML(pio.to_html(fig, include_plotlyjs="cdn", full_html=False)))
