예제 #1
0
 def test_refine_position_gaussian(self):
     signal = self.signal
     atom_positions = am.get_atom_positions(signal, 4)
     vector = ipf.find_dumbbell_vector(atom_positions)
     dumbbell_positions = am.get_atom_positions(signal, separation=13)
     atom_lattice = ipf.make_atom_lattice_dumbbell_structure(
         signal, dumbbell_positions, vector)
     atom_lattice.refine_position_gaussian()
예제 #2
0
 def test_simple_running(self):
     s = self.s
     atom_positions = am.get_atom_positions(s, separation=4)
     vector = ipf.find_dumbbell_vector(atom_positions)
     dumbbell_positions = am.get_atom_positions(s, 14)
     dumbbell_array0, dumbbell_array1 = ipf._get_dumbbell_arrays(
             s, dumbbell_positions, vector)
     assert len(dumbbell_array0) == 100
     assert len(dumbbell_array1) == 100
예제 #3
0
 def test_simple_running(self):
     s = self.s
     atom_positions = am.get_atom_positions(s, separation=4)
     vector = ipf.find_dumbbell_vector(atom_positions)
     dumbbell_positions = am.get_atom_positions(s, separation=13)
     atom_lattice = ipf.make_atom_lattice_dumbbell_structure(
             s, dumbbell_positions, vector)
     assert len(atom_lattice.sublattice_list) == 2
     sublattice0 = atom_lattice.sublattice_list[0]
     sublattice1 = atom_lattice.sublattice_list[1]
     assert len(sublattice0.atom_list) == 100
     assert len(sublattice1.atom_list) == 100
예제 #4
0
 def test_5_separation_x(self):
     test_data = MakeTestData(200, 200)
     x0, y0 = np.mgrid[10:200:20, 10:200:20]
     x1, y1 = np.mgrid[16:200:20, 10:200:20]
     x, y = np.vstack((x0, x1)).flatten(), np.vstack((y0, y1)).flatten()
     test_data.add_atom_list(x, y, sigma_x=1, sigma_y=1, amplitude=50)
     atom_positions = am.get_atom_positions(test_data.signal, 4)
     vector = ipf.find_dumbbell_vector(atom_positions)
     assert approx(abs(vector[0]), abs=1e-7) == 6.
     assert approx(abs(vector[1]), abs=1e-7) == 0.
예제 #5
0
 def test_3d_data_running(self):
     s = dd.get_eels_spectrum_survey_image()
     s_eels = dd.get_eels_spectrum_map()
     peaks = am.get_atom_positions(s, separation=4)
     i_points, i_record, p_record = integrate(s_eels,
                                              peaks[:, 0],
                                              peaks[:, 1],
                                              max_radius=3)
     assert p_record.shape == (100, 100)
     assert s_eels.data.shape == i_record.data.shape
"image_ifft" or whatever you called your filtered file.
'''

# look at the different pixel separations available, this can take some time.
feat = am.get_feature_separation(image, separation_range=(5, 20), pca=True)
feat.plot()
''' If you're happy with one of the pixel separations, then set it below. If
    you're not, you may need to change your separation_range or filter your
    image with the "1b_Filter_Data.py" file.

