Practical Python demos for RMC-BestFit using pythonnet, with notebook-first workflows and script examples for flood frequency, rating curves, forecasting, and regional analysis.
notebooks/00_getting_started.ipynbto08_batch_workflow_and_reporting.ipynbexamples/runnable Python scriptsnotebooks/helper_functions.pyshared DLL path helpersbestfit-python-demos-scope.mdproject scope and roadmap
- Windows + Python 3.10+
- .NET runtime compatible with your BestFit build
- RMC DLLs:
RMC.BestFit.dllNumerics.dll
Python packages (see notebook-requirements.txt):
pythonnetnumpypandasmatplotlibscipystatsmodelsjupyter
- Install dependencies:
pip install -r notebook-requirements.txt
- Set DLL environment variables (recommended):
$env:RMC_BESTFIT_DLL="C:\GIT\RMC-BestFit Version 2.0 (Beta-3)\Release\Libraries\RMC.BestFit.dll" $env:RMC_NUMERICS_DLL="C:\GIT\RMC-BestFit Version 2.0 (Beta-3)\Release\Libraries\Numerics.dll"
- Start Jupyter:
jupyter lab
Open notebooks in numeric order starting with 00_getting_started.ipynb.
00_getting_started.ipynb: runtime setup, DLL loading, first distribution calls, troubleshooting01_distributions.ipynb: distribution tour and shape comparison02_distribution_fitting.ipynb: empirical return periods and fitted quantile curves03_bayesian_flood_frequency.ipynb: uncertainty workflow (bootstrap posterior proxy)04_model_selection_and_comparison.ipynb: AIC/BIC comparison patterns05_rating_curve_analysis.ipynb: segmented stage-discharge fitting06_time_serie_forecasting.ipynb: ARIMAX-style forecasting demo07_spatial_extremes.ipynb: index-flood regional pooling08_batch_workflow_and_reporting.ipynb: config-driven multi-site batch flow and exports
Each notebook includes:
- Intro context
- Step-by-step code
- End summary with recommended exercises
Run from repo root:
py examples\flood_frequency_simple.py py examples\rating_curve_example.py py examples\regional_analysis.py
Current script outputs:
outputs/tables/flood_frequency_empirical_vs_model.csvoutputs/tables/flood_frequency_return_period_table.csvoutputs/tables/rating_curve_observed_vs_fit.csvoutputs/tables/rating_curve_table.csvoutputs/tables/regional_analysis_site_records.csvoutputs/tables/regional_analysis_site_quantiles.csv
notebooks/helper_functions.py uses this order:
RMC_BESTFIT_DLL/RMC_NUMERICS_DLLenv vars- Known local default paths in this dev environment
If DLL load fails, verify paths first.
pythonnetruntime error at import:- ensure
pythonnet.load("netfx")for .NET Framework builds - switch to
coreclronly for .NET 6+ builds
- ensure
FileNotFoundErrorfor DLLs:- set env vars explicitly
AddReferenceload conflicts:- restart kernel/session and re-run top cells only once
- Some notebooks use synthetic data for deterministic demos.
- Scope and planned enhancements are tracked in
bestfit-python-demos-scope.md. Numerics-Python-Examplesin sibling folder was used as style/structure reference.