HydPy-Snow-CemaNeige-T-MinMax (CemaNeige model with additional minimum and maximum air temperature as input)

The CemaNeige model snow_cn_minmax is a small extension of snow_cn. In contrast to snow_cn, it usually relies on daily minimum and maximum air temperatures to differentiate between liquid and frozen precipitation. Hence, even more than snow_cn, snow_cn_minmax is primarily designed for simulating with daily time steps.

Integration tests

Note

When new to HydPy, consider reading section Integration Tests first.

Example 1

The following integration test is equivalent to Example 1 of the application model snow_cn except for TMin and TMax, of course. They are made up freely because airGR provides no fitting data.

The following configurations, with the exception of the control parameters GradTMin and GradTMax and the input sequences TMin and TMax, are identical to those of the corresponding integration test for snow_cn and thus do not require further explanation:

>>> from hydpy import pub
>>> pub.timegrids = "1990-04-01", "1990-06-01", "1d"
>>> from hydpy.models.snow_cn_minmax import *
>>> parameterstep("1d")
>>> from hydpy import Element
>>> land = Element("land")
>>> land.model = model
>>> from hydpy import IntegrationTest
>>> IntegrationTest.plotting_options.axis1 = inputs.p, fluxes.pnet
>>> IntegrationTest.plotting_options.axis2 = inputs.tmin, inputs.tmax, states.g
>>> test = IntegrationTest(land)
>>> test.dateformat = "%d.%m."
>>> hysteresis(False)
>>> nlayers(5)
>>> hypsodata = [
...     286.0, 309.0, 320.0, 327.0, 333.0, 338.0, 342.0, 347.0, 351.0, 356.0, 360.0,
...     365.0, 369.0, 373.0, 378.0, 382.0, 387.0, 393.0, 399.0, 405.0, 411.0, 417.0,
...     423.0, 428.0, 434.0, 439.0, 443.0, 448.0, 453.0, 458.0, 463.0, 469.0, 474.0,
...     480.0, 485.0, 491.0, 496.0, 501.0, 507.0, 513.0, 519.0, 524.0, 530.0, 536.0,
...     542.0, 548.0, 554.0, 560.0, 566.0, 571.0, 577.0, 583.0, 590.0, 596.0, 603.0,
...     609.0, 615.0, 622.0, 629.0, 636.0, 642.0, 649.0, 656.0, 663.0, 669.0, 677.0,
...     684.0, 691.0, 698.0, 706.0, 714.0, 722.0, 730.0, 738.0, 746.0, 754.0, 762.0,
...     770.0, 777.0, 786.0, 797.0, 808.0, 819.0, 829.0, 841.0, 852.0, 863.0, 875.0,
...     887.0, 901.0, 916.0, 934.0, 952.0, 972.0, 994.0, 1012.0, 1029.0, 10540.0,
...     10800.0, 11250.0, 12780.0
... ]
>>> model.prepare_layers(hypsodata=hypsodata)
>>> cn1(0.962)
>>> cn2(2.249)
>>> cn4(0.9)
>>> meanansolidprecip(83.0)
>>> gradp(0.00041)
>>> gradtmean(nan)
>>> gradtmean.values[90:152] = [
...     0.59, 0.591, 0.591, 0.592, 0.593, 0.593, 0.594, 0.595, 0.595, 0.596, 0.596,
...     0.597, 0.597, 0.597, 0.598, 0.598, 0.598, 0.599, 0.599, 0.599, 0.599, 0.6, 0.6,
...     0.6, 0.6, 0.6, 0.601, 0.601, 0.601, 0.601, 0.601, 0.601, 0.601, 0.601, 0.601,
...     0.601, 0.601, 0.601, 0.601, 0.601, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602,
...     0.602, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602, 0.602,
...     0.602, 0.602, 0.602, 0.602, 0.602]
>>> gradtmin(nan)
>>> gradtmin.values[90:152] = [
...     0.425, 0.426, 0.427, 0.427, 0.428, 0.429, 0.429, 0.43, 0.431, 0.431, 0.432,
...     0.432, 0.433, 0.433, 0.434, 0.434, 0.435, 0.435, 0.436, 0.436, 0.436, 0.437,
...     0.437, 0.437, 0.438, 0.438, 0.438, 0.438, 0.439, 0.439, 0.439, 0.439, 0.439,
...     0.439, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44,
...     0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.44, 0.439, 0.439,
...     0.439, 0.439, 0.439]
>>> gradtmax(nan)
>>> gradtmax.values[90:152] = [
...     0.783, 0.784, 0.785, 0.785, 0.786, 0.787, 0.787, 0.787, 0.788, 0.788, 0.788,
...     0.788, 0.788, 0.788, 0.788, 0.788, 0.787, 0.787, 0.787, 0.786, 0.786, 0.785,
...     0.785, 0.784, 0.784, 0.783, 0.783, 0.782, 0.781, 0.781, 0.78, 0.779, 0.778,
...     0.778, 0.777, 0.776, 0.775, 0.775, 0.774, 0.773, 0.772, 0.772, 0.771, 0.77,
...     0.77, 0.769, 0.768, 0.768, 0.767, 0.767, 0.766, 0.766, 0.765, 0.765, 0.764,
...     0.764, 0.764, 0.763, 0.763, 0.763, 0.762, 0.762]
>>> parameters.update()
>>> derived.zmean(577)
>>> test.inits = (
...     (states.g, [0.0, 0.0, 0.0, 0.0, 0.0]),
...     (states.etg, [0.0, 0.0, 0.0, 0.0, 0.0]),
...     (states.gratio, [0.0, 0.0, 0.0, 0.0, 0.0]),
... )
>>> inputs.p.series = (
...     0.4, 0.0, 1.0, 1.6, 3.1, 0.0, 0.0, 0.0, 0.0, 2.4, 2.1, 0.8, 8.4, 16.1, 2.9,
...     0.0, 0.4, 12.2, 8.8, 6.3, 2.5, 0.0, 0.0, 1.7, 2.5, 9.9, 7.5, 0.3, 6.3, 4.6,
...     1.1, 0.0, 0.0, 0.0, 0.4, 9.1, 0.0, 13.4, 4.0, 0.0, 0.0, 8.6, 5.3, 2.5, 1.8,
...     0.0, 2.4, 13.3, 5.8, 4.3, 20.0, 9.8, 2.1, 1.6, 3.7, 0.2, 0.0, 0.0, 0.1, 0.7,
...     2.2)
>>> inputs.t.series = (
...     7.2, 7.1, 6.4, 7.4, 7.5, 4.3, 3.5, 3.5, 4.5, 5.0, 1.9, 1.8, 3.0, 1.3, 0.2, 1.8,
...     1.5, 3.7, 7.4, 7.6, 5.8, 6.0, 8.1, 8.1, 8.6, 8.7, 6.6, 8.8, 9.6, 9.2, 7.8, 8.0,
...     10.6, 13.8, 12.1, 7.7, 7.0, 10.0, 9.1, 11.3, 6.6, 7.4, 5.9, 7.6, 9.2, 11.8,
...     13.8, 12.1, 10.8, 11.7, 11.1, 7.3, 8.0, 10.3, 8.0, 10.4, 14.0, 14.2, 14.9,
...     15.6, 16.3)
>>> inputs.tmin.series = (
...     4.5, 4.0, 3.9, 5.8, 7.4, 3.4, 2.5, 0.1, 2.3, 4.9, 1.3, -1.5, 2.0, -0.5, -3.7,
...     0.4, -1.6, 3.2, 6.2, 6.4, 3.4, 5.8, 4.6, 5.0, 7.7, 4.8, 3.5, 5.4, 8.6, 6.1,
...     5.1, 7.1, 8.9, 10.8, 9.2, 5.7, 5.8, 6.5, 9.0, 10.9, 4.1, 4.5, 2.5, 3.7, 8.0,
...     10.0, 11.3, 11.9, 8.8, 9.9, 10.0, 6.5, 6.6, 6.4, 7.7, 6.5, 13.0, 13.9, 12.9,
...     12.7, 16.0)
>>> inputs.tmax.series = (
...     10.2, 10.0, 10.0, 10.9, 7.6, 4.9, 7.5, 4.3, 7.8, 6.5, 4.1, 3.2, 4.8, 1.8, 3.8,
...     3.0, 4.8, 5.9, 7.6, 9.0, 9.2, 8.3, 11.8, 8.8, 10.9, 12.1, 8.7, 10.0, 11.1,
...     11.4, 9.6, 10.7, 11.0, 17.0, 14.6, 8.2, 10.5, 10.8, 11.8, 14.8, 9.4, 7.9, 9.6,
...     9.7, 11.7, 15.4, 17.6, 12.3, 14.1, 12.6, 12.2, 10.6, 10.8, 11.6, 11.7, 10.8,
...     15.6, 14.6, 16.3, 19.2, 16.5)

