def test_center_of_mass_dtypes(self): sublattice = Sublattice(self.xy, self.image_data) sublattice.find_nearest_neighbors() image_data = 127 * (self.image_data / self.image_data.max()) dtype_list = [ 'float64', 'float32', 'float16', 'int64', 'int32', 'int16', 'int8', 'uint64', 'uint32', 'uint16', 'uint8' ] for dtype in dtype_list: sublattice.refine_atom_positions_using_center_of_mass( image_data=image_data.astype(dtype))
def get_polarised_single_sublattice_rotated(image_noise=False, rotation=45): sublattice = get_polarised_single_sublattice(image_noise=image_noise) sig = sublattice.signal sig.map(scipy.ndimage.rotate, angle=rotation, reshape=False) # sig.plot() atom_positions = get_atom_positions(sig, separation=7) rot_sublattice = Sublattice(atom_positions, image=sig.data) rot_sublattice.find_nearest_neighbors() rot_sublattice.refine_atom_positions_using_center_of_mass() # rot_sublattice.plot() return rot_sublattice
def test_manual_processing(self): s_adf_filename = os.path.join(my_path, "datasets", "test_ADF_cropped.hdf5") s = load(s_adf_filename) s.change_dtype('float32') atom_positions = afr.get_atom_positions( signal=s, separation=17, threshold_rel=0.02, ) sublattice = Sublattice(atom_position_list=atom_positions, image=s.data) sublattice.find_nearest_neighbors() sublattice.refine_atom_positions_using_center_of_mass( sublattice.image, percent_to_nn=0.4) sublattice.refine_atom_positions_using_2d_gaussian(sublattice.image, percent_to_nn=0.4) Atom_Lattice(image=s.data, sublattice_list=[sublattice]) sublattice.construct_zone_axes()
def test_center_of_mass_all_arguments(self): sublattice = Sublattice(self.xy, self.image_data) sublattice.find_nearest_neighbors() sublattice.refine_atom_positions_using_center_of_mass( image_data=self.image_data, percent_to_nn=0.3)
def test_center_of_mass_simple(self): sublattice = Sublattice(self.xy, self.image_data) with pytest.raises(ValueError): sublattice.refine_atom_positions_using_center_of_mass() sublattice.find_nearest_neighbors() sublattice.refine_atom_positions_using_center_of_mass()