Example #1
0
 def test_fit_single_ellipse_to_signal_rotation(self):
     rot_list = [
         -np.pi / 16,
         -np.pi / 8,
         -np.pi / 4,
         -np.pi / 2,
         -0.1,
         0.1,
         np.pi / 16,
         np.pi / 8,
         np.pi / 4,
         np.pi / 2,
         np.pi + 0.1,
         np.pi * 2 + 0.1,
         np.pi * 2.5,
         np.pi * 3 + 0.1,
         np.pi * 3.2,
     ]
     for rot in rot_list:
         s = Diffraction2D(np.zeros((200, 200)))
         s.axes_manager[0].offset, s.axes_manager[1].offset = -100, -100
         xx, yy = np.meshgrid(s.axes_manager[0].axis,
                              s.axes_manager[1].axis)
         s.data += mdtd._get_elliptical_ring(xx,
                                             yy,
                                             0,
                                             0,
                                             70,
                                             60,
                                             rot,
                                             lw_r=1)
         output = ra.fit_single_ellipse_to_signal(s, (50, 80),
                                                  angleN=10,
                                                  show_progressbar=False)
         output_rot = output[5] % np.pi
         assert approx(output_rot, abs=0.1) == (rot % np.pi)
     for rot in rot_list:
         s = Diffraction2D(np.zeros((200, 200)))
         s.axes_manager[0].offset, s.axes_manager[1].offset = -100, -100
         xx, yy = np.meshgrid(s.axes_manager[0].axis,
                              s.axes_manager[1].axis)
         s.data += mdtd._get_elliptical_ring(xx,
                                             yy,
                                             0,
                                             0,
                                             60,
                                             70,
                                             rot,
                                             lw_r=1)
         output = ra.fit_single_ellipse_to_signal(s, (50, 80),
                                                  angleN=10,
                                                  show_progressbar=False)
         output_rot = (output[5] + np.pi / 2) % np.pi
         assert approx(output_rot, abs=0.1) == (rot % np.pi)
Example #2
0
 def test_fit_single_ellipse_to_signal(self):
     s = Diffraction2D(np.zeros((200, 220)))
     s.axes_manager[0].offset, s.axes_manager[1].offset = -100, -110
     xx, yy = np.meshgrid(s.axes_manager[0].axis, s.axes_manager[1].axis)
     ellipse_ring = mdtd._get_elliptical_ring(xx, yy, 0, 0, 60, 60, 0.8, lw_r=1)
     s.data += ellipse_ring
     output = ra.fit_single_ellipse_to_signal(
         s, (50, 70), angleN=10, show_progressbar=False
     )
     output[0].plot()
     assert approx(output[1], abs=0.01) == 0.0
     assert approx(output[2], abs=0.01) == 0.0
     assert approx(output[3], abs=0.6) == 60
     assert approx(output[4], abs=0.6) == 60
     assert approx(output[6], abs=0.000001) == 1.0