MARRMOT_37

Implementation

MARRMoT v2.1.1 rev eeb7e15 m_37_hbv_15p_5s; standardized continuous structure, not original model

  • Time step: daily

  • Backend: octave-cli + Octave optim

  • Calibrated parameters: 15

  • Temperature required: yes

Inspect the exact implementation.

Parameters and initial configuration

Parameter

Supported calibration range

Default

p01

-3 to 5

1.0

p02

0 to 17

8.5

p03

-3 to 3

0.0

p04

0 to 1

0.5

p05

0 to 20

10.0

p06

0 to 1

0.5

p07

0 to 4

2.0

p08

1 to 2000

1000.5

p09

0.05 to 0.95

0.5

p10

0 to 10

5.0

p11

0 to 1

0.5

p12

0 to 4

2.0

p13

0 to 20

10.0

p14

0 to 1

0.5

p15

1 to 120

60.5

s01

Fixed initial/configuration value

0.0

s02

Fixed initial/configuration value

0.0

s03

Fixed initial/configuration value

0.0

s04

Fixed initial/configuration value

0.0

s05

Fixed initial/configuration value

0.0

Ranges/defaults are implementation contracts, not universal priors or a recommended basin calibration. Consult source comments for parameter units and coupling.

Governing equations

The following source is the exact model kernel used by this adapter. For MARRMoT it includes the state derivative and each referenced flux function; the solver and routing are described above. Original notices and source citations are retained in the files.

        function [dS, fluxes] = model_fun(obj, S)
            % parameters
            theta = obj.theta;
            tt      = theta(1);     % TT, middle of snow-rain interval [oC]
            tti     = theta(2);     % TTI, interval length of rain-snow spectrum [oC]
            ttm     = theta(3);     % TTM, threshold temperature for snowmelt [oC]
            cfr     = theta(4);     % CFR, coefficient of refreezing of melted snow [-]
            cfmax   = theta(5);     % CFMAX, degree-day factor of snowmelt and refreezing [mm/oC/d]
            whc     = theta(6);     % WHC, maximum water holding content of snow pack [-]
            cflux   = theta(7);   	% CFLUX, maximum rate of capillary rise [mm/d]
            fc      = theta(8);     % FC, maximum soil moisture storage [mm]
            lp      = theta(9);     % LP, wilting point as fraction of FC [-]
            beta    = theta(10);    % BETA, non-linearity coefficient of upper zone recharge [-]
            k0      = theta(11);    % K0, runoff coefficient from upper zone [d-1], 
            alpha   = theta(12);    % ALPHA, non-linearity coefficient of runoff from upper zone [-]
            perc    = theta(13);    % PERC, maximum rate of percolation to lower zone [mm/d]
            k1      = theta(14);    % K1, runoff coefficient from lower zone [d-1]
            maxbas  = theta(15);    % MAXBAS, flow routing delay [d]
            
            % delta_t
            delta_t = obj.delta_t;
            
            % unit hydrographs and still-to-flow vectors
            uhs = obj.uhs;
            uh = uhs{1};
            
            % stores
            S1 = S(1);
            S2 = S(2);
            S3 = S(3);
            S4 = S(4);
            S5 = S(5);
            
            % stores at previous timestep
            t = obj.t;                             % this time step
            if t == 1
                S2old=obj.S0(2);
            else
                S2old = obj.stores(t-1,2);
            end
            
            % climate input
            climate_in = obj.input_climate(t,:);   % climate at this step
            P  = climate_in(1);
            Ep = climate_in(2);
            T  = climate_in(3);
            
            % fluxes functions
            flux_sf   = snowfall_2(P,T,tt,tti);
            flux_refr = refreeze_1(cfr,cfmax,ttm,T,S2,delta_t);
            flux_melt = melt_1(cfmax,ttm,T,S1,delta_t);
            flux_rf   = rainfall_2(P,T,tt,tti);
            flux_in   = infiltration_3(flux_rf+flux_melt,S2,whc*S1);
            flux_se   = excess_1(S2old,whc*S1,delta_t);
            flux_cf   = capillary_1(cflux,S3,fc,S4,delta_t);
            flux_ea   = evap_3(lp,S3,fc,Ep,delta_t);
            flux_r    = recharge_2(beta,S3,fc,flux_in+flux_se);
            flux_q0   = interflow_2(k0,S4,alpha,delta_t);
            flux_perc = percolation_1(perc,S4,delta_t);
            flux_q1   = baseflow_1(k1,S5);
            flux_qt   = route(flux_q0 + flux_q1, uh);

            % stores ODEs
            dS1 = flux_sf   + flux_refr - flux_melt;
            dS2 = flux_rf   + flux_melt - flux_refr - flux_in - flux_se;
            dS3 = flux_in   + flux_se   + flux_cf   - flux_ea - flux_r;
            dS4 = flux_r    - flux_cf   - flux_q0   - flux_perc;
            dS5 = flux_perc - flux_q1;
            
            % outputs
            dS = [dS1 dS2 dS3 dS4 dS5];
            fluxes = [flux_sf,   flux_refr, flux_melt, flux_rf, flux_in,...
                      flux_se,   flux_cf,   flux_ea,   flux_r,  flux_q0,...
                      flux_perc, flux_q1, flux_qt];
        end
        
        % STEP runs at the end of every timestep, use it to update
        % still-to-flow vectors from unit hydrographs
