@@ -786,8 +786,18 @@ def map_data2D_hxn(
786786 start_doc = hdr ["start" ]
787787 logger .info ("Plan type: '%s'" , start_doc ["plan_type" ])
788788
789+ if "scan" in start_doc :
790+ #print(" panda scan ")
791+ plan_type = start_doc ["scan" ]["type" ]
792+
793+ else :
794+ plan_type = start_doc ["plan_type" ]
795+
796+
797+
789798 # Exclude certain types of plans based on data from the start document
790- if isinstance (skip_scan_types , (list , tuple )) and (start_doc ["plan_type" ] in skip_scan_types ):
799+ #later change to look for 1D scan based on motor length
800+ if isinstance (skip_scan_types , (list , tuple )) and plan_type in skip_scan_types :
791801 raise RuntimeError (
792802 f"Failed to load the scan: plan type { start_doc ['plan_type' ]!r} is in the list of skipped types"
793803 )
@@ -888,7 +898,11 @@ def map_data2D_hxn(
888898 # Determine fast axis and slow axis
889899 fast_axis , slow_axis , fast_axis_index = start_doc .get ("fast_axis" , None ), None , None
890900 motors = start_doc .get ("motors" , None )
891- if motors and isinstance (motors , (list , tuple )) and len (motors ) == 2 :
901+ if motors and isinstance (motors , (list , tuple )) and len (motors ) == 1 :
902+ fast_axis = fast_axis if fast_axis else motors [0 ]
903+ fast_axis_index = motors .index (fast_axis , 0 )
904+
905+ elif motors and isinstance (motors , (list , tuple )) and len (motors ) == 2 :
892906 fast_axis = fast_axis if fast_axis else motors [0 ]
893907 fast_axis_index = motors .index (fast_axis , 0 )
894908 slow_axis_index = 0 if (fast_axis_index == 1 ) else 1
@@ -930,35 +944,54 @@ def map_data2D_hxn(
930944
931945 keylist = hdr .descriptors [0 ].data_keys .keys ()
932946 det_list = [v for v in keylist if "xspress3" in v ] # find xspress3 det with key word matching
933-
947+ det_list = [ v for v in det_list if len ( v ) == 12 ] #added to filter out other rois added by user
934948 scaler_list_all = config_data ["scaler_list" ]
935949
936950 all_keys = hdr .descriptors [0 ].data_keys .keys ()
937951 scaler_list = [v for v in scaler_list_all if v in all_keys ]
938952
939953 fields = det_list + scaler_list + pos_list
940954
941- # Do not use supply 'fields' if Databroker V0 is used
942- if isinstance (db , databroker ._core .Broker ):
943- fields = None
955+ try : # load data with hdf5, faster
956+ data_out = map_data2D_HDF5 (
957+ hdr ,
958+ datashape ,
959+ det_list = det_list ,
960+ pos_list = pos_list ,
961+ scaler_list = scaler_list ,
962+ create_each_det = create_each_det ,
963+ fly_type = fly_type ,
964+ subscan_dims = subscan_dims ,
965+ spectrum_len = 4096 ,
966+ )
944967
945- data = hdr .table (fields = fields , fill = True )
968+ except Exception as err :
969+ raise err
970+ # Do not use supply 'fields' if Databroker V0 is used
971+ if isinstance (db , databroker ._core .Broker ):
972+ fields = None
946973
947974 # This is for the case of 'dcan' (1D), where the slow axis positions are not saved
948975 if (slow_axis not in data ) and (fast_axis in data ):
949976 data [slow_axis ] = np .zeros (shape = data [fast_axis ].shape )
950977
951- data_out = map_data2D (
952- data ,
953- datashape ,
954- det_list = det_list ,
955- pos_list = pos_list ,
956- scaler_list = scaler_list ,
957- create_each_det = create_each_det ,
958- fly_type = fly_type ,
959- subscan_dims = subscan_dims ,
960- spectrum_len = 4096 ,
961- )
978+ data = hdr .table (fields = fields , fill = True )
979+
980+ # This is for the case of 'dcan' (1D), where the slow axis positions are not saved
981+ if (slow_axis not in data ) and (fast_axis in data ):
982+ data [slow_axis ] = np .zeros (shape = data [fast_axis ].shape )
983+
984+ data_out = map_data2D (
985+ data ,
986+ datashape ,
987+ det_list = det_list ,
988+ pos_list = pos_list ,
989+ scaler_list = scaler_list ,
990+ create_each_det = create_each_det ,
991+ fly_type = fly_type ,
992+ subscan_dims = subscan_dims ,
993+ spectrum_len = 4096 ,
994+ )
962995
963996 # Transform coordinates for the fast axis if necessary:
964997 # Flip the direction of the fast axis for certain angles
@@ -967,7 +1000,7 @@ def map_data2D_hxn(
9671000 data_out ["pos_data" ][fast_axis_index , :, :] = np .fliplr (data_out ["pos_data" ][fast_axis_index , :, :])
9681001 data_out ["scaler_data" ] = np .flip (data_out ["scaler_data" ], axis = 1 )
9691002 data_out ["det_sum" ] = np .flip (data_out ["det_sum" ], axis = 1 )
970- for k in data .keys ():
1003+ for k in hdr . table () .keys ():
9711004 if re .search (r"^det[\d]+$" , k ): # Individual detectors such as 'det1', 'det2', etc.
9721005 data_out [k ] = np .flip (data_out [k ], axis = 1 )
9731006 else :
0 commit comments