This part of the data analysis tutorial focuses on visualizing the intensity of specific regions of interest (ROIs) as a function of theta (angle). The following steps guide you through creating a plot of intensity versus theta using matplotlib, based on data processed by the calculate_stack_and_rois function.
Code
roi = cr.utils.ROI(left=480, right=560, top=1280, bottom=1200, name="peak_406")
run_number = 35
angles, stacks, rois = calculate_stack_and_rois(run_number, [roi],)
fig, ax = plt.subplots()
ax.plot(angles, rois[0].intensities)
ax.set_xlabel('Theta')
ax.set_ylabel('Intensity (a.u.)')
Step 1: Define the ROI
Before processing your data, define the region of interest (ROI) that you will analyze. The ROI should be specified with its left, right, top, and bottom bounds, and a name for identification:
roi = cr.utils.ROI(left=480, right=560, top=1280, bottom=1200, name="peak_406")
Step 2: Process the Data
Use the calculate_stack_and_rois function to process your data, specifying the run number and the list of ROIs you're interested in. This function returns angles, image stacks (if calculated), and the updated ROIs with intensity data:
run_number = 35 # Example run number angles, stacks, rois = calculate_stack_and_rois(run_number, [roi])
Step 3: Set Up the Plot
fig, ax = plt.subplots()
ax.plot(angles, rois[0].intensities)
ax.set_xlabel('Theta') ax.set_ylabel('Intensity (a.u.)')
# Optional: Add a plot title or customize further
ax.set_title('Intensity vs. Theta for ROI "peak_406"')
Step 6: Display the Plot
Finally, display the plot by calling plt.show(). This command is especially necessary if you're running the script outside an interactive environment like Jupyter notebooks:
plt.show()
Conclusion
By following these steps, you've created a visual representation of how the intensity within your specified ROI varies with theta
* Remember, the example values provided (e.g., ROI bounds, run number) are placeholders. Adjust these according to the specific details of your experimental data and analysis needs.