def test_get_simple_cubic_signal(self): s0 = dd.get_simple_cubic_signal() s0.plot() s1 = dd.get_simple_cubic_signal(image_noise=False) s1.plot() s2 = dd.get_simple_cubic_signal(image_noise=True) s2.plot()
def test_pca_subtract_background_normalize_intensity(self): s = dd.get_simple_cubic_signal() s_fs = afr.get_feature_separation(s, pca=True, subtract_background=True, normalize_intensity=True) assert hasattr(s_fs, 'data')
def test_detector_normalisation(self): det_image = get_detector_image_signal() img = get_simple_cubic_signal(image_noise=True) img = (img) * 300000 + 4000 image_normalised = quant.detector_normalisation(img, det_image, 60) assert image_normalised.data.max() < 1 assert image_normalised.data.shape == img.data.shape
def test_separation_step(self): sr0, sr1, s_step = 10, 16, 2 s = dd.get_simple_cubic_signal() s_fs = afr.get_feature_separation(s, separation_range=(sr0, sr1), separation_step=s_step) assert s_fs.axes_manager.navigation_size == ((sr1 - sr0) / s_step)
def test_dtypes(self): dtype_list = [ 'float64', 'float32', 'uint64', 'uint32', 'uint16', 'uint8', 'int64', 'int32', 'int16', 'int8' ] s = dd.get_simple_cubic_signal() s *= 10**9 for dtype in dtype_list: print(dtype) s.change_dtype(dtype) afr.get_feature_separation(s, separation_range=(10, 15)) s.change_dtype('float16') with pytest.raises(ValueError): afr.get_feature_separation(s, separation_range=(10, 15))
overwrite=True) def plot_planes_figure(sublattice): s = sublattice.get_all_atom_planes_by_zone_vector() s.plot() s.axes_manager.indices = (1, ) s._plot.signal_plot.figure.savefig(os.path.join(my_path, 'zone_axes_sig.png'), overwrite=True) s._plot.navigator_plot.figure.savefig(os.path.join(my_path, 'zone_axes_nav.png'), overwrite=True) s = dummy_data.get_simple_cubic_signal(image_noise=True) save_simple_cubic_image(s) save_s_peaks_image(s) atom_positions = am.get_atom_positions(s, separation=7) sublattice = am.Sublattice(atom_positions, image=s.data) sublattice.find_nearest_neighbors() sublattice.refine_atom_positions_using_center_of_mass() sublattice.refine_atom_positions_using_2d_gaussian() plot_position_history(sublattice) sublattice.construct_zone_axes() plot_planes_figure(sublattice)
def test_inverted_signal(self): s = dd.get_simple_cubic_signal() amm.run_image_filtering(s, invert_signal=True)
def test_standard(self): s = dd.get_simple_cubic_signal() amm.run_image_filtering(s)
def test_find_no_peaks(self): s = dd.get_simple_cubic_signal().isig[:5., :5.] with pytest.raises(ValueError): afr.get_feature_separation(s)
def test_small_input_size_large_separation_range(self): # For small images and large separation, no peaks can be returned. # This test checks that this doesn't result in an error. s = dd.get_simple_cubic_signal().isig[:50., :50.] afr.get_feature_separation(s)
def test_separation_range_bad(self, separation_range): s = dd.get_simple_cubic_signal() with pytest.raises(ValueError): afr.get_feature_separation(s, separation_range)
def test_too_low_separation_low(self, separation_low): separation_range = (separation_low, 3) s = dd.get_simple_cubic_signal() with pytest.raises(ValueError): afr.get_feature_separation(s, separation_range)
def test_separation_range(self): sr0, sr1 = 10, 15 s = dd.get_simple_cubic_signal() s_fs = afr.get_feature_separation(s, separation_range=(sr0, sr1)) assert s_fs.axes_manager.navigation_size == (sr1 - sr0) assert s_fs.axes_manager.navigation_extent == (sr0, sr1 - 1)
def test_simple(self): s = dd.get_simple_cubic_signal() s_fs = afr.get_feature_separation(s) s_fs.plot()
def test_too_low_separation(self, separation): s = dd.get_simple_cubic_signal() with pytest.raises(ValueError): afr.get_atom_positions(s, separation)