def test_size(self): size = 17 peak_array = np.zeros(shape=(3, 2, 3, 2)) s = Diffraction2D(np.zeros(shape=(3, 2, 10, 10))) mt.add_peak_array_to_signal_as_markers(s, peak_array, size=size) marker = list(s.metadata.Markers)[0][1] assert marker.get_data_position("size") == size
def test_color(self): color = "blue" peak_array = np.zeros(shape=(3, 2, 3, 2)) s = Diffraction2D(np.zeros(shape=(3, 2, 10, 10))) mt.add_peak_array_to_signal_as_markers(s, peak_array, color=color) marker = list(s.metadata.Markers)[0][1] assert marker.marker_properties["color"] == color
def _add_peak_dicts_to_signal( signal, peak_dicts, color_centre="red", color_rest="blue", color_none="cyan", size=20, ): """Visualize the results of peak_dicts through markers in a Signal. Parameters ---------- signal : HyperSpy Signal2D, PixelatedSTEM peak_dicts : dicts color_centre, color_rest, color_none : string, optional Color of the markers. Default 'red', 'blue', 'cyan'. size : scalar, optional Size of the markers. Default 20 Example ------- >>> peak_dicts = {} >>> peak_dicts['centre'] = np.random.randint(99, size=(2, 3, 10, 2)) >>> peak_dicts['rest'] = np.random.randint(99, size=(2, 3, 3, 2)) >>> peak_dicts['none'] = np.random.randint(99, size=(2, 3, 2, 2)) >>> s = pxm.signals.Diffraction2D(np.random.random((2, 3, 100, 100))) >>> import pyxem.utils.cluster_tools as ct >>> ct._add_peak_dicts_to_signal(s, peak_dicts) >>> s.plot() """ mt.add_peak_array_to_signal_as_markers(signal, peak_dicts["centre"], color=color_centre, size=size) mt.add_peak_array_to_signal_as_markers(signal, peak_dicts["rest"], color=color_rest, size=size) mt.add_peak_array_to_signal_as_markers(signal, peak_dicts["none"], color=color_none, size=size)
def test_simple(self): peak_array = np.zeros(shape=(3, 2, 3, 2)) s = Diffraction2D(np.zeros(shape=(3, 2, 10, 10))) mt.add_peak_array_to_signal_as_markers(s, peak_array) assert len(s.metadata.Markers) == 3