Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

hbv-lab

Latest version: v1.5.0

Overview

Last scanned
24 Nov 2026
Published
24 Nov 2026
PyPI package Publisher: abdalla_mohammed
2 Stars
0 Forks
1 Versions
142 Downloads
Jupyter Notebook Repo language

Scan summary

hbv-lab was last scanned on 24 Nov 2026 at version 1.5.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: First and only release on 24 Nov 2026.
  • Findings: No rules fired in version 1.5.0.
  • Downloads: 142 downloads.

Versions

1 version published
Versions and the rules that fired in each
VersionPublishedStatus
1.5.0 LATEST 24 Nov 2026 No rules fired

No rules fired in 1.5.0

Findings

Findings for v1.5.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.5.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

HBV_Lab — an agentic HBV hydrological model with an MCP server

An intuitive, object-oriented Python implementation of a lumped conceptual HBV rainfall–runoff model — with built-in calibration and uncertainty analysis, and a Model Context Protocol (MCP) server that lets AI agents drive the whole workflow.

PyPI version Python versions License: MIT

HBV is a widely used conceptual hydrological model that simulates the main processes governing the transformation of precipitation into streamflow — snow accumulation and melt, soil moisture accounting, groundwater storage, and channel routing [1]. It has been implemented in many software packages and operational products [2] [3].

HBV_Lab is a clean, transparent reimplementation in Python designed to be easy to read, easy to use, and easy to teach with. Every routine is exposed as a small, well-documented function, and the full model is wrapped in a single HBVModel object that handles data loading, simulation, calibration, uncertainty analysis, plotting, and persistence. It is well suited to research prototyping, method development, and hydrology education.

It is also agent-ready: a built-in MCP server exposes the model as tools, so an AI agent (Claude Code, Claude Desktop, or any MCP client) can build, calibrate, validate and run uncertainty analysis on HBV models through natural language — see Use it as an MCP server.

Scope at a glance: lumped (single-cell, spatially averaged) · conceptual · daily time step · requires precipitation, temperature and potential evapotranspiration as input · 14 calibratable parameters. Please read Scope, Assumptions & Limitations before using results in any decision-making context.


Features

  • Agent-ready MCP server — drive the full create → load → calibrate → validate → uncertainty workflow from an AI agent over stdio or HTTP, with live calibration progress and structured results.
  • Complete HBV structure — snow, soil, groundwater response (two reservoirs, three runoff components) and MAXBAS triangular routing.
  • Object-oriented API — one HBVModel object holds data, parameters, states and results.
  • Automatic calibration — single-objective optimisation (NSE, KGE, RMSE or MAE) via SciPy, using a gradient-free optimiser by default (see note on calibration).
  • Uncertainty analysis — Monte-Carlo sampling of the parameter space with prediction-interval estimation (GLUE-style).
  • Performance metrics — NSE, KGE′, percent bias (PBIAS), RMSE, MAE and correlation, with a configurable warm-up period excluded from evaluation.
  • Flexible data loading — CSV or Excel, flexible date parsing, optional expansion of 12 monthly mean PET values to a daily series.
  • Rich plotting and save/load of both results (CSV) and the full model (pickle).
  • Interactive playground for exploring how each parameter shapes the hydrograph.

Model structure & parameters

The 14 parameters belong, conceptually, to four routines:

parameters = {
    'snow':     ['TT', 'CFMAX', 'SFCF', 'CFR', 'CWH'],
    'soil':     ['FC', 'LP', 'BETA'],
    'response': ['K0', 'K1', 'K2', 'UZL', 'PERC'],
    'routing':  ['MAXBAS'],
}

In the model object the parameters are stored in three groups — snow, soil and response — with the routing parameter MAXBAS held inside the response group. Each parameter is a dictionary with min / max / default values (the ranges are used by calibration and uncertainty analysis).

Default ranges and starting values:

Routine Parameter Unit Min Max Default
Snow TT °C -2 2 0
CFMAX mm °C⁻¹ d⁻¹ 1 6 3.5
SFCF - 0.5 1.5 1
CFR - 0 0.2 0.05
CWH - 0 0.2 0.1
Soil FC mm 50 500 150
LP - 0.3 1 0.7
BETA - 1 5 2
Response K0 d⁻¹ 0.1 0.9 0.5
K1 d⁻¹ 0.05 0.5 0.2
K2 d⁻¹ 0.0005 0.1 0.05
UZL mm 5 50 20
PERC mm d⁻¹ 0.5 10 1.5
Routing MAXBAS d 1 10 3

