@@ -1155,6 +1155,7 @@ void MDA_IO<T_real>::_load_scalers(bool load_int_spec, bool hasNetCDF, bool subt
11551155 if (_mda_file->scan ->requested_points == 0 || _mda_file->scan ->last_point == 0 )
11561156 {
11571157 rows = 1 ;
1158+ cols = 1 ;
11581159 }
11591160 else
11601161 {
@@ -1179,31 +1180,45 @@ void MDA_IO<T_real>::_load_scalers(bool load_int_spec, bool hasNetCDF, bool subt
11791180 }
11801181 }
11811182
1182- size_t iamt = std::min ((size_t )_mda_file->scan ->last_point , cols);
1183+ size_t iamt = cols;
1184+ if (_mda_file->scan ->last_point > 0 )
1185+ {
1186+ iamt = std::min ((size_t )_mda_file->scan ->last_point , cols);
1187+ }
11831188 for (size_t i = 0 ; i < iamt; i++)
11841189 {
11851190 for (int k = 0 ; k < _mda_file->scan ->number_detectors ; k++)
11861191 {
1187- std::string key =std::string (_mda_file->scan ->sub_scans [0 ]->detectors [k]->name );
1188- std::string label = " " ;
1189- bool is_time_normalized = false ;
1190- if (data_struct::Scaler_Lookup::inst ()->search_pv (key, label, is_time_normalized, beamline))
1191- {
1192- key = label;
1193- }
1194- if (_scan_info.scaler_maps .contains (key) == false )
1192+ if (_mda_file->scan ->detectors [k] != nullptr )
11951193 {
1196- std::string unit = " " ;
1197- if (_mda_file->scan ->sub_scans [0 ]->detectors [k]->unit != nullptr )
1194+ if (_mda_file->scan ->detectors [k]->number != k)
11981195 {
1199- unit = std::string (_mda_file-> scan -> sub_scans [ 0 ]-> detectors [k]-> unit ) ;
1196+ break ;
12001197 }
1201- _scan_info.initialize_scaler_map_with_dims (key, rows, cols, is_time_normalized, unit);
1202- }
1198+ if (_mda_file->scan ->detectors [k]->name != nullptr )
1199+ {
1200+ std::string key =std::string (_mda_file->scan ->detectors [k]->name );
1201+ std::string label = " " ;
1202+ bool is_time_normalized = false ;
1203+ if (data_struct::Scaler_Lookup::inst ()->search_pv (key, label, is_time_normalized, beamline))
1204+ {
1205+ key = label;
1206+ }
1207+ if (_scan_info.scaler_maps .contains (key) == false )
1208+ {
1209+ std::string unit = " " ;
1210+ if (_mda_file->scan ->detectors [k]->unit != nullptr )
1211+ {
1212+ unit = std::string (_mda_file->scan ->detectors [k]->unit );
1213+ }
1214+ _scan_info.initialize_scaler_map_with_dims (key, rows, cols, is_time_normalized, unit);
1215+ }
12031216
1204- if (std::isfinite (_mda_file->scan ->detectors_data [k][i]))
1205- {
1206- _scan_info.scaler_maps .at (key)->values (0 , i) = _mda_file->scan ->detectors_data [k][i];
1217+ if (std::isfinite (_mda_file->scan ->detectors_data [k][i]))
1218+ {
1219+ _scan_info.scaler_maps .at (key)->values (0 , i) = _mda_file->scan ->detectors_data [k][i];
1220+ }
1221+ }
12071222 }
12081223 }
12091224
@@ -1277,29 +1292,32 @@ void MDA_IO<T_real>::_load_scalers(bool load_int_spec, bool hasNetCDF, bool subt
12771292 {
12781293 for (int k = 0 ; k < _mda_file->scan ->sub_scans [i]->number_detectors ; k++)
12791294 {
1280- if (_mda_file->scan ->sub_scans [0 ]->detectors [k]-> name != nullptr )
1295+ if (_mda_file->scan ->sub_scans [0 ]->detectors [k] != nullptr )
12811296 {
1282- std::string key = std::string (_mda_file->scan ->sub_scans [i]->detectors [k]->name );
1283- std::string label = " " ;
1284- bool is_time_normalized = false ;
1285- if (data_struct::Scaler_Lookup::inst ()->search_pv (key, label, is_time_normalized, beamline))
1297+ if (_mda_file->scan ->sub_scans [0 ]->detectors [k]->number == k && _mda_file->scan ->sub_scans [0 ]->detectors [k]->name != nullptr )
12861298 {
1287- key = label;
1288- }
1299+ std::string key = std::string (_mda_file->scan ->sub_scans [i]->detectors [k]->name );
1300+ std::string label = " " ;
1301+ bool is_time_normalized = false ;
1302+ if (data_struct::Scaler_Lookup::inst ()->search_pv (key, label, is_time_normalized, beamline))
1303+ {
1304+ key = label;
1305+ }
12891306
1290- if (i == 0 && j == 0 )
1291- {
1292- std::string unit = " " ;
1293- if (_mda_file->scan ->sub_scans [i]->detectors [k]->unit != nullptr )
1307+ if (i == 0 && j == 0 )
12941308 {
1295- unit = std::string (_mda_file->scan ->sub_scans [i]->detectors [k]->unit );
1309+ std::string unit = " " ;
1310+ if (_mda_file->scan ->sub_scans [i]->detectors [k]->unit != nullptr )
1311+ {
1312+ unit = std::string (_mda_file->scan ->sub_scans [i]->detectors [k]->unit );
1313+ }
1314+ _scan_info.initialize_scaler_map_with_dims (key, rows, cols, is_time_normalized, unit);
1315+ }
1316+
1317+ if (_scan_info.scaler_maps .contains (key) && std::isfinite (_mda_file->scan ->sub_scans [i]->detectors_data [k][j]))
1318+ {
1319+ _scan_info.scaler_maps .at (key)->values (i, j) = _mda_file->scan ->sub_scans [i]->detectors_data [k][j];
12961320 }
1297- _scan_info.initialize_scaler_map_with_dims (key, rows, cols, is_time_normalized, unit);
1298- }
1299-
1300- if (_scan_info.scaler_maps .contains (key) && std::isfinite (_mda_file->scan ->sub_scans [i]->detectors_data [k][j]))
1301- {
1302- _scan_info.scaler_maps .at (key)->values (i, j) = _mda_file->scan ->sub_scans [i]->detectors_data [k][j];
13031321 }
13041322 }
13051323 }
0 commit comments