Given that snow_cn_minmax and snow_cn differ only in the calculation of the solid precipitation fraction, it is not surprising that the following test results are quite simple to Example 1 of snow_cn:

>>> test("snow_cn_minmax_example1", update_parameters=False)
Click to see the table
Click to see the graph

Example 2

This integration test repeats Example 2 of snow_cn with additional data regarding daily minimum and maximum air temperature:

>>> pub.timegrids = "1990-01-01", "1990-01-16", "1d"
>>> hysteresis(True)
>>> cn3(20.0)
>>> cn4(0.4)
>>> gradtmean.values[:16] = [
...     0.434, 0.434, 0.435, 0.436, 0.437, 0.439, 0.44, 0.441, 0.442, 0.444, 0.445,
...     0.446, 0.448, 0.45, 0.451, 0.453]
>>> gradtmin.values[:16] = [
...     0.366, 0.366, 0.367, 0.367, 0.367, 0.367, 0.367, 0.368, 0.368, 0.368, 0.368,
...     0.368, 0.369, 0.369, 0.369, 0.37]
>>> gradtmax.values[:16] = [
...     0.498, 0.5, 0.501, 0.503, 0.504, 0.506, 0.508, 0.51, 0.512, 0.514, 0.517,
...     0.519, 0.522, 0.525, 0.527, 0.53]
>>> parameters.update()
>>> derived.zmean(577)
>>> test.inits = (
...     (states.g, [10.0, 15.0, 20.0, 30.0, 40.0]),
...     (states.etg, [0.0, 0.0, 0.0, 0.0, 0.0]),
...     (states.gratio, [0.8, 0.8, 0.8, 0.8, 0.8]),
...     (logs.glocalmax, derived.gthresh),
... )
>>> inputs.t.series = (
...     5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1.0, -1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0
... )
>>> inputs.tmin.series = inputs.t.series - 1.0
>>> inputs.tmax.series = inputs.t.series + 3.0
>>> inputs.p.series = (
...     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
... )

