コード例 #1
0
ファイル: modelGen.py プロジェクト: colinbrust/hydro_model
    def _generate_error_statistics(self):

        self._format_swe_data()
        self._format_sf_data()

        run_error = pd.read_csv(os.path.join(self.err_dir, 'run_error.csv'),
                                index_col=0)
        run_error.columns = run_error.columns.astype(str)
        swe_error = pd.read_csv(os.path.join(self.err_dir, 'swe_error.csv'),
                                index_col=0)
        swe_error.columns = swe_error.columns.astype(str)

        run_dict = {'run_number': self.run_number}
        swe_dict = {'run_number': self.run_number}

        for col in self.model_run:

            run_dict[str(col)] = kge(self.real_run[col].values,
                                     self.model_run[col].values)

        for col in self.model_swe:

            swe_dict[str(col)] = kge(self.real_swe[col].values,
                                     self.model_swe[col].values)

        run_error = run_error.append(pd.DataFrame(run_dict, index=[1]),
                                     sort=True,
                                     ignore_index=True)
        run_error.columns = run_error.columns.astype(str)
        swe_error = swe_error.append(pd.DataFrame(swe_dict, index=[1]),
                                     sort=True,
                                     ignore_index=True)
        swe_error.columns = swe_error.columns.astype(str)

        run_error.to_csv(os.path.join(self.err_dir, 'run_error.csv'))
        swe_error.to_csv(os.path.join(self.err_dir, 'swe_error.csv'))
コード例 #2
0
 def test_kge_return_all(self):
     expected = (-0.92083174734809159, -0.1105109772757096, 0.95721520413458061, -0.56669379018786747)
     res = of.kge(self.evaluation, self.simulation, return_all=True)
     for exp, actual in zip(expected, res):
         self.assertAlmostEqual(actual, exp, self.tolerance)
コード例 #3
0
    return {'obs': pend_obs, 'sim': pend_sim, 'correcta': (pend_obs > 0) is (pend_sim > 0)}


algs_spotpy = {
    'fast': spotpy.algorithms.fast,
    'dream': spotpy.algorithms.dream,
    'cm': spotpy.algorithms.mc,
    'cmmc': spotpy.algorithms.mcmc,
    'epm': spotpy.algorithms.mle,
    'mhl': spotpy.algorithms.lhs,
    'as': spotpy.algorithms.sa,
    'sceua': spotpy.algorithms.sceua,
    'erop': spotpy.algorithms.rope,
    'caa': spotpy.algorithms.abc,
    'fscabc': spotpy.algorithms.fscabc,
    'bdd': spotpy.algorithms.dds
}

eval_funcs = {
    'ens': lambda o, s, f: spt_f.nashsutcliffe(o, s),
    'rcep': lambda o, s, f: -spt_f.rmse(o, s),
    'corresp': lambda o, s, f: spt_f.agreementindex(o, s),
    'ekg': lambda o, s, f: spt_f.kge(o, s),
    'r2': lambda o, s, f: spt_f.rsquared(o, s),
    'rcnep': lambda o, s, f: -spt_f.rrmse(o, s),
    'log p': lambda o, s, f: spt_f.log_p(o, s),
    'verosimil_gaus': lambda o, s, f: spt_l.gaussianLikelihoodMeasErrorOut(o, s),
    'tendencia': _anlz_tendencia
}
コード例 #4
0
 def test_kge(self):
     res = of.kge(self.evaluation, self.simulation)
     self.assertAlmostEqual(res, -0.92083174734809159, self.tolerance)