@@ -128,9 +128,17 @@ def export_metadata_task(run_client):
128128 nxfile .entry .instrument .manipulator .pos_act_y = nx .NXfield (np .round (values ["LT_Y" ],4 ),units = 'mm' ) # PV:XF:21IDD-ES{PRV-Ax:Y}Mtr.RBV
129129 elif user_note == "XAS scan" :
130130 primary = run_client ["primary" ].read (variables = ['PGM_Energy' , 'qem07_current1_mean_value' , 'mbs_total_intensity' ])
131- nxfile .entry .instrument .monochromator .energy_arr = nx .NXfield (np .round (primary ['PGM_Energy' ].to_numpy (),4 ), units = 'eV' )
132- nxfile .entry .instrument .monochromator .current_arr = nx .NXfield (np .round (primary ['qem07_current1_mean_value' ].to_numpy (),4 ), units = 'uA' )
133- nxfile .entry .instrument .monochromator .intensity_arr = nx .NXfield (np .round (primary ['mbs_total_intensity' ].to_numpy (),4 ))
131+
132+ # Sort the arrays according to energy levels
133+ energy_arr = primary ['PGM_Energy' ].to_numpy ()
134+ sorted_indices = np .argsort (energy_arr )
135+ energy_arr = energy_arr [sorted_indices ]
136+ current_arr = primary ['qem07_current1_mean_value' ].to_numpy ()[sorted_indices ]
137+ intensity_arr = primary ['mbs_total_intensity' ].to_numpy ()[sorted_indices ]
138+
139+ nxfile .entry .instrument .monochromator .energy_arr = nx .NXfield (np .round (energy_arr , 4 ), units = 'eV' )
140+ nxfile .entry .instrument .monochromator .current_arr = nx .NXfield (np .round (current_arr , 4 ), units = 'uA' )
141+ nxfile .entry .instrument .monochromator .intensity_arr = nx .NXfield (np .round (intensity_arr , 4 ))
134142 nxfile .entry .instrument .manipulator .pos_x = nx .NXfield (np .round (values ["LT_X" ],4 ),units = 'mm' ) # PV:XF:21IDD-ES{PRV-Ax:X}Mtr.RBV
135143 nxfile .entry .instrument .manipulator .pos_y = nx .NXfield (np .round (values ["LT_Y" ],4 ),units = 'mm' ) # PV:XF:21IDD-ES{PRV-Ax:Y}Mtr.RBV
136144 else :
0 commit comments