qmax = 20 ddf = 2 mint = -1 maxt = 1 # Assign the above parameter values into the model parameters object params.assignvalues(f, smax, qmax, ddf, mint, maxt) # Initialise the model by loading its climate inputs model = ExphydroModel(P, PET, T) # Specify the start and end day numbers of the simulation period. # This is done separately for the observed and simulated data # because they might not be of the same length in some cases. simperiods_obs = [365, 2557] simperiods_sim = [365, 2557] # Run the model and calculate objective function value for the simulation period Qsim = model.simulate(params) kge = ObjectiveFunction.klinggupta( Qobs[simperiods_obs[0]:simperiods_obs[1] + 1], Qsim[simperiods_sim[0]:simperiods_sim[1] + 1]) print('KGE value = ', kge) # Plot the observed and simulated hydrographs plt.plot(Qobs[simperiods_obs[0]:simperiods_obs[1] + 1], 'b-') plt.plot(Qsim[simperiods_sim[0]:simperiods_sim[1] + 1], 'r-') plt.show() ######################################################################
# Generate 'niter' initial EXP-HYDRO model parameters params = [ExphydroParameters() for j in range(niter)] # Initialise the model by loading its climate inputs model = ExphydroModel(P, PET, T) # Specify the start and end day numbers of the calibration period. # This is done separately for the observed and simulated data # because they might not be of the same length in some cases. calperiods_obs = [365, 2557] calperiods_sim = [365, 2557] # Calibrate the model to identify optimal parameter set paramsmax = Calibration.montecarlo_maximise(model, params, Qobs, ObjectiveFunction.klinggupta, calperiods_obs, calperiods_sim) print 'Calibration run KGE value = ', paramsmax.objval # Run the optimised model for validation period Qsim = model.simulate(paramsmax) kge = ObjectiveFunction.klinggupta(Qobs[calperiods_obs[1]:], Qsim[calperiods_sim[1]:]) print 'Independent run KGE value = ', kge # Plot the observed and simulated hydrographs plt.plot(Qobs[calperiods_obs[0]:], 'b-') plt.hold(True) plt.plot(Qsim[calperiods_sim[0]:], 'r-') plt.show() ######################################################################
qmax = 20 ddf = 2 mint = -1 maxt = 1 # Assign the above parameter values into the model parameters object params.assignvalues(f, smax, qmax, ddf, mint, maxt) # Initialise the model by loading its climate inputs model = ExphydroModel(P, PET, T) # Specify the start and end day numbers of the simulation period. # This is done separately for the observed and simulated data # because they might not be of the same length in some cases. simperiods_obs = [365, 2557] simperiods_sim = [365, 2557] # Run the model and calculate objective function value for the simulation period Qsim = model.simulate(params) kge = ObjectiveFunction.klinggupta(Qobs[simperiods_obs[0]:simperiods_obs[1]+1], Qsim[simperiods_sim[0]:simperiods_sim[1]+1]) print 'KGE value = ', kge # Plot the observed and simulated hydrographs plt.plot(Qobs[simperiods_obs[0]:simperiods_obs[1]+1], 'b-') plt.hold(True) plt.plot(Qsim[simperiods_sim[0]:simperiods_sim[1]+1], 'r-') plt.show() ######################################################################