@@ -757,7 +757,12 @@ def write(self, stats_flpe, stats_moi, stats_O, reach_id, gage_type, GO):
757757 a_v_flpe = out .createVariable ("algorithm_flpe" , 'S1' , ("num_algos_flpe" , "nchar_flpe" ),)
758758 a_v_flpe [:] = stringtochar (stats_flpe ["algorithm" ][0 ].astype ("S16" ))
759759 gid_v_flpe = out .createVariable ("gageID_flpe" , "S1" , ("num_algos_flpe" , "nchar_gage" ), fill_value = fill )
760- gid_v_flpe [:] = stringtochar (stats_flpe ["Gid" ].astype ("S16" ))
760+
761+ gids_flpe = stats_flpe ["Gid" ]
762+ if gids_flpe .ndim > 1 :
763+ gids_flpe = gids_flpe [:, 0 ] # take first value per algo row
764+ gid_v_flpe [:] = stringtochar (gids_flpe .astype ("S16" ))
765+
761766 r_v_flpe = out .createVariable ("pearsonr_flpe" , "f8" , ("num_algos_flpe" ,), fill_value = fill )
762767 r_v_flpe [:] = np .where (np .isclose (stats_flpe ["pearsonr" ], empty ), fill , stats_flpe ["pearsonr" ])
763768 sige_v_flpe = out .createVariable ("SIGe_flpe" , "f8" , ("num_algos_flpe" ,), fill_value = fill )
@@ -817,7 +822,12 @@ def write(self, stats_flpe, stats_moi, stats_O, reach_id, gage_type, GO):
817822 a_v_moi = out .createVariable ("algorithm_moi" , 'S1' , ("num_algos_flpe" , "nchar_flpe" ),)
818823 a_v_moi [:] = stringtochar (stats_moi ["algorithm" ][0 ].astype ("S16" ))
819824 gid_v_moi = out .createVariable ("gageID_moi" , "S1" , ("num_algos_flpe" , "nchar_gage" ), fill_value = fill )
820- gid_v_moi [:] = stringtochar (stats_moi ["Gid" ].astype ("S16" ))
825+
826+ gids_moi = stats_moi ["Gid" ]
827+ if gids_moi .ndim > 1 :
828+ gids_moi = gids_moi [:, 0 ]
829+ gid_v_moi [:] = stringtochar (gids_moi .astype ("S16" ))
830+
821831 r_v_moi = out .createVariable ("pearsonr_moi" , "f8" , ("num_algos_flpe" ,), fill_value = fill )
822832 r_v_moi [:] = np .where (np .isclose (stats_moi ["pearsonr" ], empty ), fill , stats_moi ["pearsonr" ])
823833 sige_v_moi = out .createVariable ("SIGe_moi" , "f8" , ("num_algos_flpe" ,), fill_value = fill )
@@ -871,7 +881,12 @@ def write(self, stats_flpe, stats_moi, stats_O, reach_id, gage_type, GO):
871881 a_v_o = out .createVariable ("algorithm_o" , 'S1' , ("num_algos_offline" , "nchar_flpe" ),)
872882 a_v_o [:] = stringtochar (stats_O ["algorithm" ][0 ].astype ("S16" ))
873883 gid_v_o = out .createVariable ("gageID_o" , "S1" , ("num_algos_offline" , "nchar_gage" ), fill_value = fill )
874- gid_v_o [:] = stringtochar (stats_O ["Gid" ].astype ("S16" ))
884+
885+ gids_O = stats_O ["Gid" ]
886+ if gids_O .ndim > 1 :
887+ gids_O = gids_O [:, 0 ]
888+ gid_v_o [:] = stringtochar (gids_O .astype ("S16" ))
889+
875890 r_v_o = out .createVariable ("pearsonr_o" , "f8" , ("num_algos_offline" ,), fill_value = fill )
876891 r_v_o [:] = np .where (np .isclose (stats_O ["pearsonr" ], empty ), fill , stats_O ["pearsonr" ])
877892 sige_v_o = out .createVariable ("SIGe_o" , "f8" , ("num_algos_offline" ,), fill_value = fill )
0 commit comments