diff --git a/pyproject.toml b/pyproject.toml index 1f16fa2e5..84766255b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,8 @@ test = [ "geopandas", ] +app = ["streamlit>=1.41.1"] + notebooks = ["nbformat", "nbconvert", "jupyter", "plotly", "shapely", "seaborn"] [project.urls] diff --git a/tests/testdata/SW/eur_Hm0_F3_wind.dfs0 b/tests/testdata/SW/eur_Hm0_F3_wind.dfs0 new file mode 100644 index 000000000..ed6036c91 Binary files /dev/null and b/tests/testdata/SW/eur_Hm0_F3_wind.dfs0 differ diff --git a/web/README.md b/web/README.md new file mode 100644 index 000000000..982382b53 --- /dev/null +++ b/web/README.md @@ -0,0 +1,15 @@ +# FMSkill web application + +## Installation + +``` +$pip install streamlit +``` + +Usage: +``` +$streamlit run web/app.py +``` + +![](screenshot.png) + diff --git a/web/app.py b/web/app.py new file mode 100644 index 000000000..36f0242da --- /dev/null +++ b/web/app.py @@ -0,0 +1,55 @@ +import tempfile +from pathlib import Path +import streamlit as st +import mikeio +import modelskill +import matplotlib.pyplot as plt + +""" +# ModelSkill Drag and Drop +""" + +tmp = Path(tempfile.mkdtemp()) + +with st.sidebar: + obs = st.file_uploader("Observation", type="dfs0") + + if obs: + fn_obs = tmp / "obs.dfs0" + fn_obs.write_bytes(obs.getvalue()) + + dfs = mikeio.open(fn_obs) + obs_item = st.selectbox("Item", options=[i.name for i in dfs.items]) + + mod = st.file_uploader("Model", type="dfs0") + + if mod: + fn_mod = tmp / "mod.dfs0" + fn_mod.write_bytes(mod.getvalue()) + mdfs = mikeio.open(fn_mod) + mod_item = st.selectbox("Item", options=[i.name for i in mdfs.items]) + + metrics = st.multiselect( + "Metrics", + ["bias", "rmse", "mae", "cc", "r2", "si", "kge", "mape", "urmse"], + default=["bias", "rmse", "r2"], + ) + +if mod and obs: + c = modelskill.match( + fn_obs, fn_mod, obs_item=obs_item, mod_item=mod_item, gtype="point" + ) + + tskill, tts, tsc = st.tabs(["Skill", "Time series", "Scatter"]) + + with tskill: + df = c.skill(metrics=metrics).to_dataframe() + st.dataframe(df) + + with tts: + c.plot.timeseries() + st.pyplot(plt.gcf()) + + with tsc: + c.plot.scatter() + st.pyplot(plt.gcf()) diff --git a/web/screenshot.png b/web/screenshot.png new file mode 100644 index 000000000..171efcdfd Binary files /dev/null and b/web/screenshot.png differ