InterJIA workshop · Madrid · November 2026

Hybrid modelling of compound floods with BlueMath

HyDeCoFfEE: sea, river and rain in the Santoña estuary. From 100 SFINCS simulations to 3 × 100 years of flood maps, in your browser and in your notebooks.

A simpler version of HyCoFfEE (Hybrid Approaches Predicting Compound Flooding for Estuarine Environments), with SFINCS instead of SCHISM.

GeoOcean Universidad de Cantabria IAHR

Geomatics and Ocean Engineering Group (GeoOcean) · Universidad de Cantabria

Today

Four steps, four notebooks

Each block is a short talk with interactive demos, then you run the notebook. About two hours in total.

15 min

BlueMath & the case

Why hybrid models, and the Santoña estuary.

15 + 25 min · notebook 01

Sample & simulate

LHS + MDA pick 100 days, SFINCS floods them, PCA compresses the maps.

LHS · MDA · PCA
10 + 10 min · notebook 02

Surrogate

An RBF learns the flood map of any day in milliseconds.

RBF
10 + 10 min · notebook 03

Climate emulator

Weather types and copulas generate 3 × 100 years of plausible days.

KMA · copulas
10 + 10 min · notebook 04

Flood climate

110,000 days through the surrogate: return periods and flood maps.

HyFlood
Got lost? Set USE_PRETRAINED = True at the top of notebooks 02 and 04: they then read our models from notebooks/pretrained/.
Your lab for today

Everything is ready in the browser

1 · Open Codespaces

On github.com/GeoOcean/BlueMath_Course_InterJIA, click Code → Codespaces → Create. Wait about a minute: everything is installed.

2 · Run the notebooks in order

Open notebooks/01 and choose the Python kernel in /opt/conda. Then 02, 03 and 04.

3 · Stuck?

Set USE_PRETRAINED = True at the top of notebooks 02 and 04 (run_sfincs = False in 01) and continue with our results.

notebooks/ ├── 01_SFINCS_wrapper.ipynb ├── 02_Surrogate.ipynb ├── 03_Emulator.ipynb ├── 04_Flood_climate.ipynb ├── data/ inputs ├── pretrained/ our results └── utils/ helper code
Who we are

GeoOcean: Geomatics and Ocean Engineering group

Universidad de Cantabria, Santander. We study ocean and coastal processes with numerical models, statistics and data, and turn the methods into open tools such as BlueMath.

geoocean.unican.es

16

people

47

projects

141

publications

24

partners

Coastal flooding & storm surgeWaves & nearshore processes Estuarine hydrodynamicsClimate change & sea level Data mining & metamodelsRisk modelling Geomatics & remote sensingScientific software

With partners such as USGS, NOAA, Scripps, CSIRO, NIWA, the Pacific Community, Puertos del Estado and IEO.

Your instructors today

Who is talking

Jared Ortiz-Angulo

Jared Ortiz-Angulo

PhD student · compound flooding

Civil engineer (Granada), MSc in Coast and Port Engineering (Cantabria) and expert in numerical simulation (UPM). Many projects on coastal processes and on the impact of climate change on the coast.

PhD at Universidad de Cantabria: hybrid short-term prediction and climate-change projection systems for compound flooding.

jared.ortizangulo@unican.es

Javier Tausia

Javier Tausia

Software developer · technical researcher

Physics (2016) and MSc in Data Science (2020), Universidad de Cantabria.

Develops efficient meteo-oceanographic tools, and new ways of coding that widen the usability and reach of the group's methods: BlueMath.

javier.tausia@unican.es

BlueMath · GeoOcean, Universidad de Cantabria

Small pieces.
Bigger ocean science.

BlueMath is an open-source Python framework for the statistical analysis and simulation of coastal climate hazards. Years of research broken into small, reusable pieces that anyone can snap together into methods and climate services.

github.com/GeoOcean/BlueMath

Why we built it

Most coastal research is hard to reuse

70%

of researchers failed to reproduce someone else's published research.

Baker, 2016
>50%

failed to reproduce their own experiments.

Baker, 2016
11%

of the analysed papers provided their code.

Jansen et al., 2020

Research slows down when every new method has to be rebuilt from scratch before it fits into an existing workflow. BlueMath turns that work into shared pieces that are written once, tested, and reused.

Three layers

Pieces snap into methods. Methods stack into services.

How you run it today

One image, every machine

You work here
This repositorynotebooks and data
Docker imagegeoocean/interjia
Python + bluemath-tkand everything the notebooks need
SFINCSthe flood model
Ubuntu 22.04system libraries
Runs on
GitHub Codespacesin the browser · today
Your laptopDocker · Linux, Windows, macOS
A clusterApptainer · many cores

Installed once, the same everywhere: same results on any machine. Platforms such as EDITO run models the same way.

Coming to BlueMath

HYDRA: hydrology and climate in Python

From raw data to scenarios, simulations and risk products, in reproducible workflows.

HYDRA website ↗

1

Data

Automatic downloads: precipitation, discharge, climate change, soils

2

Climate analysis

Extremes, regional frequency, copulas, spatial interpolation

3

Stochastic generation

Synthetic series and multisite rainfall

4

Modelling

Hydrological and hydraulic models, automated

DATA SOURCES

ERA5 · GPM · AEMET · Meteostat · GloFAS · GRDC · CMIP6 · SoilGrids

MODELS

HEC-HMS · SWAT+ · HEC-RAS · SFINCS

Today the river discharge and the rain come as files. With HYDRA in BlueMath, the same SFINCS workflow could start from the downloads and the stochastic rainfall.

The hybrid recipe

Expensive physics where it matters, statistics everywhere else

01

Sample

Cover all plausible days

LHS
01

Select

Keep the 100 most different

MDA
01

Simulate

Run the physics on those 100 days only

SFINCS
01

Reduce

Flood maps → a few numbers

PCA
02

Learn

Forcing → numbers → map

RBF
03 · 04

Emulate

Thousands of years of days → flood statistics

KMA · copulas
2.6 days

SFINCS on the 110,673 emulated days (~2 s each)

~5 min

SFINCS on the 100 selected days, in parallel on a laptop

seconds

The surrogate on the 110,673 days

Where it is applied

Same hybrid recipe, different processes

Method What it does Figure Paper
BinWaves Nearshore wave spectra by superposing monochromatic cases (SWAN) Paper ↗
HyWaves Nearshore wave spectra with a SnapWave metamodel (MDA + PCA + GP) Paper ↗
HyWaThy / HyBeat Nearshore waves over changing beach bathymetry (XBeach) Paper ↗
HySwash Nearshore hydrodynamics and run-up on beaches and reefs (SWASH) Paper ↗
HyCReWW Wave run-up on coral reefs of any shape (XBeach) Paper ↗
SHyTCWaves Tropical-cyclone wave fields without a SWAN run per storm Paper ↗
GreenSurge Storm-surge fields with an additive hybrid model Paper ↗
HyCoFfEE Compound flooding in estuaries from waves, surge, tide and rain (SCHISM) Paper ↗
HyFlood High-resolution compound coastal flood maps with cascaded surrogates Paper ↗
HySalt Estuary salinity and water level from a few Delft3D-FLOW runs Paper ↗

Today: HyDeCoFfEE, a decaff version of HyCoFfEE, and with SFINCS instead of SCHISM.
Waves, surge, cyclones, run-up, salinity, floods: the same playbook at every scale.

The case

The Santoña estuary floods from three sides

  • The sea: tide + storm surge + wave setup enter through the mouth, between El Puntal and Santoña.
  • The river: the Asón brings up to ~1,200 m³/s into the south of the estuary.
  • The rain: falls on the whole domain, marshes and valleys included.
Often the three arrive on the same day: a compound flood. Modelling each driver alone misses it.

Hover the map: elevation from the 20 m topobathymetry (UTM 30N). The dashed area is the SFINCS domain, closed at the mouth.

Data · 2008–2018

Ten years of daily drivers

Data · 3,716 days

Are the drivers related?

River and rain go together: rain generates the runoff. A big flood with no rain is not physical.

The sea is driven by the tide, the surge and the waves: almost independent of the river.

The sampling of notebook 01 and the emulator of notebook 03 must respect this structure.
01
Notebook 01 · SFINCS wrapper

Sample and simulate

We cannot run SFINCS for every possible day. Which days do we run?

Latin HypercubeMaximum DissimilaritySFINCS forcingsubgridPCA
01 Sampling

Random vs Latin Hypercube

Random sampling leaves gaps and clusters, by chance.

LHS splits every variable into N equal strata and puts exactly one sample in each row and each column: one shaded cell per row and per column.

Every value range is covered, whatever N. Here the samples sit at the centre of their cells; in bluemath-tk they are placed at random inside them. In 3D (TWL, Q, rain) the idea is the same.

Notebook: LHS(num_dimensions=3, seed=1) → 20,000 samples.
01 Sampling

Keep it physical

The LHS samples Q and rain independently: it proposes a river flood on a dry day.

We keep only the samples inside the convex hull of the observed (Q, rain) pairs.

The TWL is left free: high tide + river flood stays possible.

20,000 → 13,457 plausible scenarios.
01 Selection

Maximum Dissimilarity: the most different days

  1. Start from an extreme point.
  2. For every point, compute its distance to the closest point already selected.
  3. Select the point with the largest of those distances.
  4. Repeat until you have N.

The selection covers the edges first: exactly where the extremes are. Random selection mostly picks the crowded centre.

01 Selection

100 days for SFINCS

The real selection of the notebook: MDA on the 13,457 plausible scenarios, normalised to [0, 1].

Move the slider: the first cases are the corners of the space. Drag the plot to rotate it.

MDA(num_centers=100).fit(data, normalize_data=True)
01 Forcing

From one daily value to a SFINCS forcing

Sea: a triangle peaking at hour 12. The tide is symmetric around the mean level and the residual (surge + setup) is nearly constant over a day, so TWL min = 2 NTR ‾ − TWL max

River: the SCS unit hydrograph scaled to the daily peak, shifted by a random lag of ±2–6 h.

Rain: the daily depth spread uniformly over the 24 h.

01 SFINCS

A fast flood model, thanks to subgrid

SFINCS (Deltares) solves simplified shallow-water equations: fast enough for compound floods over large areas.

  • 100 m computational grid, 175 × 127 cells
  • Subgrid tables from the 20 m DEM: each cell knows how its volume and wet area grow with the level
  • Water level imposed on the mouth line, Asón at the southern edge, rain on every cell
  • ~2 s per day of simulation

Move the water level: a coarse model without subgrid sees the cell as either dry or wet; the subgrid cell fills gradually, like the real terrain.

01 Wrappers

One SFINCS setup, 100 cases, one dataset

A bluemath-tk wrapper builds the model once, makes a folder for every case, runs them anywhere and returns all the results together. You only describe what changes between cases.

1 · Template

Build it once

templates/
├─ sfincs.ind  sfincs.msk
└─ sfincs_subgrid.nc

Grid, active cells and subgrid tables from the DEM (fixed_parameters, HydroMT).

2 · Cases

A folder per day

cases/
├─ 0000/ .bzs .dis .precip
├─ 0001/ ...
└─ ... 100 cases

Each MDA day writes its sea, river and rain forcing (metamodel_parameters).

3 · Run

Anywhere

serial     sfincs
docker     sfincs-cpu
apptainer  sfincs.sif

A launcher is just a command. One case per core, a log in each folder.

4 · Collect

One dataset back

water_level_cases(...)
# zs (case_num, y, x)

The maximum water level of the 100 cases in one xarray Dataset, ready for PCA.

Same four steps for every model: SWAN · SWASH · XBeach · Delft3D · SCHISM · SFINCS · your own. To add the Asón river we subclassed the SFINCS wrapper: build_case also writes sfincs.src + sfincs.dis (notebooks/utils/sfincs_wrapper.py).
01 Wrappers, live

1 template → 100 SFINCS runs → 1 dataset

01 Results

Each driver floods a different place

01 PCA

Principal components in two dimensions

PCA finds the directions where the data vary the most. Rotate the axis: the variance of the projections is largest along PC1.

With correlated variables, one direction captures almost everything, and the second adds little.

