コード例 #1
0
    def test_inverted_mirror_ar2rectangular(self):
        data_invMirror = ensure2DImage(self.data_invMir[0])
        result_invMirror = angleres.AngleResolved2Rectangular(
            data_invMirror, (90, 360))

        # get the inverted image of the one that corresponds to the flipped mirror
        data = data_invMirror[::-1, :]
        data.metadata[model.MD_AR_FOCUS_DISTANCE] *= -1
        arpole = data.metadata[model.MD_AR_POLE]
        data.metadata[model.MD_AR_POLE] = (arpole[0], data_invMirror.shape[0] -
                                           1 - arpole[1])

        result_standardMirror = angleres.AngleResolved2Rectangular(
            data, (90, 360))

        numpy.testing.assert_allclose(result_invMirror,
                                      result_standardMirror,
                                      atol=1e-7)
コード例 #2
0
    def test_uint16_input_rect(self):
        """
        Tests for input of DataArray with uint16 ndarray to rectangular projection
        """
        data = self.data
        C, T, Z, Y, X = data[0].shape
        data[0].shape = Y, X
        result = angleres.AngleResolved2Rectangular(data[0], (100, 400))

        self.assertEqual(result.shape, (100, 400))
コード例 #3
0
    def test_uint16_input_rect2polar(self):
        """
        Tests for input of DataArray with uint16 ndarray from rectangular projection to polar projection.
        """
        data = self.data
        C, T, Z, Y, X = data[0].shape
        data[0].shape = Y, X
        data[0].metadata[MD_POL_MODE] = MD_POL_S1  # add necessary metadata

        # convert to rectangular
        data_rect = angleres.AngleResolved2Rectangular(data[0], (100, 400))
        # convert from rectangular to polar
        result = angleres.Rectangular2Polar(data_rect, 201)
        result_polar_1 = RGB2Greyscale(result)

        # convert input data directly to polar representation
        result_polar_2 = angleres.AngleResolved2Polar(data[0], 201)

        self.assertEqual(result.shape, (201, 201, 3))
        self.assertEqual(result_polar_2.shape, result_polar_1.shape)
コード例 #4
0
    def test_uint16_input_rect_intensity(self):
        """
        Tests for input of DataArray with uint16 ndarray to rectangular projection checking that the
        expected intensity values are at the correct theta/phi position in the rectangular and polar representation.
        This test case is optimized for the current input image. If ever changed, this test case might fail!
        """
        data = self.data
        C, T, Z, Y, X = data[0].shape
        data[0].shape = Y, X
        data[0] = data[0][0:256, 0:241]

        result_rectangular = angleres.AngleResolved2Rectangular(
            data[0], (90, 360))

        self.assertEqual(result_rectangular.shape, (90, 360))

        # get theta/phi corresponding to x/y in data
        theta_data, phi_data, intensity_data, circle_mask_dilated = \
            angleres._ExtractAngleInformation(data[0], hole=False)

        # find the position in the raw data with max intensity
        pos_max = numpy.where(data[0] == numpy.max(data[0]))
        x = pos_max[0][0]
        y = pos_max[1][0]

        # find the intensity value for the same position but corrected for photon collection efficiency
        intensity_data_I = intensity_data[x][y]

        # find the corresponding theta/phi angles
        phi = phi_data[x][y]
        theta = theta_data[x][y]

        # find the position in the rectangular representation
        px_phi = int(
            numpy.round(result_rectangular.shape[1] / (2 * numpy.pi) * phi))
        px_theta = int(
            numpy.round(result_rectangular.shape[0] / (numpy.pi / 2) * theta))
        result_I_rectangular = result_rectangular[px_theta][px_phi]

        # test values are close due to rounding the px pos and interpolation
        numpy.testing.assert_allclose(intensity_data_I,
                                      result_I_rectangular,
                                      atol=10e6)

        # find a second characteristic position in raw image
        x1 = 97
        y1 = 77

        # find the intensity value for the same position but corrected for photon collection efficiency
        intensity_data_I_rectangular_2 = intensity_data[x1][y1]

        # find the corresponding theta/phi angles
        phi2 = phi_data[x1][y1]
        theta2 = theta_data[x1][y1]

        px_phi2 = int(
            numpy.round(result_rectangular.shape[1] / (2 * numpy.pi) * phi2))
        px_theta2 = int(
            numpy.round(result_rectangular.shape[0] / (numpy.pi / 2) * theta2))

        result_I_rectangular_2 = result_rectangular[px_theta2 - 1][
            px_phi2 - 1]  # Note rounding problems

        # test values are close due to rounding the px pos and interpolation
        numpy.testing.assert_allclose(intensity_data_I_rectangular_2,
                                      result_I_rectangular_2,
                                      atol=10e6)