Пример #1
0
 def test_wrong_size(self):
     atom0, atom1 = ap.Atom_Position(5, 0), ap.Atom_Position(0, 5)
     atom2, atom3 = ap.Atom_Position(5, 10), ap.Atom_Position(10, 5)
     atom4 = ap.Atom_Position(10, 10)
     with pytest.raises(ValueError):
         to.get_point_between_four_atoms(
             (atom0, atom1, atom2, atom3, atom4))
def get_neighbor_middle_position(atom, za0, za1):
    """Find the middle point between four neighboring atoms.

    The neighbors are found by moving one step along the atom planes
    belonging to za0 and za1.

    So atom planes must be constructed first.

    Parameters
    ----------
    atom : Atom_Position object
    za0 : tuple
    za1 : tuple

    Return
    ------
    middle_position : tuple
        If the atom is at the edge by being the last atom in the
        atom plane, False is returned.

    Examples
    --------
    >>> import atomap.analysis_tools as an
    >>> sublattice = am.dummy_data.get_simple_cubic_sublattice()
    >>> sublattice.construct_zone_axes()
    >>> za0 = sublattice.zones_axis_average_distances[0]
    >>> za1 = sublattice.zones_axis_average_distances[1]
    >>> atom = sublattice.atom_list[33]
    >>> middle_position = an.get_neighbor_middle_position(atom, za0, za1)

    """
    atom00 = atom
    atom01 = atom.get_next_atom_in_zone_vector(za0)
    atom10 = atom.get_next_atom_in_zone_vector(za1)
    middle_position = False
    if not (atom01 is False):
        if not (atom10 is False):
            atom11 = atom10.get_next_atom_in_zone_vector(za0)
            if not (atom11 is False):
                middle_position = to.get_point_between_four_atoms(
                    (atom00, atom01, atom10, atom11))
    return middle_position
Пример #3
0
 def test_negative(self):
     atom0, atom1 = ap.Atom_Position(-15, 30), ap.Atom_Position(-10, 30)
     atom2, atom3 = ap.Atom_Position(-15, 40), ap.Atom_Position(-10, 40)
     mid_pos = to.get_point_between_four_atoms((atom0, atom1, atom2, atom3))
     assert mid_pos == (-12.5, 35.)
Пример #4
0
 def test_diagonal(self):
     atom0, atom1 = ap.Atom_Position(5, 0), ap.Atom_Position(0, 5)
     atom2, atom3 = ap.Atom_Position(5, 10), ap.Atom_Position(10, 5)
     mid_pos = to.get_point_between_four_atoms((atom0, atom1, atom2, atom3))
     assert mid_pos == (5., 5.)
Пример #5
0
 def test_simple(self):
     atom0, atom1 = ap.Atom_Position(10, 30), ap.Atom_Position(20, 30)
     atom2, atom3 = ap.Atom_Position(10, 40), ap.Atom_Position(20, 40)
     mid_pos = to.get_point_between_four_atoms((atom0, atom1, atom2, atom3))
     assert mid_pos == (15., 35.)