def plot_best_matching_results_on_signal(self, signal, library, permanent_markers=True, *args, **kwargs): """Plot the best matching diffraction vectors on a signal. Parameters ---------- signal : ElectronDiffraction2D The ElectronDiffraction2D signal object on which to plot the peaks. This signal must have the same navigation dimensions as the peaks. library : DiffractionLibrary Diffraction library containing the phases and rotations permanent_markers : bool Permanently save the peaks as markers on the signal *args : Arguments passed to signal.plot() **kwargs : Keyword arguments passed to signal.plot() """ match_peaks = self.map(peaks_from_best_template, library=library, inplace=False) mmx, mmy = generate_marker_inputs_from_peaks(match_peaks) signal.plot(*args, **kwargs) for mx, my in zip(mmx, mmy): m = hs.markers.point(x=mx, y=my, color='red', marker='x') signal.add_marker(m, plot_marker=True, permanent=permanent_markers)
def plot_best_matching_results_on_signal(self, signal, permanent_markers=True, *args, **kwargs): """Plot the best matching diffraction vectors on a signal. Parameters ---------- signal : ElectronDiffraction2D The ElectronDiffraction2D signal object on which to plot the peaks. This signal must have the same navigation dimensions as the peaks. permanent_markers : bool Permanently save the peaks as markers on the signal. Default True. *args : Arguments passed to signal.plot() **kwargs : Keyword arguments passed to signal.plot() """ match_peaks = self.vectors mmx, mmy = generate_marker_inputs_from_peaks(match_peaks) signal.plot(*args, **kwargs) for mx, my in zip(mmx, mmy): m = hs.markers.point(x=mx, y=my, color="red", marker="x") signal.add_marker(m, plot_marker=True, permanent=permanent_markers)
def local_plotter(dp, dp_cord_list): peaks = hs.signals.Signal2D(np.array([dp_cord_list[0:2], dp_cord_list[2:]])) mmx, mmy = generate_marker_inputs_from_peaks(peaks) dp.plot(cmap='viridis') for mx, my in zip(mmx, mmy): m = hs.markers.point(x=mx, y=my, color='red', marker='x') dp.add_marker(m, plot_marker=True, permanent=True) return None
def plot_diffraction_vectors_on_signal(self, signal, *args, **kwargs): """Plot the diffraction vectors on a signal. Parameters ---------- signal : ElectronDiffraction2D The ElectronDiffraction2D signal object on which to plot the peaks. This signal must have the same navigation dimensions as the peaks. *args : Arguments passed to signal.plot() **kwargs : Keyword arguments passed to signal.plot() """ mmx, mmy = generate_marker_inputs_from_peaks(self) signal.plot(*args, **kwargs) for mx, my in zip(mmx, mmy): m = markers.point(x=mx, y=my, color='red', marker='x') signal.add_marker(m, plot_marker=True, permanent=False)
def test_visuals(): # This functions will need to abuse globals. # & Can be removed if we trust the other tests from pyxem.utils.sim_utils import peaks_from_best_template from pyxem.utils.plot import generate_marker_inputs_from_peaks import hyperspy.api as hs peaks = match_results.map(peaks_from_best_template, library=library, inplace=False) mmx, mmy = generate_marker_inputs_from_peaks(peaks) dp.set_diffraction_calibration(2 / 144) dp.plot(cmap='viridis') for mx, my in zip(mmx, mmy): m = hs.markers.point(x=mx, y=my, color='red', marker='x') dp.add_marker(m, plot_marker=True, permanent=True) # Hand checking again assert True
def plot_best_matching_results_on_signal(self, signal, phase_names, library, diffraction_generator, reciprocal_radius, permanent_markers=True, *args, **kwargs): """Plot the best matching diffraction vectors on a signal. Parameters ---------- signal : ElectronDiffraction The ElectronDiffraction signal object on which to plot the peaks. This signal must have the same navigation dimensions as the peaks. phase_names : list List of phase names used as keys to the library library : DiffractionLibrary Diffraction library containing the phases and rotations diffraction_generator : DiffractionGenerator Diffraction generator used to generate the patterns reciprocal_radius : float The maximum radius of the sphere of reciprocal space to sample, in reciprocal angstroms. permanent_markers : bool Permanently save the peaks as markers on the signal. Default True. *args : Arguments passed to signal.plot() **kwargs : Keyword arguments passed to signal.plot() """ match_peaks = self.map(peaks_from_best_vector_match, phase_names=phase_names, library=library, diffraction_generator=diffraction_generator, reciprocal_radius=reciprocal_radius, inplace=False) mmx, mmy = generate_marker_inputs_from_peaks(match_peaks) signal.plot(*args, **kwargs) for mx, my in zip(mmx, mmy): m = hs.markers.point(x=mx, y=my, color='red', marker='x') signal.add_marker(m, plot_marker=True, permanent=permanent_markers)