Our "variables" are the 2,910 wet cells of a flood map. Most of them rise and fall together.
01 PCA

2,910 cells → 8 numbers

Hands-on · 25 min

Your turn: notebook 01

notebooks/01_SFINCS_wrapper.ipynb
  1. Look at the historical days and build the LHS + hull + MDA selection.
  2. Plot the forcing of a few cases. Which lag did each case get?
  3. Build the SFINCS model and run the 100 cases (a few minutes).
  4. Compare the flood maps of the six situations.
  5. Fit the PCA: how many components do you need?
No SFINCS on your machine? Set run_sfincs = False: the notebook uses our results.
25′

You should see:

SFINCS cases run: 100 of 100 8 PCs explain 99.91% of the variance
02
Notebook 02 · Surrogate

A flood model in milliseconds

An interpolator learns the 100 SFINCS runs and predicts the flood map of any day.

radial basis functionsinverse PCAk-fold cross-validation
02 RBF

Radial basis functions in one dimension

The prediction is a weighted sum of bumps centred at the training points, plus a linear trend:

f ( x ) = ∑ i w i e − ‖ x − x i ‖ 2 / 2 σ 2 + a 0 + a · x

The weights make f pass exactly through every training point. σ sets how far each point reaches.

Click on the plot to add a training point. bluemath-tk optimises σ for each output.

02 The surrogate

From the forcing to a flood map

input

3 numbers

TWL, Q, rain, normalised to [0, 1]

× 8 RBFs

8 PCs

One RBF per principal component, each with its own σ

RBF
inverse PCA

Water level

mean + Σ PCk · EOFk on the 100 m grid

PCA
subgrid downscaling

Water depth

max(level − DEM, 0) on the 20 m DEM

hydromt-sfincs
output

Flood map

In milliseconds, for any day

Why water level, not depth?

The level is a smooth surface defined in every active cell: PCA and RBF handle it well. The DEM adds the sharp wet/dry edges afterwards.

What the RBF cannot do

It interpolates between the 100 SFINCS days. Outside their range (bigger storms than ever simulated) it is not reliable.

02 Live

Your own flood, computed in this browser

02 Validation

How many SFINCS runs do we need?

Hands-on · 10 min

Your turn: notebook 02

notebooks/02_Surrogate.ipynb
  1. Fit the RBF from the forcing to the 8 PCs.
  2. Run the 5-fold cross-validation and look at the error vs the number of SFINCS runs.
  3. Compare SFINCS and RBF for the worst and the median case. Where does the surrogate fail?
  4. Predict your own days: change new_days.
💬 How would you improve it? More runs, another kernel, fewer PCs…
10′

Lost? USE_PRETRAINED = True

03
Notebook 03 · Climate emulator

Hundreds of years of weather

Ten years of data cannot tell us the 100-year flood. We simulate plausible days that keep the physics of the weather.

weather typesALRGaussian copulasvalidation
03 Why emulate

From weather patterns to daily drivers

daily · given

Daily weather types

25 patterns of sea level pressure around Iberia, 1979–2018

PCA · KMA
yearly · given

Annual weather types

5 types of year, from the share of each DWT in the year

PCA · KMA
simulation · given

Two ALR models

AWT year by year, then DWT day by day with the AWT PCs as covariates

ALR
daily · notebook 03

One copula per type

Rain, surge + setup and river discharge sampled together

Gaussian copula
output

3 × 100 years

110,673 plausible days, with the right dependence

The simulated DWT series (data/xds_output.nc) is given. In notebook 03 you fit the copulas and simulate the drivers. The tide is added in notebook 04.
03 Predictor

25 daily weather types

Sea level pressure, its gradient and the 500 hPa geopotential, 1979–2018 → PCA (90% of the variance) + KMA guided by local rain and wind.

03 Annual weather types

From daily types to the character of a year

Count the DWTs of each year: 25 probabilities per year, summing to 100%.

Some years have more stormy types, others more anticyclonic ones. PCA (3 PCs) + KMA groups the 40 years into 5 annual weather types.

Each AWT is a different mix of daily types: it sets which days are more likely that year.

The 3 PCs of each year are kept: they are the covariates of the daily model.
03 ALR · annual

