@@ -599,35 +599,61 @@ def result_table(self, freq='daily', top_n=5, latex=False):
599599 sim_names = [path .split (os .sep )[- 1 ] for path in sim_dirs ]
600600 meas_var = self ._get_measured (self .stage )
601601 statvar_name = self ._get_statvar_name (self .stage )
602+ orig_statvar = load_statvar (OPJ (self .input_dir ,'statvar.dat' ))\
603+ [statvar_name ]
604+
602605 result_df = pd .DataFrame (columns = \
603606 ['NSE' ,'RMSE' ,'PBIAS' ,'COEF_DET' ,'ABS(PBIAS)' ])
607+ orig_results = pd .DataFrame (index = ['orig_params' ],\
608+ columns = ['NSE' ,'RMSE' ,'PBIAS' ,'COEF_DET' ])
609+ # get datetime indices that overlap from measured and simulated
610+ sim_out = load_statvar (OPJ (sim_dirs [0 ], 'outputs' , 'statvar.dat' ))\
611+ [statvar_name ]
612+ idx = meas_var .index .intersection (sim_out .index )
613+ meas_var = copy (meas_var [idx ])
614+ #sim_out = sim_out[idx]
615+ orig_statvar = orig_statvar [idx ]
616+
617+ if freq == 'monthly' :
618+ meas_mo = meas_var .groupby (meas_var .index .month ).mean ()
619+ orig_mo = orig_statvar .groupby (orig_statvar .index .month ).mean ()
620+
604621 for i , sim in enumerate (sim_dirs ):
605622 sim_out = load_statvar (OPJ (sim , 'outputs' , 'statvar.dat' ))\
606623 ['{}' .format (statvar_name )]
607- idx = meas_var .index .intersection (sim_out .index )
608- meas_var = copy (meas_var [idx ])
609624 sim_out = sim_out [idx ]
610625 if freq == 'daily' :
611626 result_df .loc [sim_names [i ]] = [\
612627 nash_sutcliffe (meas_var , sim_out ),\
613628 rmse (meas_var , sim_out ),\
614629 percent_bias (meas_var ,sim_out ),\
615630 meas_var .corr (sim_out )** 2 ,\
616- np .abs (percent_bias (meas_var , sim_out )) ]
631+ np .abs (percent_bias (meas_var , sim_out )) ]
632+ orig_results .loc ['orig_params' ] = [\
633+ nash_sutcliffe (orig_statvar ,meas_var ),\
634+ rmse (orig_statvar ,meas_var ),\
635+ percent_bias (orig_statvar ,meas_var ),\
636+ orig_statvar .corr (meas_var )** 2 ]
637+
617638 elif freq == 'monthly' :
618- meas_mo = meas_var .groupby (meas_var .index .month ).mean ()
619639 sim_out = sim_out .groupby (sim_out .index .month ).mean ()
620640 result_df .loc [sim_names [i ]] = [\
621641 nash_sutcliffe (meas_mo , sim_out ),\
622642 rmse (meas_mo , sim_out ),\
623643 percent_bias (meas_mo , sim_out ),\
624644 meas_mo .corr (sim_out )** 2 ,\
625645 np .abs (percent_bias (meas_mo , sim_out )) ]
626-
646+ orig_results .loc ['orig_params' ] = [\
647+ nash_sutcliffe (orig_mo ,meas_mo ),\
648+ rmse (orig_mo ,meas_mo ),\
649+ percent_bias (orig_mo ,meas_mo ),\
650+ orig_mo .corr (meas_mo )** 2 ]
651+
627652 sorted_result = result_df .sort_values (by = ['NSE' ,'RMSE' ,'ABS(PBIAS)' ,\
628653 'COEF_DET' ], ascending = [False ,True ,True ,False ])
629654 sorted_result .columns .name = '{} parameters' .format (self .stage )
630655 sorted_result = sorted_result [['NSE' ,'RMSE' ,'PBIAS' ,'COEF_DET' ]]
656+ sorted_result = pd .concat ([orig_results ,sorted_result ])
631657
632658 if latex : return sorted_result [:top_n ].to_latex (escape = False )
633659 else : return sorted_result [:top_n ]
0 commit comments