• Python Environment Setup
• Tools Overview
Section 01: Preprocessing
• 1_Model_Config/ — copy, edit, run
• What goes inside model_config_<project>.py
• The HTML configuration report
Section 02: Post-Processing
• 2_Read_Outputs/read_output_template.py
• The HTML flood-statistics report
• fluxos_viewer.py (KML / WebGL / MP4)
• Summary
Create the venv once after clone:
# 1. Create the venv python3 -m venv .venv # 2. Activate (the conda/unset lines are harmless # w/o Conda; they stop a stale PROJ_LIB from # hanging `import rasterio`) conda deactivate 2>/dev/null || true unset PROJ_LIB PROJ_DATA source .venv/bin/activate # 3. Install deps pip install --upgrade pip pip install -r supporting_scripts/requirements.txt # 4. Verify — call the venv's own python directly with a clean # environment. This is the "it just works" form: no timeout, # no retries, no chance of a Conda shim interfering. env -u PROJ_LIB -u PROJ_DATA -u GDAL_DATA \ -u CONDA_PREFIX -u CONDA_DEFAULT_ENV \ ./.venv/bin/python -c "import rasterio, pygmsh, pyvista; print('ok')" # → if it hangs > 10 s, see the troubleshooting note on the right
rasterio | GeoTIFF I/O |
numpy / scipy | arrays, resampling |
pygmsh, gmsh | triangular meshing |
pyvista | read .vtu output |
gmsh wheel fails?
brew install gmsh (macOS) /
apt install gmsh (Linux), then re-run pip.
Verify still hangs?
Conda is polluting the child process with
DYLD/LD_LIBRARY_PATH. Last resort:
open a fresh terminal (no auto-Conda),
source .venv/bin/activate and re-run
step 4. Or permanently disable Conda auto-activation:
conda config --set auto_activate_base false.
Windows PowerShell:
if ($env:CONDA_DEFAULT_ENV){conda deactivate};
Remove-Item Env:PROJ_LIB,Env:PROJ_DATA -EA SilentlyContinue;
.venv\Scripts\Activate.ps1; then
.venv\Scripts\python -c "import rasterio, pygmsh, pyvista; print('ok')".
Two editable templates drive the full workflow — the user only edits these two files. Everything else is internal library code.
1_Model_Config/
model_config_template.py
One editable template that builds the DEM (.asc), Gmsh triangular mesh
(.msh), and modset.json in one run — and emits an
HTML configuration report with copy-paste Docker commands.
2_Read_Outputs/
read_output_template.py
Streams FLUXOS output files and emits an HTML flood-statistics report with time-series (volume, flooded area, depth, velocity), max-inundation map, hazard classification, depth histogram, and first-inundation map.
2_Read_Outputs/output_supporting_lib/
fluxos_viewer.py
Standalone CLI that exports the same results as animated KML (Google Earth), MP4 video, or an interactive 3D WebGL page.
supporting_scripts/1_Model_Config/ +
supporting_scripts/2_Read_Outputs/
The preprocessing entry point is a single Python file you copy, edit, and run. The template never changes — each project gets its own copy so configurations are reproducible and diff-able under version control.
# 1. Move into the 1_Model_Config folder # If you are in FLUXOS_cpp, you can run cd supporting_scripts/1_Model_Config/ # 2. Copy the template to a project-specific name # (anything like model_config_<project>.py) cp model_config_template.py \ model_config_myTest.py # 3. Open the copy and edit the _config dict # (see next slide for the fields you need to set) # You can also just double-click the file and edit # it in any text editor — VS Code, Sublime, PyCharm, # TextEdit, Notepad++, etc. — no terminal needed. nano model_config_myTest.py # 4. Run it — from this folder OR anywhere else, # just point python at your edited copy python model_config_myTest.py # (run from repo root instead, if you prefer): # python supporting_scripts/1_Model_Config/\ # model_config_myTest.py
1_Model_Config/model_config_template.py directly; keep it pristineproject_name, DEM source, bbox, mesh size, inflow point, simulation dates (details on the next slide)source .venv/bin/activate
(see slide 3). The template imports rasterio /
pygmsh — they have to be installed.
git checkout +
python model_config_<project>.py.
model_config_template.py, Rosa Creek case study). It runs
out-of-the-box on the GeoTIFF shipped at Working_example/Rosa_2m.tif
— no edits needed.
_config = dict(
project_name = "Rosa Creek",
authors = ["Diogo Costa"],
date = "2026-04-21",
output_bin_dir = "Working_example",
modset_name = "modset_rosa.json",
# --- DEM: local GeoTIFF ---
dem_source_mode = "file",
dem_source_geotiff = "Working_example/Rosa_2m.tif",
dem_target_resolution_m = 2.0,
dem_output_asc = "Rosa_2m.asc",
# --- Mesh ---
mesh_type = "regular",
trimesh_min_size = 2.0,
trimesh_max_size = 30.0,
trimesh_slope_factor = 2.0,
mesh_output_msh = "Rosa_trimesh.msh",
# --- Forcing ---
meteo_file = None, # no rain; hydrograph-driven
inflow_file = dict(
path = "Working_example/Flow_river_30h.fluxos",
lon = -124.08154, lat = 52.21373, # Rosa inlet, UTM 10N
),
# --- Simulation + output ---
sim_datetime_start = "2009-01-01 00:00:00",
roughness_height = 0.005,
output_folder = "Results/",
print_step_s = 1800,
h_min_to_print_m = 0.001,
# --- Optional modules ---
ade_transport = dict(enabled=False, d_coef=0.5),
soil_infiltration = dict(enabled=False, default_ks_mm_hr=10.0),
# --- Run options ---
fluxos_executable = "bin/fluxos",
generate_report = True,
)
Working_example/<dem>.asc — ESRI-ASCII DEMWorking_example/<mesh>.msh — Gmsh triangular mesh (only for mesh_type="triangular")Working_example/<modset>.json — solver input1_Model_Config/reports/ with copy-paste Docker compile + run commands"download" mode reprojects to UTM automatically
(e.g. EPSG:32629 for Portugal).
Each run of model_config_template.py opens a self-contained
HTML report in your browser. One page, no further navigation needed to
build and run the model.
cd <repo>docker compose ... build (or Apptainer equivalent)/work/bin and run the modsetResults/ directorypython model_config_template.py and follow the links in the report.
# Edit the _config dict: _config = dict( project_name = "Rosa Creek", # Folder FLUXOS wrote to results_dir = "Results_river_30h", # The modset that drove the run modset_file = "Working_example/modset_river_30h.json", # Flooded = cells with h > this (metres) h_threshold_flooded_m = 0.01, # Analyse every Nth timestep stride = 1, generate_report = True, export_csv_timeseries = True, ) # Then run it: cd supporting_scripts/2_Read_Outputs python read_output_template.py
max / mean conc_SW vs. time.txt files analyses fine on a laptop.
# Lives at 2_Read_Outputs/output_supporting_lib/fluxos_viewer.py # Add --mesh-type triangular for .vtu output (regular = .txt default) # Interactive 3D WebGL viewer (starts a local HTTP server # on --webgl-port and opens http://localhost:8080) python supporting_scripts/2_Read_Outputs/\ output_supporting_lib/fluxos_viewer.py \ --results-dir Results/ \ --dem Working_example/Rosa_2m.asc \ --utm-zone 10 \ --export-webgl \ --webgl-output fluxos_web_rosa \ --webgl-step 1 \ --webgl-port 8080 # Animated KML/KMZ for Google Earth # (default action if neither --export-webgl nor --export-video given) python fluxos_viewer.py \ --results-dir Results/ \ --dem Working_example/Rosa_2m.asc \ --utm-zone 10 \ --output-dir fluxos_kml_rosa # MP4 animation (requires ffmpeg in PATH) python fluxos_viewer.py \ --results-dir Results/ \ --dem Working_example/Rosa_2m.asc \ --utm-zone 10 \ --export-video mp4 \ --video-output flood.mp4 \ --video-fps 15
.txt) and triangular (.vtu) output — pass --mesh-type--variable h (default), velocity, conc_SWindex.html + data); a local HTTP server auto-opens in the browser~/.fluxos_tile_cache/ so re-runs skip the network--webgl-step N | keep every Nth snapshot (smaller bundle) |
--webgl-no-serve | export only, don't start the server |
--video-scale N | Nx DEM resolution for MP4 frames |
--velocity-arrows | overlay flow arrows on KML / MP4 |
| Template / Tool | Role | User edits | Output |
|---|---|---|---|
| 1_Model_Config/ model_config_template.py |
Preprocessing | copy → edit _config dict of the copy |
DEM .asc, mesh .msh, modset.json, HTML configuration report (with ready-to-paste Docker, sim-run, and visualisation snippets) |
| 2_Read_Outputs/ read_output_template.py |
Post-processing (statistics) | flags on the CLI, or _config if running the template |
HTML flood-statistics report: time-series, max-inundation & first-inundation maps, ARR-2019 hazard map, depth histogram |
| 2_Read_Outputs/output_supporting_lib/ fluxos_viewer.py |
Post-processing (visualisation) | flags only | Interactive WebGL viewer folder, animated KML/KMZ for Google Earth, or MP4 video |
python3 -m venv .venv & install requirements →
cp model_config_template.py model_config_<project>.py →
edit the copy →
python model_config_<project>.py →
open the HTML report and paste its Next-Steps snippets
(compile FLUXOS, run the sim, visualise results).
python model_config_<project>.py.
GitHub: github.com/ue-hydro/FLUXOS_cpp
Documentation: fluxos-cpp.readthedocs.io
Contact: diogo.costa@uevora.pt