Skip to content

Commit

Permalink
Initial translation of app interface
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSample committed Jun 18, 2024
1 parent e29c942 commit 1b346d6
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 75 deletions.
2 changes: 1 addition & 1 deletion docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ language: norsk.yml

Denne nettsiden inneholder dokumentasjon for [innsjøkalkingsapplikasjonen](https://lake-liming.t.niva.no/). Modellen simulerer typiske/idealiserte endringer i innsjøers vannkjemi (kalsiumkonsentrasjon og pH) for ulike kalkingsstrategier.

* For en beskrivelse av hvordan du bruker applikasjonen, se [Brukerveiledningen](https://nivanorge.github.io/lake_liming_app/user-guide.html).
* For en beskrivelse av hvordan du bruker applikasjonen, se [Brukerhåndboken](https://nivanorge.github.io/lake_liming_app/user-guide.html).

* For å forstå hvordan modellen fungerer, se [Innsjømodellering](https://nivanorge.github.io/lake_liming_app/lake-modelling.html).

Expand Down
6 changes: 3 additions & 3 deletions src/lake_modelling/utils/run_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def plot_multiple_products(df, pH_lake0, pH_inflow, lib):
g.axes[1, 0].axhline(y=pH_lake0, ls="--", c="k")
g.axes[1, 0].axhline(y=pH_inflow, ls="--", c="k")
g.axes[0, 0].set_ylabel("$\Ca_{ekv}$ (mg/l)")
g.axes[1, 0].set_ylabel("Lake pH (-)")
g.axes[1, 0].set_ylabel("Innsjø pH (-)")
g.axes[1, 0].set_xlabel("")
g.axes[0, 0].set_title("")
g.axes[1, 0].set_title("")
Expand All @@ -118,10 +118,10 @@ def plot_multiple_products(df, pH_lake0, pH_inflow, lib):
alt.Chart(df)
.mark_line()
.encode(
x=alt.X("date", axis=alt.Axis(title="Months", grid=True)),
x=alt.X("date", axis=alt.Axis(title="Måneder", grid=True)),
y=alt.Y(
"pH",
axis=alt.Axis(title="Lake pH (-)"),
axis=alt.Axis(title="Innsjø pH (-)"),
scale=alt.Scale(zero=False),
),
color="product",
Expand Down
79 changes: 52 additions & 27 deletions src/lake_modelling/utils/user_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,97 @@


def get_lake_params():
st.markdown("### Lake characteristics")
with st.expander("Help"):
st.markdown("### Innsjøegenskaper")
# with st.expander("Help"):
# st.markdown(
# """Enter the characteristics for your lake of interest using the input boxes below.
# Estimates for mean monthly and annual discharge will be shown in the plot."""
# )
with st.expander("Hjelp"):
st.markdown(
"""Enter the characteristics for your lake of interest using the input boxes below.
Estimates for mean monthly and annual discharge will be shown in the plot."""
"""Skriv inn egenskapene for din interessante innsjø ved å bruke inntastingsboksene
nedenfor. Estimert gjennomsnittlig månedlig og årlig utslipp vil bli vist i plottet."""
)
col1, col2 = st.columns(2)
area = col1.number_input("Surface area (km²)", min_value=0.01, value=0.2)
depth = col1.number_input("Mean depth (m)", min_value=0.01, value=5.0)
area = col1.number_input("Overflateareal (km²)", min_value=0.01, value=0.2)
depth = col1.number_input("Middeldybde (m)", min_value=0.01, value=5.0)
tau = col1.number_input(
"Water residence time (years)",
"Vannoppholdstid (years)",
min_value=0.1,
value=0.7,
step=0.1,
format="%.1f",
)
flow_prof = (
col1.selectbox("Flow profile", ("None", "Fjell", "Kyst"), index=1)
col1.selectbox("Vannføringsprofil", ("Ingen", "Fjell", "Kyst"), index=1)
).lower()
pH_lake0 = col2.number_input("Initial pH", min_value=4.5, max_value=6.5, value=5.0)
pH_inflow = col2.number_input("Inflow pH", min_value=4.5, max_value=6.5, value=5.0)
toc_lake0 = col2.number_input("TOC concentration (mg/l)", min_value=0.0, value=4.0)
if flow_prof == "ingen":
flow_prof = "none"
pH_lake0 = col2.number_input("Start pH", min_value=4.5, max_value=6.5, value=5.0)
pH_inflow = col2.number_input("Innløps pH", min_value=4.5, max_value=6.5, value=5.0)
toc_lake0 = col2.number_input("TOC konsentrasjon (mg/l)", min_value=0.0, value=4.0)
lake_params = (area, depth, tau, flow_prof, pH_lake0, pH_inflow, toc_lake0)

return lake_params


def get_product(products):
st.markdown("## Liming products")
with st.expander("Help"):
st.markdown("## Kalkprodukter")
# with st.expander("Help"):
# st.markdown(
# """Choose a liming product from the list below to view column test results (instantaneous
# dissolution and overdosing factors) from the database."""
# )
with st.expander("Hjelp"):
st.markdown(
"""Choose a liming product from the list below to view column test results (instantaneous
dissolution and overdosing factors) from the database."""
"""Velg et kalkprodukt fra listen nedenfor for å se kolonnetestresultater
(momentanoppløsning og overdoseringsfaktorer) fra databasen."""
)
prod_name = st.selectbox("Choose liming product", (products))
prod_name = st.selectbox("Velg kalkprodukt", (products))

return prod_name


def get_model_params():
st.markdown("### Liming parameters")
with st.expander("Help"):
st.markdown("### Kalkingsparametere")
# with st.expander("Help"):
# st.markdown(
# """
# Use the input boxes below to define the **liming procedure**.

# For each product in the database, the model will simulate changes in Ca
# (equivalent) concentration and pH for the specified lake using this procedure.
# """
# )
with st.expander("Hjelp"):
st.markdown(
"""
Use the input boxes below to define the **liming procedure**.
For each product in the database, the model will simulate changes in Ca
(equivalent) concentration and pH for the specified lake using this procedure.
Bruk inndataboksene nedenfor for å definere **kalkingsprosedyren**.
For hvert produkt i databasen vil modellen simulere endringer i Ca (ekvivalent)
konsentrasjon og pH for den angitte innsjøen ved hjelp av denne prosedyren.
"""
)
col1, col2 = st.columns(2)

lime_dose = col1.number_input(
"Lime dose (mg/l of product)", min_value=0.1, max_value=85.0, value=10.0
"Kalkdose (mg/l produkt)", min_value=0.1, max_value=85.0, value=10.0
)
spr_prop = col1.number_input(
"Proportion of lake surface area limed (-)",
"Andel av innsjøoverflate kalket (-)",
min_value=0.0,
max_value=1.0,
value=0.5,
)
spr_meth = col1.selectbox("Application method", ("Wet", "Dry"), index=0).lower()
spr_meth = col1.selectbox("Kalkingsmetode", ("Våt", "Tørr"), index=0).lower()
if spr_meth == "våt":
spr_meth = "wet"
else:
spr_meth = "dry"
lime_month = col2.number_input(
"Application month", min_value=1, max_value=12, value=7
"Kalkingsmåned", min_value=1, max_value=12, value=7
)
n_months = col2.number_input("Number of months to simulate", min_value=1, value=12)
n_months = col2.number_input("Antall måneder å simulere", min_value=1, value=12)
# F_sol = col1.number_input(
# "Proportion of lake-bottom lime that remains soluble (-)",
# min_value=0.0,
Expand Down
48 changes: 31 additions & 17 deletions subpages/column_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,42 @@
def app():
"""Main function for the 'column_test' page."""

st.markdown("## Column tests")
# st.markdown("## Column tests")
# st.info(
# """You can explore column test results for lime products that are **already
# in the database** from the `Innsjømodellering` tab.""",
# icon="ℹ️",
# )
# with st.expander("Help"):
# st.markdown(
# """Use this page to upload **new** column test data from an Excel template.
# First download a blank copy of the template
# [here](https://github.com/NIVANorge/lake_liming_app/raw/main/data/liming_app_data_template_v1-1.xlsx).
# Then fill-in your column test results and upload the completed template
# using the button in the left sidebar."""
# )
st.markdown("## Kolonnetester")
st.info(
"""You can explore column test results for lime products that are **already
in the database** from the `Innsjømodellering` tab.""",
"""Du kan utforske kolonnetestresultater for kalkprodukter som er **allerede i
databasen** fra fanen `Innsjømodellering`.""",
icon="ℹ️",
)
with st.expander("Help"):
with st.expander("Hjelp"):
st.markdown(
"""Use this page to upload **new** column test data from an Excel template.
First download a blank copy of the template
[here](https://github.com/NIVANorge/lake_liming_app/raw/main/data/liming_app_data_template_v1-1.xlsx).
Then fill-in your column test results and upload the completed template
using the button in the left sidebar."""
"""Bruk denne siden til å laste opp **nye** kolonnetestdata fra en Excel-mal.
Last først ned en tom kopi av malen
[her](https://github.com/NIVANorge/lake_liming_app/raw/main/data/liming_app_data_template_v1-1.xlsx).
Fyll deretter ut kolonnetestresultatene og last opp den ferdige malen ved å
bruke knappen i venstre sidefelt."""
)
data_file = st.sidebar.file_uploader("Upload template")
data_file = st.sidebar.file_uploader("Last opp mal")
if data_file:
st.session_state["data_file"] = data_file

if "data_file" in st.session_state:
data_file = st.session_state["data_file"]
with st.spinner("Reading data..."):
st.markdown(f"**File name:** `{data_file.name}`")
with st.spinner("Leser data..."):
st.markdown(f"**Filnavn:** `{data_file.name}`")
read_template(data_file)

par_df = st.session_state["par_df"]
Expand All @@ -38,10 +52,10 @@ def app():
par_val_dict = par_df.to_dict()["Value"]
st.markdown(
f"""
### Processing data for product: `{par_val_dict['lime_product_name']}`
**Total Ca content by mass:** {par_val_dict['lime_prod_ca_pct']} %
### Behandler data for produkt: `{par_val_dict['lime_product_name']}`
**Totalt Ca-innhold etter masse:** {par_val_dict['lime_prod_ca_pct']} %
**Total Mg content by mass:** {par_val_dict['lime_prod_mg_pct']} %
**Totalt Mg-innhold etter masse:** {par_val_dict['lime_prod_mg_pct']} %
"""
)

Expand All @@ -51,7 +65,7 @@ def subheader(str):
unsafe_allow_html=True,
)

subheader("Calcium results")
subheader("Kalsium resultater")
left_col, right_col = st.columns(2)
# Instantaneous test
with left_col:
Expand All @@ -74,7 +88,7 @@ def subheader(str):

# Display Mg results if data present
if inst_df["Mg_mg/l"].sum() != 0:
subheader("Magnesium results")
subheader("Magnesium resultater")
left_col, right_col = st.columns(2)
with left_col:
# Instantaneous test
Expand Down
56 changes: 40 additions & 16 deletions subpages/comparison_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,53 @@ def app():
"""Main function for the 'comparison_factors' page."""

st.markdown("## Omregningsfaktorer")
# st.markdown(
# """
# These plots show the simulated effectiveness of different lime products compared
# to a reference standard for lakes with various mean depths and water residence
# times. **Values less than one indicate the product is more effective than the
# standard; values greater than one imply it is less effective (per unit mass)**.

# The reference used for these plots is `Standard Kalk Kat3`.

# See the
# [Documentation](https://nivanorge.github.io/lake_liming_app/user-guide.html#sec-comparison-factors)
# for details.
# """
# )
st.markdown(
"""
These plots show the simulated effectiveness of different lime products compared
to a reference standard for lakes with various mean depths and water residence
times. **Values less than one indicate the product is more effective than the
standard; values greater than one imply it is less effective (per unit mass)**.
Disse plottene viser den simulerte effektiviteten til ulike kalkprodukter sammenlignet
med en referansestandard for innsjøer med ulike middeldybder og vannoppholdstider.
**Verdier mindre enn én indikerer at produktet er mer effektivt enn standarden; verdier
større enn én betyr at den er mindre effektiv (per kilogram)**.
The reference used for these plots is `Standard Kalk Kat3`.
See the
[Documentation](https://nivanorge.github.io/lake_liming_app/user-guide.html#sec-comparison-factors)
for details.
Referansen som brukes for disse plottene er `Standard Kalk Kat3`.
Se [Dokumentasjon](https://nivanorge.github.io/lake_liming_app/user-guide.html#sec-comparison-factors)
for detaljer.
"""
)
with st.expander("Help"):
# with st.expander("Help"):
# st.markdown(
# """
# The plots are interactive:
# * Click on the series names in the legend to turn curves on/off.
# * Use `SHIFT + Click` to select multiple curves.
# * Use your mouse wheel to zoom in/out.
# * Double-click to return to the full extent.
# * Hover on any line to see details as "tooltips".
# """
# )
with st.expander("Hjelp"):
st.markdown(
"""
The plots are interactive:
* Click on the series names in the legend to turn curves on/off.
* Use `SHIFT + Click` to select multiple curves.
* Use your mouse wheel to zoom in/out.
* Double-click to return to the full extent.
* Hover on any line to see details as "tooltips".
Plottene er interaktive:
* Klikk på serienavnene i forklaringen for å slå kurver på/av.
* Bruk `SHIFT + Klikk` for å velge flere kurver.
* Bruk musehjulet til å zoome inn/ut.
* Dobbeltklikk for å gå tilbake til hele omfanget.
* Hold musepekeren på en linje for å se detaljer som "verktøytips".
"""
)
chart = plot_factors()
Expand Down
35 changes: 24 additions & 11 deletions subpages/lake_modelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,37 @@ def app():
prod = LimeProduct(name)
prod.plot_column_data(plot_lib)

st.markdown("## Lake modelling")
st.markdown("## Innsjømodellering")
area, depth, tau, flow_prof, pH_lake0, pH_inflow, toc_lake0 = get_lake_params()
lake = Lake(area, depth, tau, flow_prof, pH_lake0, pH_inflow, toc_lake0)
lake.plot_flow_profile(plot_lib)

res_df = run_multiple_products(lake, products)
st.markdown("### Model results")
with st.expander("Help"):
st.markdown("### Modell resultater")
# with st.expander("Help"):
# st.markdown(
# """
# The plots are interactive:
# * Click on the series names in the legend to turn curves on/off.
# * Use `SHIFT + Click` to select multiple curves.
# * Use your mouse wheel to zoom in/out.
# * Double-click to return to the full extent.
# * Hover on any line to see details as "tooltips".

# Dashed horizontal lines on the pH plot mark the lake's initial and inflow pH.
# """
# )
with st.expander("Hjelp"):
st.markdown(
"""
The plots are interactive:
* Click on the series names in the legend to turn curves on/off.
* Use `SHIFT + Click` to select multiple curves.
* Use your mouse wheel to zoom in/out.
* Double-click to return to the full extent.
* Hover on any line to see details as "tooltips".
Dashed horizontal lines on the pH plot mark the lake's initial and inflow pH.
Plottene er interaktive:
* Klikk på serienavnene i forklaringen for å slå kurver på/av.
* Bruk `SHIFT + Klikk` for å velge flere kurver.
* Bruk musehjulet til å zoome inn/ut.
* Dobbeltklikk for å gå tilbake til hele omfanget.
* Hold musepekeren på en linje for å se detaljer som "verktøytips".
Stiplede horisontale linjer på pH-plottet markerer innsjøens start- og innløps-pH.
"""
)
plot_multiple_products(res_df, pH_lake0, pH_inflow, plot_lib)
Expand Down

0 comments on commit 1b346d6

Please sign in to comment.