From 6ec1b22a97fb70adfccc53a9d5dc05129dc4041c Mon Sep 17 00:00:00 2001 From: Ajith Pattammattel Date: Fri, 9 May 2025 10:50:24 -0400 Subject: [PATCH 1/2] hxn_panda_scan_loading_updated --- .DS_Store | Bin 6148 -> 6148 bytes pyxrf/.DS_Store | Bin 0 -> 8196 bytes pyxrf/gui_module/.DS_Store | Bin 0 -> 6148 bytes pyxrf/model/load_data_from_db.py | 71 ++++++++++++++++++++++--------- 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 pyxrf/.DS_Store create mode 100644 pyxrf/gui_module/.DS_Store diff --git a/.DS_Store b/.DS_Store index ca2b7874ee44cef1857d5487e8c8184223131c55..882d103d71b02cb19f31c2088f1b5ccb860fe058 100644 GIT binary patch delta 303 zcmZoMXfc=|#>B)qu~3YagMop8V`8BQClinX0?Zo&b~7?EPt=jFXJsg0sAQ;MC}K!U zDlaZb%E?axD%hD+kds+lVqkEMk%^gwm5rT)or9YrHaH`{Jh&vWq_o&6u_zkE3(3#V zNrJHxlfp7n%i{$^ob&Ta5;OBsi@+K(Q&NFSV!|`?Qu524@=Nnliotq=ffDgR84gYk z&UgXI>S|+SGjkmUQ#12g9ffL3BLf`;6JxX5T22m8Wqs?Q`0SkAy!>vk2N)O`Av6Oo yl!j3~Kn9YZHbyY9PBsu>*~|@eKQK5p7Jg@*%rBzI3JMB^$%Z1*n*&6)FarQ7TuOof delta 77 zcmZoMXfc=|#>AjHu~3+iaWW5+G$#`S1Tbz4*v+_Ef%!Sh#s*Qw&Fmcf96)uO1)0Ay ZPv#d<4% zLTog?C>r&}2Nf@`Mxzg!K$Q4kB2PZx#)t{NnE0ZJ=%X>w|IC>sY=H+8Vn~>iob%5) z=l{>;JKsMi{|sXcgGF-_V{MEvm9mh05fyhyqF>}Yk`lGllLXl_=H$x$Y|im=cj(3q zF#<6HF#<6HF#<6H4+a8sXN#oXYySF0Z57v zAWZa3aX@I3jASa3b5e$;G^UIm5SbzhF(A#UKPl8nrXo2fr8H-d<_yuyh$0k(vy)vi zRA)#@8J95vF#>lYAl#>c%`lId%&LjsFXd((+YfqrzK2p*->_hzx=>xD9#5b0%IP2* z6#c<$;i#yMd7hK2K4)`BY^$8%ONTr+$l9(|2n}r0B9&tkwrhIjL9ghVerTJP9jc~k z8Qy;G+~(dbTf38e{oBrWC(mu`?deW#+1!8ryrwSe*tp|x=Cm{8dN0deAbJz9#(BHC zP`f3^FAd305_QehE&Wj4lBO>*#*a+s8QxN&b&t*lw&(gstb$K6!<&5C-~PPk9x7O( zeewiR&%K(utDo+d0P?FWY8tYAWmJE!VW& zlhXvA8`vjotDrTbTOD(=GggJSE^lj37{+|<>L`=Noc&DE4$krpRju$PO^vHo8~QPm z*7SsDiqTB|nW}|79jguFsOT9gSX7#kLFYO{AMMrEC5bIR5H;>-(T&NxH#0+9@uRlgDZ_Y5OnWfv2cxr=OG~;M%{@$g z)BdS!!5S?SyQ0>8)EXWawF{#W(+<3_lh8OwyO`(SL>d}ZMa5N)DynvQ_y8Z`GQPlXim%fzqUKrA0B6wMwVb zqx31e9br*FvF8m5Pw4NrL<-zuROtiJPrRVlA;#aB~Ctu@&2}9Xm0C zJ=ll+#M3d1V*-_K=&d7=ajp2ND6)52uF* zX=(R*-HKQ{N%?8YA_=`YDMJ$~!f>2q7><*?^}~>!lcXwaQjwgKl3FPJ?;ir<`#-+_ JL*_l)#lNH&7cu|< literal 0 HcmV?d00001 diff --git a/pyxrf/gui_module/.DS_Store b/pyxrf/gui_module/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..51227d71a94e52683c4d00d01ac912a7dfa75f3b GIT binary patch literal 6148 zcmeHKI|>3p3{CuiU}I@HSMUad=n3`$7K)81_^Y?_TprDrPoXS!S|~4&yqQeiEc=Sh zMnrUeSOjyq1*=D6P-_S;VFyM%Fva+Zyp5TE&WLZbpy zfC^9nDnJE3tw46z(fHFB^FAs-1%6%u`#u!7VNGlU{nLTqBLHxKv>VnwO8|={fHkoV zL$0gG>bW2DSK<@<*e5h_zG?{ceokWPC@W?4D@!4jkV*c7e!sMHO^~d U8|ZZ8oet#BfayY`0^e5P0W;M1& literal 0 HcmV?d00001 diff --git a/pyxrf/model/load_data_from_db.py b/pyxrf/model/load_data_from_db.py index 8c5ed752..87033c2f 100644 --- a/pyxrf/model/load_data_from_db.py +++ b/pyxrf/model/load_data_from_db.py @@ -786,8 +786,18 @@ def map_data2D_hxn( start_doc = hdr["start"] logger.info("Plan type: '%s'", start_doc["plan_type"]) + if "scan" in start_doc: + #print(" panda scan ") + plan_type = start_doc["scan"]["type"] + + else: + plan_type = start_doc["plan_type"] + + + # Exclude certain types of plans based on data from the start document - if isinstance(skip_scan_types, (list, tuple)) and (start_doc["plan_type"] in skip_scan_types): + #later change to look for 1D scan based on motor length + if isinstance(skip_scan_types, (list, tuple)) and plan_type in skip_scan_types: raise RuntimeError( f"Failed to load the scan: plan type {start_doc['plan_type']!r} is in the list of skipped types" ) @@ -888,7 +898,11 @@ def map_data2D_hxn( # Determine fast axis and slow axis fast_axis, slow_axis, fast_axis_index = start_doc.get("fast_axis", None), None, None motors = start_doc.get("motors", None) - if motors and isinstance(motors, (list, tuple)) and len(motors) == 2: + if motors and isinstance(motors, (list, tuple)) and len(motors) == 1: + fast_axis = fast_axis if fast_axis else motors[0] + fast_axis_index = motors.index(fast_axis, 0) + + elif motors and isinstance(motors, (list, tuple)) and len(motors) == 2: fast_axis = fast_axis if fast_axis else motors[0] fast_axis_index = motors.index(fast_axis, 0) slow_axis_index = 0 if (fast_axis_index == 1) else 1 @@ -930,7 +944,7 @@ def map_data2D_hxn( keylist = hdr.descriptors[0].data_keys.keys() det_list = [v for v in keylist if "xspress3" in v] # find xspress3 det with key word matching - + det_list = [v for v in det_list if len(v)==12] #added to filter out other rois added by user scaler_list_all = config_data["scaler_list"] all_keys = hdr.descriptors[0].data_keys.keys() @@ -938,27 +952,46 @@ def map_data2D_hxn( fields = det_list + scaler_list + pos_list - # Do not use supply 'fields' if Databroker V0 is used - if isinstance(db, databroker._core.Broker): - fields = None + try: # load data with hdf5, faster + data_out = map_data2D_HDF5( + hdr, + datashape, + det_list=det_list, + pos_list=pos_list, + scaler_list=scaler_list, + create_each_det=create_each_det, + fly_type=fly_type, + subscan_dims=subscan_dims, + spectrum_len=4096, + ) - data = hdr.table(fields=fields, fill=True) + except Exception as err: + raise err + # Do not use supply 'fields' if Databroker V0 is used + if isinstance(db, databroker._core.Broker): + fields = None # This is for the case of 'dcan' (1D), where the slow axis positions are not saved if (slow_axis not in data) and (fast_axis in data): data[slow_axis] = np.zeros(shape=data[fast_axis].shape) - data_out = map_data2D( - data, - datashape, - det_list=det_list, - pos_list=pos_list, - scaler_list=scaler_list, - create_each_det=create_each_det, - fly_type=fly_type, - subscan_dims=subscan_dims, - spectrum_len=4096, - ) + data = hdr.table(fields=fields, fill=True) + + # This is for the case of 'dcan' (1D), where the slow axis positions are not saved + if (slow_axis not in data) and (fast_axis in data): + data[slow_axis] = np.zeros(shape=data[fast_axis].shape) + + data_out = map_data2D( + data, + datashape, + det_list=det_list, + pos_list=pos_list, + scaler_list=scaler_list, + create_each_det=create_each_det, + fly_type=fly_type, + subscan_dims=subscan_dims, + spectrum_len=4096, + ) # Transform coordinates for the fast axis if necessary: # Flip the direction of the fast axis for certain angles @@ -967,7 +1000,7 @@ def map_data2D_hxn( data_out["pos_data"][fast_axis_index, :, :] = np.fliplr(data_out["pos_data"][fast_axis_index, :, :]) data_out["scaler_data"] = np.flip(data_out["scaler_data"], axis=1) data_out["det_sum"] = np.flip(data_out["det_sum"], axis=1) - for k in data.keys(): + for k in hdr.table().keys(): if re.search(r"^det[\d]+$", k): # Individual detectors such as 'det1', 'det2', etc. data_out[k] = np.flip(data_out[k], axis=1) else: From 421bc98673daebb1ef1df0fac82b95f27492dd7d Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Sat, 10 May 2025 12:28:02 -0400 Subject: [PATCH 2/2] Formatting with 'black' --- pyxrf/model/load_data_from_db.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pyxrf/model/load_data_from_db.py b/pyxrf/model/load_data_from_db.py index 87033c2f..c10899c4 100644 --- a/pyxrf/model/load_data_from_db.py +++ b/pyxrf/model/load_data_from_db.py @@ -787,16 +787,14 @@ def map_data2D_hxn( logger.info("Plan type: '%s'", start_doc["plan_type"]) if "scan" in start_doc: - #print(" panda scan ") + # print(" panda scan ") plan_type = start_doc["scan"]["type"] else: plan_type = start_doc["plan_type"] - - # Exclude certain types of plans based on data from the start document - #later change to look for 1D scan based on motor length + # later change to look for 1D scan based on motor length if isinstance(skip_scan_types, (list, tuple)) and plan_type in skip_scan_types: raise RuntimeError( f"Failed to load the scan: plan type {start_doc['plan_type']!r} is in the list of skipped types" @@ -944,7 +942,7 @@ def map_data2D_hxn( keylist = hdr.descriptors[0].data_keys.keys() det_list = [v for v in keylist if "xspress3" in v] # find xspress3 det with key word matching - det_list = [v for v in det_list if len(v)==12] #added to filter out other rois added by user + det_list = [v for v in det_list if len(v) == 12] # added to filter out other rois added by user scaler_list_all = config_data["scaler_list"] all_keys = hdr.descriptors[0].data_keys.keys() @@ -952,7 +950,7 @@ def map_data2D_hxn( fields = det_list + scaler_list + pos_list - try: # load data with hdf5, faster + try: # load data with hdf5, faster data_out = map_data2D_HDF5( hdr, datashape,