Context
PR review of #149 found that `HBV.simulate()` accepts a `snow`
parameter documented as controlling whether the snow subroutine runs,
but the actual simulation loop hardcodes `snow=0` when calling
`step_run()`.
Problem / Current Behaviour
```python
src/Hapi/rrm/hbv.py line ~759
The snow parameter is only used for initial discharge calculation
(lines 746-751), NOT for the actual simulation loop:
st[i + 1, :], q_uz[i + 1], q_lz[i + 1] = self.step_run(
par, v, st[i], snow=0 # <-- hardcoded, ignores the snow parameter
)
```
This means snow accumulation, melt, and refreezing are never
simulated in the time-stepping loop, regardless of the `snow`
parameter value.
Affected locations
| File |
Symbol |
Notes |
| `src/Hapi/rrm/hbv.py:~759` |
`HBV.simulate` |
Hardcoded `snow=0` |
Steps to Reproduce
```python
from Hapi.rrm.hbv import HBV
import numpy as np
model = HBV()
n = 100
prec = np.random.uniform(0, 20, n)
temp = np.random.uniform(-5, 10, n) # cold temps that should trigger snow
et = np.random.uniform(0, 3, n)
par_snow = [0, 1, 1, 3, 0.1, 0.05, 200, 2, 1, 0.9, 0.005, 0.03,
0.015, 10, 1, 0.5, 0.1]
snow=1 should enable snow processes, but they never run
q_uz, q_lz, st = model.simulate(prec, temp, et, par_snow, snow=1)
st[:, 0] (snow pack) and st[:, 4] (water content) are always 0
```
Proposed Solution
Pass the `snow` parameter through to `step_run`:
```python
st[i + 1, :], q_uz[i + 1], q_lz[i + 1] = self.step_run(
par, v, st[i], snow=snow # pass through
)
```
Alternative: If `snow=0` is intentional (snow only affects initial
conditions), update the docstring to clearly state this limitation.
Out of Scope
- Refactoring the snow subroutine itself
- Adding snow support to HBVBergestrom92
Effort Estimate
Size: `XS`
Rationale: One-line fix if the parameter should be passed through,
or a docstring update if the behaviour is intentional.
Definition of Done
Context
PR review of #149 found that `HBV.simulate()` accepts a `snow`
parameter documented as controlling whether the snow subroutine runs,
but the actual simulation loop hardcodes `snow=0` when calling
`step_run()`.
Problem / Current Behaviour
```python
src/Hapi/rrm/hbv.py line ~759
The snow parameter is only used for initial discharge calculation
(lines 746-751), NOT for the actual simulation loop:
st[i + 1, :], q_uz[i + 1], q_lz[i + 1] = self.step_run(
par, v, st[i], snow=0 # <-- hardcoded, ignores the snow parameter
)
```
This means snow accumulation, melt, and refreezing are never
simulated in the time-stepping loop, regardless of the `snow`
parameter value.
Affected locations
Steps to Reproduce
```python
from Hapi.rrm.hbv import HBV
import numpy as np
model = HBV()
n = 100
prec = np.random.uniform(0, 20, n)
temp = np.random.uniform(-5, 10, n) # cold temps that should trigger snow
et = np.random.uniform(0, 3, n)
par_snow = [0, 1, 1, 3, 0.1, 0.05, 200, 2, 1, 0.9, 0.005, 0.03,
0.015, 10, 1, 0.5, 0.1]
snow=1 should enable snow processes, but they never run
q_uz, q_lz, st = model.simulate(prec, temp, et, par_snow, snow=1)
st[:, 0] (snow pack) and st[:, 4] (water content) are always 0
```
Proposed Solution
Pass the `snow` parameter through to `step_run`:
```python
st[i + 1, :], q_uz[i + 1], q_lz[i + 1] = self.step_run(
par, v, st[i], snow=snow # pass through
)
```
Alternative: If `snow=0` is intentional (snow only affects initial
conditions), update the docstring to clearly state this limitation.
Out of Scope
Effort Estimate
Size: `XS`
Rationale: One-line fix if the parameter should be passed through,
or a docstring update if the behaviour is intentional.
Definition of Done
initialization-only
and cold temperatures are provided