function [out] = snowfall_2(In,T,p1,p2)
%snowfall_2 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Snowfall based on a temperature threshold interval
% Constraints:  -
% @(Inputs):    p1   - midpoint of the combined rain/snow interval [oC]
%               p2   - length of the mixed snow/rain interval [oC]
%               T    - current temperature [oC]
%               In   - incoming precipitation flux [mm/d]

out = min(In,max(0,In.*(p1+0.5*p2-T)/p2));

end
function [out] = refreeze_1(p1,p2,p3,T,S,dt)
%refreeze_1 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Refreezing of stored melted snow
% Constraints:  f <= S/dt
% @(Inputs):    p1   - reduction fraction of degree-day-factor [-]
%               p2   - degree-day-factor [mm/oC/d]
%               p3   - temperature threshold for snowmelt [oC]
%               T    - current temperature [oC]
%               S    - current storage [mm]
%               dt   - time step size [d]

out = max(min(p1*p2*(p3-T), S/dt), 0);

end
function [out] = melt_1(p1,p2,T,S,dt)
%melt_1 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Snowmelt from degree-day-factor 
% Constraints:  f <= S/dt
% @(Inputs):    p1   - degree-day factor [mm/oC/d]
%               p2   - temperature threshold for snowmelt [oC]
%               T    - current temperature [oC]
%               S    - current storage [mm]
%               dt   - time step size [d]

out = max(min(p1*(T-p2),S/dt),0);

end
function [out] = rainfall_2(In,T,p1,p2)
%rainfall_2 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Rainfall based on a temperature threshold interval
% Constraints:  -
% @(Inputs):    In   - incoming precipitation flux [mm/d]
%               T    - current temperature [oC]
%               p1   - midpoint of the combined rain/snow interval [oC]
%               p2   - length of the mixed snow/rain interval [oC]

out = min(In,max(0,In.*(T-(p1-0.5*p2))/p2));

end
function [out] = infiltration_3(In,S,Smax,varargin)
%infiltration_3 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Infiltration to soil moisture of liquid water stored in snow pack
% Constraints:  -
% @(Inputs):    In   - incoming flux [mm/d]
%               S    - current storage [mm]
%               Smax - maximum storage [mm]
%               varargin(1) - smoothing variable r (default 0.01)
%               varargin(2) - smoothing variable e (default 5.00)

if size(varargin,2) == 0
    out = In.*(1-smoothThreshold_storage_logistic(S,Smax));
elseif size(varargin,2) == 1
    out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1)));
elseif size(varargin,2) == 2
    out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1),varargin(2)));    
end

end
function [out] = excess_1(So,Smax,dt)
%excess_1

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Storage excess when store size changes (returns flux [mm/d])
% Constraints:  f >= 0
% @(Inputs):    So   - 'old' storage [mm]
%               Smax - 'new' maximum storage [mm]
%               dt   - time step size [d]

out = max((So-Smax)/dt,0);

end
function [out] = capillary_1(p1,S1,S1max,S2,dt)
%capillary_1 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Capillary rise: based on deficit in higher reservoir
% Constraints:  f <= S2/dt
% @(Inputs):    p1   - maximum capillary rise rate  [mm/d]
%               S1   - current storage in receiving store [mm]
%               S1max- maximum storage in receiving store [mm]
%               S2   - current storage in providing store [mm]
%               dt   - time step size [d]

out = min(p1.*(1-S1/S1max),S2/dt);

end
function [out] = evap_3(p1,S,Smax,Ep,dt)
%evap_3 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Evaporation based on scaled current water storage and wilting point
% Constraints:  f <= Ep
%               f <= S/dt
% @(Inputs):    p1   - wilting point as fraction of Smax [-]
%               S    - current storage [mm]
%               Smax - maximum storage [mm]
%               Ep   - potential evapotranspiration rate [mm/d]
%               dt   - time step size [d]

