示例#1
0
    def test_get_optimal_centre_position_off_centre_non_square(self):
        test_data = mdtd.MakeTestData(size_x=300,
                                      size_y=400,
                                      default=False,
                                      blur=True,
                                      downscale=False)
        x0, y0 = 150, 170
        test_data.add_ring(x0=x0, y0=y0, r=100, intensity=10, lw_pix=1)
        s = test_data.signal
        s.axes_manager[0].offset = -x0 - 2
        s.axes_manager[1].offset = -y0 - 3
        s_c = ra.get_optimal_centre_position(
            test_data.signal,
            radial_signal_span=(90, 110),
            steps=3,
            step_size=1.0,
            angleN=8,
        )
        min_pos0 = ra.get_coordinate_of_min(s_c)
        s.axes_manager[0].offset = -x0 + 2
        s.axes_manager[1].offset = -y0 - 3
        s_c = ra.get_optimal_centre_position(
            test_data.signal,
            radial_signal_span=(90, 110),
            steps=3,
            step_size=1.0,
            angleN=8,
        )
        min_pos1 = ra.get_coordinate_of_min(s_c)
        s.axes_manager[0].offset = -x0 - 2
        s.axes_manager[1].offset = -y0 + 3
        s_c = ra.get_optimal_centre_position(
            test_data.signal,
            radial_signal_span=(90, 110),
            steps=3,
            step_size=1.0,
            angleN=8,
        )
        min_pos2 = ra.get_coordinate_of_min(s_c)
        s.axes_manager[0].offset = -x0 + 2
        s.axes_manager[1].offset = -y0 + 3
        s_c = ra.get_optimal_centre_position(
            test_data.signal,
            radial_signal_span=(90, 110),
            steps=3,
            step_size=1.0,
            angleN=8,
        )
        min_pos3 = ra.get_coordinate_of_min(s_c)

        for min_pos in [min_pos0, min_pos1, min_pos2, min_pos3]:
            assert approx(min_pos[0]) == x0
            assert approx(min_pos[1]) == y0
示例#2
0
 def test_get_optimal_centre_position(self):
     x0, y0 = 300.0, 300.0
     test_data = mdtd.MakeTestData(size_x=600, size_y=600, default=False)
     test_data.add_ring(x0=x0, y0=y0, r=200, intensity=10, lw_pix=2)
     s = test_data.signal
     s.axes_manager[0].offset = -301.0
     s.axes_manager[1].offset = -301.0
     s_centre_position = ra.get_optimal_centre_position(
         s, radial_signal_span=(180, 210), steps=2, step_size=1)
     x, y = ra.get_coordinate_of_min(s_centre_position)
     assert (x0 - 0.5) <= x and x <= (x0 + 0.5)
     assert (x0 - 0.5) <= x and x <= (x0 + 0.5)