Simulating the sequence of years

An autoregressive logistic regression gives the probability of each AWT next year, knowing this year's.

P(AWTt = i) ∝ exp(αi + βi·AWTt−1)

Terms: intercept + Markov order 1. Simulated: 3 sequences, 1999–2100.

Only 6–10 years per AWT: a Gaussian copula with KDE marginals populates the PC space of each AWT (1000 samples).

Each simulated year then picks its 3 PCs at random from the populated PCs of its AWT.

ALR_WRP(...).Simulate(num_sims=3, ...): done for you, in data/AWT_SIM_nsims3_2000_2100.nc.
03 ALR · daily

Simulating the weather day by day

A second ALR gives the probability of each of the 25 DWTs tomorrow.

intercept
season   cos/sin 2πt, 4πt
AWT      PC1 PC2 PC3 of the year
Markov   DWT of yesterday

The seasonality brings winter storms in winter; the AWT PCs make some years stormier; Markov keeps the persistence of the weather.

Covariates: the simulated PCs of the annual ALR, one value per year, repeated for every day.

Output, given: data/xds_output.nc, 3 × 100 years of DWTs. Notebook 03 starts here.
03 Copulas

A Gaussian copula: dependence and marginals, separately

03 Copulas

One copula per weather type

03 Output

Synthetic weather, validated

Hands-on · 10 min

Your turn: notebook 03

notebooks/03_Emulator.ipynb
  1. Load the weather types and join them with the daily drivers.
  2. Fit one Gaussian copula per type and look at its correlations.
  3. Simulate 3 × 100 years from the simulated weather types.
  4. Validate: histograms per type, scatter, QQ and annual maxima.
  5. Plot one simulation with its DWTs and AWTs underneath.
💬 Try the ECDF kernel instead of KDE for a variable: what happens to the extremes?
10′

It writes outputs/simulated_precip_ss_q.nc for notebook 04.

04
Notebook 04 · Flood climate

3 × 100 years of floods in seconds

The emulator gives the days, the surrogate gives the maps. Together: flood statistics.

tide + surgetraining rangereturn periodscompound drivers
04 Total water level

Adding the tide back

04 Statistics

Return periods from 3 × 100 emulated years

04 Maps

The flood map of any return period

04 Compound flooding

Two places, two different floods

Hands-on · 10 min

Your turn: notebook 04

notebooks/04_Flood_climate.ipynb
  1. Rebuild the TWL = tide + surge + setup of every emulated day.
  2. Check how many days fall outside the training range.
  3. Run the 110,673 days through the surrogate and get the annual maxima.
  4. Plot the return-period curves and the 10- and 100-year maps.
  5. Which driver makes the annual maximum at each location?
10′
💬 What limits the confidence in the 100-year level? What about the days above the training range?
Wrap-up

What we built today

100

SFINCS runs, chosen with LHS + MDA

8

principal components per flood map (99.9%)

110,673

emulated days through the RBF surrogate

1:100

year flood map, without fitting an extreme-value distribution

The same recipe works for waves (HySwash, HyBeat), cyclones (SHyTCWaves) or any expensive model: simulate a few, learn them, emulate many.

Discussion

Where to be careful

The training range

The RBF interpolates. Emulated days above the simulated maxima are clipped, and the rarest floods are underestimated. Add SFINCS runs at the edges.

Simplified forcing

One triangle, one hydrograph, uniform rain and a random lag per day: the timing of the drivers matters for compound floods.

The emulator

3 × 100 years from 10 years of local data and 40 of weather types. The tide is drawn independently of the weather.

A changing climate

Add sea level rise to the TWL, or drive the emulator with weather types from climate projections.

Thank you

Start with one piece.

Clone the repositories, pick a piece, and build something bigger on top of it.

GeoOcean Universidad de Cantabria IAHR

Contribute to BlueMath

Develop code, use and test the methods on your coast, bring computing power, start a project, host a course. Open an issue or a pull request.

Credits

BlueMath toolkit (GeoOcean): LHS, MDA, PCA, RBF and the climate emulator. SFINCS and HydroMT-SFINCS (Deltares). Licensed GPL-3.0.