out = min([S/(p1*Smax)*Ep,Ep,S/dt]);

end
function [out] = recharge_2(p1,S,Smax,flux)
%recharge_2 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Recharge as non-linear scaling of incoming flux
% Constraints:  S >= 0
% @(Inputs):    p1   - recharge scaling non-linearity [-]
%               S    - current storage [mm]
%               Smax - maximum contributing storage [mm]
%               flux - incoming flux [mm/d]

out = flux*((max(S,0)/Smax)^p1);

end
function [out] = interflow_2(p1,S,p2,dt)
%interflow_2 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Non-linear interflow
% Constraints:  f <= S
%               S >= 0  - this avoids numerical issues with complex numbers
% @(Inputs):    p1   - time delay [d-1]
%               p2   - exponential scaling parameter [-]
%               S    - current storage [mm]
%               dt   - time step size [d]

out = min(p1*max(S,0)^(1+p2),max(S/dt,0));

end
function [out] = percolation_1(p1,S,dt)
%percolation_1 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Percolation at a constant rate
% Constraints:  f <= S/dt
% @(Inputs):    p1   - base percolation rate [mm/d]
%               S    - current storage [mm]
%               dt   - time step size [d]

out = min(p1,S/dt);

end
function [out] = baseflow_1(p1,S)
% baseflow_1 

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% Flux function
% ------------------
% Description:  Outflow from a linear reservoir
% Constraints:  -
% @(Inputs):    p1   - time scale parameter [d-1]
%               S    - current storage [mm]

out = p1.*S;

end
function [ flux_out ] = route(flux_in, uh)
% ROUTE calculates the output of a unit hydrograph at the current timestep
% after routing a flux through it.

% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

% In:
% flux_in   - input flux         [1x1]
% uh        - unit hydrograph    [nx2]
%               uh's first row contains coeficients to splut flow at each
%               of n timesteps forward, the second row contains
%               still-to-flow values.
%
% Out:
% flux_out  - flux routed through the uh at this step [1x1]
%

flux_out = uh(1,1) * flux_in + uh(2,1);

end
function [out] = smoothThreshold_storage_logistic(S,Smax,r,e)
%smoothThreshold_storage_logistic Logisitic smoother for storage threshold functions.

% Copyright (C) 2018 Wouter J.M. Knoben
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.

%   Smooths the transition of threshold functions of the form:
%
%   Q = { P, if S = Smax
%       { 0, if S < Smax
%
%   By transforming the equation above to Q = f(P,S,Smax,e,r):
%   Q = P * 1/ (1+exp((S-Smax+r*e*Smax)/(r*Smax)))
%
%   Inputs:
%   S       : current storage
%   Smax    : maximum storage
%   r       : [optional] smoothing parameter rho, default = 0.01
%   e       : [optional] smoothing parameter e, default 5
%
%   NOTE: this function only outputs the multiplier. This needs to be
%   applied to the proper flux utside of this function.
%
%   NOTE: can be applied for temperature thresholds as well (i.e. snow
%   modules). This simply means that S becomes T, and Smax T0.

% Check for inputs and use defaults if not provided
% NOTE: this is not very elegant, but it is more than a factor 10 faster then: 
% if ~exist('r','var'); r = 0.01; end
% if ~exist('e','var'); e = 5.00; end
if nargin == 2
    r = 0.01;
    e = 5.00;
elseif nargin == 3
    r = r{1};
    e = 5.00;
elseif nargin == 4
    r = r{1};
    e = e{1};
end

% Calculate multiplier
Smax = max(Smax,0);   % this avoids numerical instabilities when Smax<0
if r*Smax == 0
    out = 1 ./ (1+exp((S-Smax+r*e*Smax)/(r)));
else
    out = 1 ./ (1+exp((S-Smax+r*e*Smax)/(r*Smax)));
end

end

Note

This standardized MARRMoT structure is not identical to the original named model. p01... follow exact source order; s01... are fixed initial stores, defaulting to zero. Octave + optim are required. Solver behavior can differ across runtime versions.

Simulation

from basinforge import Basin, get_model

basin = Basin.from_csv("basin.csv", basin_id="A", area_km2=1200,
                       q_unit="m3/s", timestep="daily")
q_mm = get_model("MARRMOT_37").simulate(basin)
q_m3s = basin.to_m3s(q_mm)

Supply your actual data and catchment area; temperature-dependent models require a temperature column. For non-daily models, choose an appropriate warmup in model steps.

See calibration, input requirements, sources and verification limitations.