MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / redraw_fluorescence_plot

Method redraw_fluorescence_plot

pyxrf/xanes_maps/xanes_maps_api.py:2741–2862  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2739 self.fig.canvas.flush_events()
2740
2741 def redraw_fluorescence_plot(self):
2742 self.ax_fluor_plot.clear()
2743
2744 xd_px_min, yd_px_min, xd_px_max, yd_px_max = self.pts_selected
2745
2746 if xd_px_min == xd_px_max and yd_px_min == yd_px_max:
2747 plot_single_point = True
2748 else:
2749 plot_single_point = False
2750
2751 data_stack_selected = self.stack_selected[:, yd_px_min : yd_px_max + 1, xd_px_min : xd_px_max + 1]
2752 data_selected = np.sum(np.sum(data_stack_selected, axis=2), axis=1)
2753
2754 # Apply energy shift (it influences all plots, so it should be done regardless of the rest
2755 # of the options
2756 if self.incident_energy_shift_keV == self.incident_energy_shift_keV_updated:
2757 self.energy = self.energy_original
2758 else:
2759 # Find difference between the original value of the shift (that was already
2760 # applied and the new value)
2761 de = self.incident_energy_shift_keV_updated - self.incident_energy_shift_keV
2762 # Apply the shift to energy points for the observed data
2763 self.energy = [_ + de for _ in self.energy_original]
2764
2765 # Subtract baseline if needed
2766 if (self.label_selected == self.label_default) and self.subtract_pre_edge_baseline:
2767 try:
2768 data_selected = subtract_xanes_pre_edge_baseline(
2769 data_selected, self.energy, self.label_default, non_negative=False
2770 )
2771 except RuntimeError as ex:
2772 logger.error(f"Background was not subtracted: {ex}")
2773
2774 # Fluorescence plot will display the new energy values
2775 self.ax_fluor_plot.plot(
2776 self.energy, data_selected, marker=".", linestyle="solid", label="XANES spectrum"
2777 )
2778
2779 # Save currently displayed spectrum data, so that it could be reused (e.g. saved to file)
2780 self.xanes_spectrum_selected = data_selected
2781
2782 # Plot the results of fitting (if the fitting was performed and the value for the
2783 # shift of incident energy was not changed)
2784 if (
2785 (self.label_selected == self.label_default)
2786 and (self.xanes_map_data is not None)
2787 and (self.absorption_refs is not None)
2788 and (self.ref_data is not None)
2789 and (self.ref_energy is not None)
2790 ):
2791 # The number of averaged points
2792 n_averaged_pts = (xd_px_max - xd_px_min + 1) * (yd_px_max - yd_px_min + 1)
2793
2794 plot_comments = ""
2795 if n_averaged_pts > 1:
2796 plot_comments = f"Area: {n_averaged_pts} px."
2797
2798 fit_real_time = True

Callers 4

showMethod · 0.95
redraw_imageMethod · 0.95
canvas_onreleaseMethod · 0.95

Calls 6

_interpolate_referencesFunction · 0.85
fit_spectrumFunction · 0.85
rfactor_computeFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected