A Streamlit web app that helps water agencies and landowners evaluate the economic value of implementing a Recharge Net Metering (ReNeM) program. By entering district-specific parameters, users get a Net Present Value (NPV) estimate for both the sponsoring agency and participating rechargers, along with a sensitivity analysis showing how the result responds to each input.
The math is a direct port of the original Jupyter notebooks
(ReNeM CBA Notebook_4.18.23.ipynb, ReNeM Sensitivity Notebook_7.11.23.ipynb,
ReNeM basin projects_4.18.23.ipynb) which are kept in the repository for
reference. The app wraps that math in an interactive UI so a non-technical
user can explore scenarios without editing Python code.
Streamlit is a Python framework for building data apps
without writing any HTML, CSS, or JavaScript. You write a regular Python
script that reads inputs (st.number_input, st.slider, …) and renders
outputs (st.markdown, st.plotly_chart, …); Streamlit handles the web
server, layout, and re-rendering on input changes.
This app is a multipage Streamlit app:
- The entry-point script (
1_01_About.py) is the landing page. - Any script inside the
pages/folder becomes an additional page that appears automatically in Streamlit's left-nav sidebar.
ReNeM_Calculator/
├── 1_01_About.py # Landing page (entry point)
├── pages/
│ ├── 1_02_Documentation.py # Variable reference tables (deep-linkable)
│ └── 2_03_Calculator.py # Input form, NPV math, results, sensitivity
├── images/ # Photos used on the About page
├── requirements.txt # Python dependencies
├── ReNeM CBA Notebook_4.18.23.ipynb # Source notebook (reference)
├── ReNeM Sensitivity Notebook_7.11.23.ipynb # Source notebook (reference)
├── ReNeM basin projects_4.18.23.ipynb # Source notebook (reference)
└── README.md
The three notebooks are the historical research basis for the app's formulas and are kept in the repo for reference. They are not executed by the deployed app.
The Streamlit app's NPV math matches ReNeM CBA Notebook_4.18.23.ipynb
verbatim with one deliberate exception: the app scales three project-level
fixed costs by the number of projects (o); the CBA notebook does not.
The costs that differ:
| Variable | Meaning | Notebook treatment | App treatment |
|---|---|---|---|
F |
One-time design and construction cost | flat | F · o |
tpc_fc |
One-time third-party certification setup cost | flat | tpc_fc · o |
tpc_ac |
Annual third-party certification cost | flat | tpc_ac · o |
These show up on the agency / basin side of the NPV. Because the app multiplies
them by o, programs with more than one project will report a lower Basin
NPV in the app than the CBA notebook would for the same inputs (the gap
grows with o). The Recharger NPV is unaffected — recharger-side costs are
already per-project in both the notebook and the app.
The change is applied consistently across:
get_npvs_with_stochasticity()— the function that produces the displayed Total / Basin / Recharger NPVsnpvs()— the sensitivity-analysis function- The Agency Unit Cost per Acre-Foot card on the Calculator results page
To reproduce the notebook's numbers exactly, set o = 1 in the calculator.
Prerequisites: Python 3.10 or newer. Check with python --version.
-
Clone the repository:
git clone https://github.com/micahhsu/ReNeM_CBA.git cd ReNeM_CBA -
(Recommended) create and activate a virtual environment so the app's dependencies don't conflict with anything else on your machine:
# Windows (PowerShell) python -m venv .venv .venv\Scripts\Activate.ps1
# macOS / Linux python -m venv .venv source .venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
Run the app:
streamlit run 1_01_About.py
Streamlit will open the app in your default browser at
http://localhost:8501. Edits to any of the page files are picked up live — save the file and click "Rerun" (or enable "Always rerun") in the upper-right of the app.
To stop the app, return to the terminal and press Ctrl+C.
Streamlit Community Cloud is a free hosting service for Streamlit apps backed by a GitHub repository. This is what I have been using to temporarily deploy the website.
-
Push the repository to GitHub. If it is not already on GitHub, create a new repo and push.
-
Sign in at https://share.streamlit.io with the same GitHub account that owns the repository.
-
Click "New app" and fill in:
- Repository: your GitHub repo (e.g.
micahhsu/ReNeM_CBA) - Branch: usually
main - Main file path:
1_01_About.py
- Repository: your GitHub repo (e.g.
-
Click "Deploy". Streamlit Cloud will read
requirements.txtautomatically and install dependencies. The first build typically takes 2–4 minutes. -
Once deployed, the app is live at a
*.streamlit.appURL. Pushing new commits to the configured branch redeploys automatically.
To update the deployment manually (e.g. after editing on Streamlit Cloud's side) or to check logs, use the "Manage app" menu in the lower-right of the live app.
- Add a variable input: edit the appropriate sidebar tab (
tab1for Program variables,tab2for Project variables) inpages/2_03_Calculator.py. Follow the existingst.container(horizontal=True)_help_popover(…)pattern to keep the 📖 help button aligned.
- Add a variable definition: add a row tuple to either
program_rowsorproject_rowsinpages/1_02_Documentation.py. The first element of the tuple (thevar_key) becomes the deep-link target — calling_help_popover("myvar", …)in the Calculator links to?var=myvarhere. - Change a formula: all NPV math lives in the four functions near the top
of
pages/2_03_Calculator.py(npv,npv_list,get_npv_Qlist,get_npvs_with_stochasticity) and the sensitivity-analysis function (npvs). These mirror the equivalent cells in the source notebooks.