The defined, constant difference between the minimum and maximum air temperature enforces a behaviour similar to the temperature interval approach of snow_cn defined by the fixed parameters TThreshSnow and TThreshRain. Hence, we observe close agreement with the calculation results of Example 2:

>>> test("snow_cn_minmax_hyst_example2", update_parameters=False)
Click to see the table
Click to see the graph
class hydpy.models.snow_cn_minmax.Model[source]

Bases: BaseModel

HydPy-Snow-CemaNeige-T-MinMax (CemaNeige model with additional minimum and maximum air temperature as input).

The following “run methods” are called in the given sequence during each simulation step:
The following “additional methods” might be called by one or more of the other methods or are meant to be directly called by the user:
  • Return_T_V1 Return the altitude-adjusted temperature.

DOCNAME = ('Snow-CemaNeige-T-MinMax', 'CemaNeige model with additional minimum and maximum air temperature as input')
OBSERVER_METHODS = ()
REUSABLE_METHODS = ()
class hydpy.models.snow_cn_minmax.ControlParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Control parameters of model snow_cn_minmax.

The following classes are selected:
  • NLayers() Number of snow layers [-].

  • ZLayers() Height of each snow layer [m].

  • LayerArea() Area of snow layer as a percentage of total area [-].

  • GradP() Altitude gradient of precipitation [1/m].

  • GradTMean() Altitude gradient of daily mean air temperature for each day of the year [°C/100m].

  • GradTMin() Altitude gradient of daily minimum air temperature for each day of the year [°C/100m].

  • GradTMax() Altitude gradient of daily maximum air temperature for each day of the year [°C/100m].

  • MeanAnSolidPrecip() Mean annual solid precipitation [mm/a].

  • CN1() Temporal weighting coefficient for the snow pack’s thermal state [-].

  • CN2() Degree-day melt coefficient [mm/°C/T].

  • CN3() Accumulation threshold [mm].

  • CN4() Fraction of annual snowfall defining the melt threshold [-].

  • Hysteresis() Flag that indicates whether hysteresis of build-up and melting of the snow cover should be considered [-].

class hydpy.models.snow_cn_minmax.DerivedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Derived parameters of model snow_cn_minmax.

The following classes are selected:
  • DOY() References the “global” month of the year index array [-].

  • GThresh() Accumulation threshold [mm].

  • ZMean() Mean elevation of all layer [m].

class hydpy.models.snow_cn_minmax.FactorSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FactorSequences

Factor sequences of model snow_cn_minmax.

The following classes are selected:
class hydpy.models.snow_cn_minmax.FixedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Fixed parameters of model snow_cn_minmax.

The following classes are selected:
  • ZThreshold() Altitude threshold for constant precipitation [m].

  • MinMelt() Minimum ratio of actual to potential melt [-].

  • TThreshSnow() Temperature below which all precipitation falls as snow [°C].

  • TThreshRain() Temperature above which all precipitation falls as rain [°C].

  • MinG() Amount of snow below which actual melt can be equal to potential melt [mm].

class hydpy.models.snow_cn_minmax.FluxSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FluxSequences

Flux sequences of model snow_cn_minmax.

The following classes are selected:
  • PLayer() Precipitation of each snow layer [mm/T].

  • PSnowLayer() Snowfall of each snow layer [mm/T].

  • PRainLayer() Rainfall of each snow layer [mm/T].

  • PotMelt() Potential snow melt of each snow layer [mm/T].

  • Melt() Actual snow melt of each snow layer [mm/T].

  • PNetLayer() Net precipitation of each snow layer [mm/T].

  • PNet() Net precipitation of the complete catchment [mm/T].

class hydpy.models.snow_cn_minmax.InputSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: InputSequences

Input sequences of model snow_cn_minmax.

The following classes are selected:
  • P() Precipitation [mm/T].

  • T() Mean air temperature [°C].

  • TMin() Minimum air temperature [°C].

  • TMax() Maximum air temperature [°C].

class hydpy.models.snow_cn_minmax.LogSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: LogSequences

Log sequences of model snow_cn_minmax.

The following classes are selected:
class hydpy.models.snow_cn_minmax.StateSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: StateSequences

State sequences of model snow_cn_minmax.

The following classes are selected:
  • G() Snow pack [mm].

  • ETG() Thermal state of the snow pack [°C].

  • GRatio() Ratio of the snow-covered area [-].