Note: If you have used the image filter file, then replace "image" with
"image_ifft" or whatever you called your filtered file.    
'''

sep = 9  # just an example
atom_positions1 = am.get_atom_positions(image, separation=sep, pca=True)

# save these original sub1 positions!
np.save('atom_positions1.npy', arr=atom_positions1)

# how to reload this file format
# example_positions = np.load('atom_positions1.npy')
''' Create the first sublattice, which we call sub1. '''

sub1 = am.Sublattice(atom_position_list=atom_positions1,
                     image=image,
                     color='red')
sub1.find_nearest_neighbors()

# you can plot the sublattice easily with:
# sub1.plot()
예제 #7
0
    s.plot()
    s._plot.signal_plot.figure.savefig(os.path.join(my_path,
                                                    'atom_lattice.png'),
                                       overwrite=True)


def plot_image_wo_A(image):
    s = hs.signals.Signal2D(image)
    s.plot()
    s._plot.signal_plot.figure.savefig(os.path.join(my_path,
                                                    'signal_wo_A.png'),
                                       overwrite=True)


s = dummy_data.get_two_sublattice_signal()
A_positions = am.get_atom_positions(s, separation=15)
sublattice_A = am.Sublattice(A_positions, image=s.data, color='r')
sublattice_A.find_nearest_neighbors()
sublattice_A.refine_atom_positions_using_center_of_mass()
sublattice_A.refine_atom_positions_using_2d_gaussian()
sublattice_A.construct_zone_axes()

save_sub_A_image(sublattice_A)
plot_planes_figure(sublattice_A)

zone_axis_001 = sublattice_A.zones_axis_average_distances[1]
B_positions = sublattice_A.find_missing_atoms_from_zone_vector(zone_axis_001)
image_without_A = remove_atoms_from_image_using_2d_gaussian(
    sublattice_A.image, sublattice_A)

plot_image_wo_A(image_without_A)
예제 #8
0
import os
import matplotlib
matplotlib.use('Qt5Agg')  # noqa
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import atomap.api as am
import atomap.animation_plotting_tools as apt

my_path = os.path.join(os.path.dirname(__file__), 'atomadderremovergui')
if not os.path.exists(my_path):
    os.makedirs(my_path)

#####
s = am.dummy_data.get_distorted_cubic_signal()
peaks = am.get_atom_positions(s, 25)
peaks_new = am.add_atoms_with_gui(s, peaks)
ifig = plt.get_fignums()[0]
fig = plt.figure(ifig)
ax = fig.axes[0]

position_list = [
    [-20, 20],
    [51, 215],
    [90, 215],
    [129, 215],
    [159, 220],
    [170, 215],
    [159, 220],
    [211.5, 215],
    [232, 250],
]
예제 #9
0
import os
import atomap.api as am
import matplotlib.pyplot as plt

my_path = os.path.join(os.path.dirname(__file__), 'quant')
if not os.path.exists(my_path):
    os.makedirs(my_path)

# Making and fitting data
s = am.dummy_data.get_atom_counting_signal()
atom_positions = am.get_atom_positions(s, 8, threshold_rel=0.1)
sublattice = am.Sublattice(atom_positions, s)
sublattice.construct_zone_axes()
sublattice.refine_atom_positions_using_2d_gaussian()

# Plotting
models = am.quant.get_statistical_quant_criteria([sublattice], 10)
plt.savefig(os.path.join(my_path, 'criteria_plot.png'), overwrite=True)

atom_lattice = am.quant.statistical_quant(sublattice.image, sublattice,
                                          models[3], 4)
plt.savefig(os.path.join(my_path, 'quant_output1a.png'), overwrite=True)

s_al = atom_lattice.get_sublattice_atom_list_on_image()
s_al.plot()
s_al._plot.signal_plot.figure.savefig(os.path.join(my_path,
                                                   'quant_output1b.png'),
                                      dpi=150)
예제 #10
0
def plot_fantasite(s):
    s.plot()
    s._plot.signal_plot.figure.savefig(os.path.join(my_path, 'fantasite.png'),
                                       overwrite=True)


def plot_atom_lattice(atom_lattice):
    s = atom_lattice.get_sublattice_atom_list_on_image()
    s.plot()
    s._plot.signal_plot.figure.savefig(os.path.join(my_path,
                                                    'atom_lattice.png'),
                                       overwrite=True)


s = am.dummy_data.get_fantasite()
A_positions = am.get_atom_positions(s, separation=12, pca=True)
sublattice_A = am.Sublattice(A_positions, image=s.data, color='r', name='A')
sublattice_A.find_nearest_neighbors()
sublattice_A.refine_atom_positions_using_center_of_mass()
sublattice_A.refine_atom_positions_using_2d_gaussian()
sublattice_A.construct_zone_axes()

direction_001 = sublattice_A.zones_axis_average_distances[1]
B_positions = sublattice_A.find_missing_atoms_from_zone_vector(direction_001)
image_without_A = remove_atoms_from_image_using_2d_gaussian(
    sublattice_A.image, sublattice_A)

sublattice_B = am.Sublattice(B_positions,
                             image_without_A,
                             color='blue',
                             name='B')
예제 #11
0
my_path = os.path.join(os.path.dirname(__file__), 'makedumbbelllattice')
if not os.path.exists(my_path):
    os.makedirs(my_path)

#####
s = am.dummy_data.get_dumbbell_heterostructure_signal()
s.plot()
s._plot.signal_plot.figure.savefig(os.path.join(my_path, 'dummy_data.png'))

#####
s_peaks = am.get_feature_separation(s, separation_range=(2, 6))
s_peaks.plot()
s_peaks._plot.signal_plot.figure.savefig(os.path.join(my_path, 'feature_separation_all_atoms.png'))

#####
atom_positions = am.get_atom_positions(s, separation=2)
dumbbell_vector = ipf.find_dumbbell_vector(atom_positions)

#####
s_peaks = am.get_feature_separation(s, separation_range=(5, 20))
s_peaks.axes_manager.indices = (3,)
s_peaks.plot()
s_peaks._plot.signal_plot.figure.savefig(os.path.join(my_path, 'feature_separation_dumbbell.png'))

#####
dumbbell_positions = am.get_atom_positions(s, separation=8)
dumbbell_lattice = ipf.make_atom_lattice_dumbbell_structure(s, dumbbell_positions, dumbbell_vector)
dumbbell_lattice.refine_position_gaussian()
s_ap = dumbbell_lattice.get_sublattice_atom_list_on_image()
s_ap.plot()
s_ap._plot.signal_plot.figure.savefig(os.path.join(my_path, 'dumbbell_lattice_initial.png'))
예제 #12
0
                            scanWindowMax=1.0,
                            algorithm="prism",
                            numThreads=2)

simulation = tml.load_prismatic_mrc_with_hyperspy(
    prismatic_mrc_filename='prism_2Doutput_' + prismatic_xyz_filename + '.mrc',
    save_name=prismatic_xyz_filename[:-4])

simulation.plot()

######## Model Creation Example - simulated Cu NP ########

s = tml.example_data.load_example_Cu_nanoparticle()
s.plot()

atom_positions = am.get_atom_positions(s, separation=10, pca=True)
# atom_positions = am.add_atoms_with_gui(image=s, atom_list=atom_positions)
# np.save("Au_NP_atom_positions", atom_positions)
# atom_positions = np.load("Au_NP_atom_positions.npy")

sublattice = am.Sublattice(atom_position_list=atom_positions, image=s)
sublattice.refine_atom_positions_using_center_of_mass()
sublattice.plot()

atom_lattice = am.Atom_Lattice(image=s,
                               name="Cu_NP_sim",
                               sublattice_list=[sublattice])
atom_lattice.save(filename="Cu_NP_sim_Atom_Lattice.hdf5", overwrite=True)

sublattice.image /= sublattice.image.max()