This is a Flask application served as an API for https://github.com/SCCWRP/bmp-hydrology-calculator.
This API provides endpoints for hydrological calculations related to Best Management Practices (BMPs), including rainfall event analysis, flow statistics, and infiltration modeling. It is designed to be used as a backend for the BMP Hydrology Calculator web application.
- Rainfall Event Analysis: Detects rainfall events, calculates total rainfall, rainfall intensity, and antecedent dry periods.
- Flow Analysis: Computes runoff volume, duration, peak flow rates, and percent change between inflow and outflow.
- Rain-Flow Event Linking: Associates rainfall events with corresponding flow events for event-based analysis.
- Infiltration Modeling: Fits exponential decay models to piezometer data to estimate infiltration rates.
Returns the main index page.
Returns the Swagger UI documentation page.
Accepts rainfall data and returns statistics for detected rainfall events.
Request Body Example:
{
"rain": {
"datetime": [...],
"rain": [...]
}
}Accepts flow data (inflow, outflow, bypass, etc.) and returns flow statistics.
Request Body Example:
{
"inflow1": {
"datetime": [...],
"flow": [...],
"time_unit": "L/s"
},
"outflow": {
"datetime": [...],
"flow": [...],
"time_unit": "L/s"
}
}Accepts both rain and flow data, links rain events to flow events, and returns combined statistics.
Accepts piezometer depth data and parameters for smoothing and regression, fits exponential decay models, and returns infiltration rates and fit statistics.
Request Body Example:
{
"data": [
{"datetime": "...", "PZ1": ..., "PZ2": ...},
...
],
"SMOOTHING_WINDOW": 5,
"REGRESSION_WINDOW": 720,
"REGRESSION_THRESHOLD": 0.999
}- Install dependencies (see
requirements.txt). - Set the
FLASK_APP_SECRET_KEYenvironment variable. - Run the Flask app (e.g.,
flask runor via WSGI). - Use the
/api/docsendpoint for interactive API documentation.
proj/app.py: Main Flask application and API endpoints.proj/functions/: Core hydrology calculation modules.proj/utils/: Utility functions for data formatting and validation.proj/templates/: HTML templates for index and Swagger UI.proj/static/: Static files (JS, CSS, OpenAPI YAML).
See LICENSE in the main project repository.