def test_load_dm(self): filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF.dm3") stack = tomotools.load(filename) assert stack.axes_manager[0].name == 'Tilt' assert stack.axes_manager[0].offset == -90.0 assert stack.axes_manager.signal_shape == (64, 64) assert stack.axes_manager.navigation_shape == (91,)
def test_load_hspy(self): filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF.mrc") stack = tomotools.load(filename) assert type(stack) is TomoStack assert stack.axes_manager.signal_shape == (256, 256) assert stack.axes_manager.navigation_shape == (77,) assert stack.__repr__()[0:10] == '<TomoStack'
def test_register_ecc(self): filename = os.path.join(my_path, "test_data", "HAADF.mrc") stack = tomotools.load(filename) reg = stack.inav[0:20].stack_register('ECC') assert type(reg) is tomotools.TomoStack assert reg.axes_manager.signal_shape == \ stack.inav[0:20].axes_manager.signal_shape assert reg.axes_manager.navigation_shape == \ stack.inav[0:20].axes_manager.navigation_shape
def get_needle_data(aligned=False): """ Retrieve experimental tilt series of needle-shaped specimen. Returns ---------- needle : TomoStack object TomoStack containing the simulated catalyst tilt series """ if aligned: filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF_Aligned.hdf5") needle =\ tomotools.load(filename) else: filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF.mrc") needle =\ tomotools.load(filename) return needle
def get_catalyst_tilt_series(misalign=False, minshift=-5, maxshift=5, tiltshift=0, tiltrotate=0, xonly=False, noise=False, noise_factor=0.2): """ Retrieve model catalyst tilt series. Arguments ---------- misalign : bool If True, apply random shifts to each projection to simulated drift minshift : float Lower bound for random shifts maxshift : float Upper bound for random shifts tiltshift : float Number of pixels by which to shift entire tilt series. Simulates offset tilt axis. rotate : float Angle by which to rotate entire tilt series. Simulates non-vertical tilt axis. xonly : bool If True, shifts are only applied along the X-axis noise : bool If True, add Gaussian noise to the stack noise_factor : float Percentage noise to be added. Must be between 0 and 1. Returns ---------- catalyst : TomoStack object TomoStack containing the simulated catalyst tilt series """ filename = os.path.join(tomotools_path, "tests", "test_data", "Catalyst3DModel_TiltSeries180.hdf5") catalyst =\ tomotools.load(filename) if misalign: catalyst = misalign_stack(catalyst, min_shift=minshift, max_shift=maxshift, tilt_shift=tiltshift, tilt_rotate=tiltrotate, x_only=xonly) if noise: catalyst = add_gaussian_noise(catalyst, noise_factor) return catalyst
def test_signal_to_stack_with_tiltsignal(self): filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF.mrc") tilt_signal = tomotools.load(filename) tilt_signal.set_tilts(-76, 2) signal = hs.signals.Signal2D(np.random.random([77, 100, 100])) stack = tomotools.io.signal_to_tomo_stack(signal, tilt_signal=tilt_signal) assert stack.axes_manager[0].name == 'Tilt' assert stack.axes_manager.signal_shape == (100, 100) assert stack.axes_manager.navigation_shape == (77,) assert stack.axes_manager[0].axis.all() == \ tilt_signal.axes_manager[0].axis.all()
def test_load_unknown(self): filename = os.path.join(tomotools_path, "tests", "test_data", "HAADF.NONE") with pytest.raises(ValueError): tomotools.load(filename)