Since v1.5.0, FC, PERC and K2 use the wider ranges of Seibert (1997). The earlier ranges (FC up to 300 mm, PERC up to 3 mm d⁻¹, K2 from 0.01 d⁻¹) held calibrations of dry and chalk catchments at their limits. Any range can be changed per model:

model.set_parameters({
    'soil':     {'FC': {'min': 50, 'max': 700, 'default': 250}},
    'response': {'MAXBAS': {'default': 4}},
})

A diagram of a single model time step is available here.

Installation

From PyPI:

pip install HBV_Lab

Inside a notebook:

!pip install HBV_Lab

From source (latest development version):

git clone https://github.com/abdallaox/HBV_python_implementation.git
cd HBV_python_implementation
pip install -e .

Requires Python ≥ 3.7. Core dependencies (numpy, pandas, scipy, matplotlib, tqdm, openpyxl) are installed automatically. The interactive playground additionally needs Bokeh (pip install "HBV_Lab[playground]").

Quick start

import pandas as pd
from HBV_Lab import HBVModel

# 1. Load forcing data: a DataFrame with date, precipitation, temperature,
#    potential ET and — optionally — observed discharge columns.
df = pd.read_excel("data/test_data_2.xlsx")
model = HBVModel()
model.load_data(
    data=df,
    date_column="Date", precip_column="P", temp_column="T",
    pet_column="PET", obs_q_column="Q",
    date_format="%Y%m%d", warmup_end="19811231",
)

# 2. (Optional) override default parameter ranges / values
# model.set_parameters({'soil': {'FC': {'default': 250}}})

# 3. Run, calibrate and analyse
model.run()
model.calibrate()              # gradient-free optimisation by default
model.evaluate_uncertainty()   # Monte-Carlo uncertainty analysis
model.plot_results()

# 4. Persist results and the model itself
model.save_results("results/run.csv")
model.save_model("models/my_model")
model = HBVModel.load_model("models/my_model")

The example dataset (data/test_data_2.xlsx) ships with the source repository, not with the PyPI package. Clone the repo, or point load_data at your own data.

Tutorial

A complete, annotated case study — build a model, calibrate it on one period, validate it on another, and quantify parameter uncertainty — is provided in the notebook quick_start_guide.ipynb.

Play with HBV

Build intuition for how each parameter shapes the hydrograph in the interactive HBVLAB playground, which runs a model built with this library.

Use it as an MCP server (for AI agents)

HBV_Lab ships an MCP server so any AI agent can build, run, calibrate and analyse HBV models through tool calls. It runs in two modes:

  • stdio (default) — the agent launches the server as a local subprocess. Best for desktop agents.
  • HTTP (--http) — the server runs as a standalone service at http://<host>:<port>/mcp that any number of remote agents can connect to.

Install once:

pip install "HBV_Lab[mcp]"

Upgrading: stop/close the MCP client (and any running hbv-mcp process) before upgrading — a running server holds hbv-mcp.exe open on Windows, so an in-place pip install -U can fail with a file-lock error. After upgrading, fully restart the client (or remove and re-add the server) so it re-discovers the tool list; clients fetch tools only once per connection, so upgrading mid-session leaves them showing the old tools.

Option A — local (stdio)

No need to start anything yourself; the agent runs hbv-mcp for you. Just add it to your client's MCP config.

Claude Desktop — edit claude_desktop_config.json (Settings → Developer → Edit Config):

{
  "mcpServers": {
    "hbv-lab": { "command": "hbv-mcp" }
  }
}

Claude Code — one command:

claude mcp add hbv-lab hbv-mcp

Any other MCP client — point it at the command hbv-mcp (transport: stdio).

Option B — shared HTTP server (any agent, local or remote)

Start the server once:

hbv-mcp --http                       # http://127.0.0.1:8000/mcp  (this machine only)
hbv-mcp --http --host 0.0.0.0 --port 9000   # expose on the network

