• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thouska / spotpy / 15283517039

27 May 2025 07:01PM UTC coverage: 67.799% (+0.006%) from 67.793%
15283517039

Pull #334

github

web-flow
Merge 459e2938c into 47dd43fa1
Pull Request #334: Typo adjustments, black formatting, drop Python 3.9, support Python 3.13

24 of 99 new or added lines in 15 files covered. (24.24%)

14 existing lines in 8 files now uncovered.

3752 of 5534 relevant lines covered (67.8%)

2.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/spotpy/examples/spot_setup_hymod_python_pareto.py
1
"""
2
Copyright 2015 by Tobias Houska
3
This file is part of Statistical Parameter Estimation Tool (SPOTPY).
4

5
:author: Tobias Houska
6

7
This example implements the python version of hymod into SPOTPY.
8
"""
9

UNCOV
10
import os
×
11

12
import numpy as np
×
13

14
import spotpy
×
15
from spotpy.examples.hymod_python.hymod import hymod
×
16

17

18
class spot_setup(object):
×
19
    cmax = spotpy.parameter.Uniform(low=1.0, high=500, optguess=412.33)
×
20
    bexp = spotpy.parameter.Uniform(low=0.1, high=2.0, optguess=0.1725)
×
21
    alpha = spotpy.parameter.Uniform(low=0.1, high=0.99, optguess=0.8127)
×
22
    Ks = spotpy.parameter.Uniform(low=0.0, high=0.10, optguess=0.0404)
×
23
    Kq = spotpy.parameter.Uniform(low=0.1, high=0.99, optguess=0.5592)
×
24

25
    def __init__(self):
×
26
        # Transform [mm/day] into [l s-1], where 1.783 is the catchment area
27
        self.Factor = 1.783 * 1000 * 1000 / (60 * 60 * 24)
×
28
        # Load Observation data from file
29
        self.PET, self.Precip = [], []
×
30
        self.date, self.trueObs = [], []
×
31
        self.owd = os.path.dirname(os.path.realpath(__file__))
×
32
        self.hymod_path = self.owd + os.sep + "hymod_python"
×
33
        climatefile = open(self.hymod_path + os.sep + "hymod_input.csv", "r")
×
34
        headerline = climatefile.readline()[:-1]
×
35

36
        if ";" in headerline:
×
37
            self.delimiter = ";"
×
38
        else:
39
            self.delimiter = ","
×
40
        self.header = headerline.split(self.delimiter)
×
41
        for line in climatefile:
×
42
            values = line.strip().split(self.delimiter)
×
43
            self.date.append(str(values[0]))
×
44
            self.Precip.append(float(values[1]))
×
45
            self.PET.append(float(values[2]))
×
46
            self.trueObs.append(float(values[3]))
×
47

48
        climatefile.close()
×
49

50
    def simulation(self, x):
×
51
        data = hymod(self.Precip, self.PET, x[0], x[1], x[2], x[3], x[4])
×
52
        sim = []
×
53
        for val in data:
×
54
            sim.append(val * self.Factor)
×
55
        return sim[366:]
×
56

57
    def evaluation(self):
×
58
        return self.trueObs[366:]
×
59

60
    def objectivefunction(self, simulation, evaluation, params=None):
×
61
        return [
×
62
            -abs(spotpy.objectivefunctions.bias(evaluation, simulation)),
63
            spotpy.objectivefunctions.rsquared(evaluation, simulation),
64
            spotpy.objectivefunctions.nashsutcliffe(evaluation, simulation),
65
        ]
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc