Skip to content

Commit

Permalink
cleaned calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
richardarsenault committed Dec 9, 2023
1 parent dbe412b commit f46847e
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions xhydro/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from spotpy.parameter import Uniform
import spotpy
import hydroeval as he
from xhydro.hydrological_modelling import hydrological_model_selector

class spot_setup(object):

Expand Down Expand Up @@ -80,32 +81,7 @@ def perform_calibration(model_config, evaluation_metric, maximize, bounds_high,
#objfun = get_objective_function_value(model_config['Qobs'], Qsim, best_parameters, obj_func=evaluation_metric)

return best_parameters, Qsim, bestobjf


def dummy_model(model_config):

"""
Dummy model to show the implementation we should be aiming for. Each model
will have its own required data that users can pass. We could envision a setup
where a class generates the model_config object for all model formats making it
possible to replace models on the fly
"""

precip = model_config['precip']
temperature = model_config['temperature']
drainage_area = model_config['drainage_area']
parameters = model_config['parameters']

Q = np.empty(len(precip))

for t in range(0,len(precip)):

Q[t]= (precip[t] * parameters[0] + abs(temperature[t])*parameters[1])* parameters[2] * drainage_area


return Q





def transform_flows(Qobs, Qsim, transform=None, epsilon=None):
Expand Down Expand Up @@ -139,17 +115,6 @@ def transform_flows(Qobs, Qsim, transform=None, epsilon=None):
return Qobs, Qsim



def hydrological_model_selector(model_config):

if model_config['model_name'] == 'Dummy':
Qsim = dummy_model(model_config)

# ADD OTHER MODELS HERE

return Qsim


def get_objective_function_value(Qobs, Qsim, params, transform=None, epsilon=None, obj_func=None):

# Transform flows if needed
Expand Down

0 comments on commit f46847e

Please sign in to comment.