1
Energy Scan
szola_m edited this page 2024-04-09 10:27:07 +02:00

In this tutorial, we will focus on visualizing energy scans, showcasing how to plot intensity differences between regions of interest for comparative analysis. This process involves recalculating certain ROIs and comparing them under different conditions (e.g., warm vs. cold). Given that we've already covered how to define ROIs, process data using calculate_stack_and_rois, and create plots, we will now focus specifically on the steps relevant to this energy scan analysis.


Comparative Energy Scan Visualization

This section guides you through visualizing energy scans, particularly focusing on comparing intensity differences between specific ROIs under different conditions (labeled as "Warm" and "Cold" for illustrative purposes).

fig, ax = plt.subplots() 
roi_recalculate = cr.utils.ROI(left=2, right=4,bottom=2,top=2,name="roi_to_recalculate_things")

run_number = 46 
angles, stacks, rois = calculate_stack_and_rois(run_number, [roi, roi_peak, roi_bgr,roi_recalculate], ) 
ax.plot(angles, rois[1].intensities - rois[2].intensities ,'-o',label='Warm') 

run_number = 44 
angles, stacks, rois = calculate_stack_and_rois(run_number, [roi, roi_peak, roi_bgr,roi_recalculate], )
ax.plot(angles, rois[1].intensities - rois[2].intensities ,'-o',label='Cold') 

plt.legend() 
ax.set_ylabel("Intensity in ROI (a.u.) (orange roi - the green one)") 
ax.set_xlabel("Energy (eV)") 
ax.set_title(f"Run {run_number}: Escan of the (405) candidate - Warm & Cold")

Preparing Data

Begin by recalculating your ROIs for the energy scan analysis. Here, you will specify additional ROIs, including those for background subtraction or comparison under different experimental conditions:

roi_recalculate = cr.utils.ROI(left=2, right=4, bottom=2, top=2, name="roi_to_recalculate_things")

Step 1: Analyze Data for Different Runs

Perform data processing for each run of interest. Here, we're considering two runs (46 and 44) to represent "Warm" and "Cold" conditions, respectively:

# Process data for "Warm" condition (Run 46)
run_number = 46
angles, stacks, rois = calculate_stack_and_rois(run_number, [roi, roi_peak, roi_bgr,roi_recalculate], ) 

# Process data for "Cold" condition (Run 44)
run_number = 44
angles, stacks, rois = calculate_stack_and_rois(run_number, [roi, roi_peak, roi_bgr,roi_recalculate], )

Step 2: Set Up Comparative Plots

Create a subplot for visualizing the intensity differences between your conditions across varying energies:

fig, ax = plt.subplots()

Step 3: Plot Intensity Differences

For both conditions, plot the intensity difference between specified ROIs. Add labels to distinguish between the conditions:

# Plot for "Warm" condition 
ax.plot(angles[44], rois[46][1].intensities - rois[46][2].intensities, '-o', label='Warm') 

# Plot for "Cold" condition 
ax.plot(angles[44], rois[44][1].intensities - rois[44][2].intensities, '-o', label='Cold')

Ensure to add a legend to your plot to help differentiate between the "Warm" and "Cold" data sets:

plt.legend()

Conclusion

By following these steps, you've created a comparative visualization of energy scans, highlighting the intensity differences between ROIs under "Warm" and "Cold" conditions.

Remember, the example run numbers, ROI definitions, and labels ("Warm" and "Cold") used here are illustrative. You'll need to adjust these.