Then connect your agent to the URL:

# Claude Code
claude mcp add --transport http hbv-lab http://127.0.0.1:8000/mcp
// Claude Desktop / generic client config
{
  "mcpServers": {
    "hbv-lab": { "type": "http", "url": "http://127.0.0.1:8000/mcp" }
  }
}

Host/port also read the PORT / HBV_MCP_HOST / HBV_MCP_PORT environment variables, so the HTTP mode deploys cleanly to platforms like Railway, Render or Fly.

What the agent can do

Tools: create_model, clone_model, copy_parameters, load_data (from a CSV/Excel file path), get_parameters, set_parameters, get_parameter_ranges, set_parameter_ranges, set_initial_conditions, run_model, calibrate, evaluate_uncertainty, get_metrics, compare_models, plot_results, save_results, save_model, load_model, list_models. A typical agent flow is create → load → run → calibrate → plot. Model state is kept server-side (each tool takes a model_id) and large time series are passed by file path, not through the agent's context — tools return compact metrics and output-file paths.

Calibration progress & agent steering. calibrate emits MCP progress notifications every optimizer iteration (clients that surface them show a live progress/log view), and its result reports an honest convergence status (converged / hit_iteration_budget / failed), still_improving, the best-objective-per-iteration objective_trajectory, and an at_bound list of parameters pinned to their range limits. Because each call continues from the model's current parameters, an agent can calibrate incrementally — call calibrate with a small iterations budget, inspect the improving metric, and decide whether to keep going, widen ranges (via set_parameter_ranges), or switch objective between rounds.

Split-sample made easy. Calibrate one model, clone_model it (or copy_parameters to a second model), load_data the validation window on the clone, and run_model — the calibrated parameters carry over with no manual transfer. compare_models tabulates calibration vs. validation metrics.

Transparent data loading. load_data reports pet_handling (e.g. expanded_from_12_monthly_means when PET is supplied as 12 monthly means — the HBV-light convention — and auto-expanded to daily) and a per-column data_quality summary (valid/missing counts, min/max), so an agent can sanity-check the forcing without opening the file.

Richer uncertainty. evaluate_uncertainty returns the 95% prediction-band coverage (fraction of observations inside the band), mean band width, and per-parameter posterior quantiles (p5/p25/p50/p75/p95). Pass output_file to write the full per-timestep prediction band (Date, Observed, Calibrated, BestRun, Q5, Q95) to CSV, ready to plot. (Sampling is uniform over the parameter ranges — parameter, not predictive, uncertainty.)

Inputs & outputs

Inputs (daily, consistent units): precipitation (mm), air temperature (°C) and potential evapotranspiration (mm). PET may be supplied as a full daily series or as 12 monthly means, which are expanded automatically. Observed discharge (mm) is optional but required for calibration, uncertainty analysis and performance metrics. All water fluxes and storages are expressed in millimetres of water depth over the catchment (mm).

Outputs: simulated discharge and its quick / intermediate / base-flow components, plus the full internal state and flux time series (snow pack, liquid water, soil moisture, recharge, actual ET, upper/lower storage). When observed discharge is available, performance metrics (NSE, KGE′, PBIAS, RMSE, MAE, correlation) are computed over the post-warm-up period.

A note on calibration

Because the model contains many threshold operations, its objective surface is piecewise-constant. Gradient-based optimisers (e.g. SLSQP, L-BFGS-B) see near-zero numerical gradients and tend to stop at the starting point without improving the fit, so calibration uses a gradient-free method (Nelder-Mead) by default. Nelder-Mead is a single-objective, local search. For a global search, use Dynamically Dimensioned Search (Tolson and Shoemaker, 2007), which was designed for hydrological model calibration. With DDS, iterations is the number of model runs, and seed makes the run repeatable:

model.calibrate(method='DDS', objective='NSE', iterations=2000, seed=0)

For a broader picture of the parameter space, run evaluate_uncertainty() (Monte-Carlo).

Scope, Assumptions & Limitations

HBV_Lab is intended for education and research. To use it with confidence, please be aware of the following:

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases hbv-lab

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

Frame 2085668439 (1)
Group 1261154229