예제 #1
0
 def test_2d_gaussian_all_arguments(self):
     sublattice = Sublattice(self.xy, self.image_data)
     sublattice.find_nearest_neighbors()
     sublattice.refine_atom_positions_using_2d_gaussian(
         image_data=self.image_data,
         percent_to_nn=0.3,
         rotation_enabled=False)
예제 #2
0
 def setup_method(self):
     image_data = np.random.random(size=(100, 100))
     position_list = []
     for x in range(10, 100, 5):
         for y in range(10, 100, 5):
             position_list.append([x, y])
     sublattice = Sublattice(np.array(position_list), image_data)
     sublattice.find_nearest_neighbors()
     self.sublattice = sublattice
예제 #3
0
 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))
예제 #4
0
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
예제 #5
0
def make_atom_lattice_dumbbell_structure(
        s, position_list, dumbbell_vector, show_progressbar=True):
    """
    Make Atom_Lattice object from image of dumbbell structure.

    Parameters
    ----------
    s : HyperSpy 2D signal
    position_list : list of atomic positions
        In the form [[x0, y0], [x1, y1], [x2, y2], ...]
    dumbbell_vector : tuple
    show_progressbar : bool, default True

    Returns
    -------
    dumbbell_lattice: Atomap Dumbbell_Lattice object

    Examples
    --------
    >>> import temul.external.atomap_devel_012.api as am
    >>> import temul.external.atomap_devel_012.initial_position_finding as ipf
    >>> from temul.external.atomap_devel_012.atom_finding_refining import get_atom_positions
    >>> s = am.dummy_data.get_dumbbell_signal()
    >>> position_list = get_atom_positions(s, separation=16)
    >>> dumbbell_vector = ipf.find_dumbbell_vector(s, 4)
    >>> dumbbell_lattice = ipf.make_atom_lattice_dumbbell_structure(
    ...     s, position_list, dumbbell_vector)
    """
    dumbbell_list0, dumbbell_list1 = _get_dumbbell_arrays(
        s, position_list, dumbbell_vector,
        show_progressbar=show_progressbar)
    s_modified = do_pca_on_signal(s)
    sublattice0 = Sublattice(
        atom_position_list=dumbbell_list0,
        original_image=s.data,
        image=s_modified.data,
        color='blue')
    sublattice1 = Sublattice(
        atom_position_list=dumbbell_list1,
        original_image=s.data,
        image=s_modified.data,
        color='red')
    sublattice0.find_nearest_neighbors()
    sublattice1.find_nearest_neighbors()
    atom_lattice = Dumbbell_Lattice(
        image=sublattice0.image,
        name="Dumbbell structure",
        sublattice_list=[sublattice0, sublattice1])
    return(atom_lattice)
예제 #6
0
    def setup_method(self):
        test_data = tt.MakeTestData(520, 520)
        x, y = np.mgrid[10:510:20j, 10:510:20j]
        x, y = x.flatten(), y.flatten()
        test_data.add_atom_list(x, y)
        s = test_data.signal

        atom_positions = afr.get_atom_positions(
            signal=s,
            separation=10,
            threshold_rel=0.02,
        )
        sublattice = Sublattice(atom_position_list=atom_positions,
                                image=s.data)
        sublattice.find_nearest_neighbors()
        self.sublattice = sublattice
예제 #7
0
    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()
예제 #8
0
 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)
예제 #9
0
 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()
예제 #10
0
 def test_2d_gaussian_simple(self):
     sublattice = Sublattice(self.xy, self.image_data)
     with pytest.raises(ValueError):
         sublattice.refine_atom_positions_using_2d_gaussian()
     sublattice.find_nearest_neighbors()
     sublattice.refine_atom_positions_using_2d_gaussian()