Пример #1
0
    def awg_to_plunger(self, fig=100):
        """ Plot results of awg_to_plunger calibration check?

        Args:
            fig (str, int or None): default None. Name of figure to plot in, if None not plotted.

        """
        x = np.arange(0, 80, 1.0).astype(np.float32)
        y = np.arange(0, 60).astype(np.float32)
        z = np.meshgrid(x, y)
        z = 0.01 * z[0].astype(np.uint8)
        input_angle = np.deg2rad(-35)
        semiLine(z,
                 np.array([[0], [y.max()]]),
                 input_angle,
                 w=2.2,
                 l=30,
                 H=0.52)
        ds = makeDataSet2Dplain('x', x, 'y', y, 'z', z)
        result = {'dataset': ds, 'type': 'awg_to_plunger'}
        r = analyse_awg_to_plunger(result, method='hough', fig=fig)
        output_angle = r['angle']

        if fig is not None:
            print(r)
            print('angle input %.3f: output angle %s' %
                  (input_angle, str(output_angle)))

        d = qtt.pgeometry.angleDiff(input_angle, (-np.pi / 2 - output_angle))
        self.assertTrue(np.abs(d) < np.deg2rad(5))
Пример #2
0
 def __call__(self):
     import qtt.utilities.imagetools as lt
     data = np.random.rand(self.nx * self.nx)
     data_reshaped = data.reshape(self.nx, self.nx)
     lt.semiLine(data_reshaped, [self.nx / 2, self.nx / 2],
                 np.deg2rad(self.p()), w=2, l=self.nx / 3, H=2)
     lt.semiLine(data_reshaped, [self.nx / 2, self.nx / 2],
                 np.deg2rad(self.q()), w=2, l=self.nx / 4, H=3)
     return data_reshaped
Пример #3
0
    def test_semi_line(self):
        im = np.zeros((300, 400))
        semi_line = semiLine(im, [100, 200], 10, w=12, l=300)

        self.assertEqual(semi_line.size, 120000)
        self.assertAlmostEqual(semi_line.min(), -8.742276804696303e-06, 6)
        self.assertAlmostEqual(semi_line.max(), 199.9999542236328, 6)
        self.assertAlmostEqual(semi_line.sum(), 183001.1215185296, 3)

        line_segment = lineSegment(semi_line, [5, 5], [50, 100])
        self.assertEqual(line_segment.size, 120000)
        self.assertAlmostEqual(line_segment.min(), -1.7484456293459516e-05, 6)
        self.assertAlmostEqual(line_segment.max(), 199.9999542232738, 6)
        self.assertAlmostEqual(line_segment.sum(), 209757.99804017632, 3)