Пример #1
0
 def test_log_norm(self):
     data = np.random.random((200, 200))
     peaks = ipf.add_atoms_with_gui(data, norm='log')
     fig = plt.figure(1)
     x, y = fig.axes[0].transData.transform((100, 100))
     assert len(peaks) == 0
     fig.canvas.button_press_event(x, y, 1)
     assert len(peaks) == 1
     fig.canvas.button_press_event(x, y, 1)
     assert len(peaks) == 0
Пример #2
0
 def test_many_atoms_input(self):
     data = np.random.random((500, 1000))
     x, y = np.mgrid[10:990:100j, 10:490:100j]
     x, y = x.flatten(), y.flatten()
     positions = np.stack((x, y)).T
     peaks = ipf.add_atoms_with_gui(data, positions)
     assert len(peaks) == len(positions)
     fig = plt.figure(1)
     x0, y0 = fig.axes[0].transData.transform((peaks[0][0], peaks[0][1]))
     fig.canvas.button_press_event(x0, y0, 1)
     assert len(peaks) == len(positions) - 1
Пример #3
0
    def test_distance_threshold(self):
        data = np.random.random((50, 200))
        peaks0 = ipf.add_atoms_with_gui(data, distance_threshold=10)
        fig0 = plt.figure(1)
        x00, y00 = fig0.axes[0].transData.transform((100, 10))
        fig0.canvas.button_press_event(x00, y00, 1)
        assert len(peaks0) == 1
        x01, y01 = fig0.axes[0].transData.transform((109, 19))
        fig0.canvas.button_press_event(x01, y01, 1)
        assert len(peaks0) == 0
        plt.close(fig0)

        peaks1 = ipf.add_atoms_with_gui(data, distance_threshold=4)
        fig1 = plt.figure(1)
        x10, y10 = fig1.axes[0].transData.transform((100, 10))
        fig1.canvas.button_press_event(x10, y10, 1)
        assert len(peaks1) == 1
        x11, y11 = fig1.axes[0].transData.transform((109, 19))
        fig1.canvas.button_press_event(x11, y11, 1)
        assert len(peaks1) == 2
        plt.close(fig1)
Пример #4
0
 def test_atoms_input(self):
     data = np.random.random((50, 200))
     peaks = ipf.add_atoms_with_gui(data, [
         [120, 20],
         [120, 30],
     ])
     fig = plt.figure(1)
     x0, y0 = fig.axes[0].transData.transform((100, 10))
     assert len(peaks) == 2
     fig.canvas.button_press_event(x0, y0, 1)
     assert len(peaks) == 3
     x1, y1 = fig.axes[0].transData.transform((120, 30))
     fig.canvas.button_press_event(x1, y1, 1)
     assert len(peaks) == 2
     assert peaks[0] == approx([120, 20])
     assert peaks[1] == approx([100, 10])
Пример #5
0
    def set_calibration_area(self, manual_list=None):
        '''
        Area that will be used to calibrate a simulation. The pixel separation
        can be set with set_calibration_separation. The average intensity of
        the atoms chosen by this separation within the area will be set to 1.
        The idea is to calibrate the experimental and simulated images with a
        known intensity (e.g., single Mo atom in MoS2 is relatively
        consistant).

        reference_image can be changed via the Model_refiner.reference_image
        attribute.

        manual_list must be a list of two lists, each of length two.
        For example: [ [0,0], [50, 50] ]
        '''

        if isinstance(manual_list, list):
            self.calibration_area = manual_list
        else:
            self.calibration_area = add_atoms_with_gui(self.reference_image)
Пример #6
0
 def test_signal_input(self):
     s = Signal2D(np.random.random((200, 200)))
     ipf.add_atoms_with_gui(s, norm='log')
     ipf.add_atoms_with_gui(s, norm='linear')
Пример #7
0
 def test_log_norm_negative_image_values(self):
     data = np.random.random((200, 200)) - 10
     ipf.add_atoms_with_gui(data, norm='log')