Beispiel #1
0
    def test_transforms_correctly_with_polarization_rotation(self):
        # We test that rotating the lab frame correctly rotates
        # the polarization.
        # If we rotate (x0, y0) -> (y1, -x1), then the polarization
        # in the new coordinates should be
        # E1x = E0y, E1y = -E1x
        scatterer = sphere
        medium_wavevec = 2 * np.pi / wavelen
        medium_index = index
        theory = MieLens()

        krho = np.linspace(0, 100, 11)
        phi_0 = 0 * krho + np.pi / 180.0  # a small component along y
        phi_1 = phi_0 - np.pi / 2
        kz = np.full_like(krho, 20.0)

        pol_0 = xr.DataArray([1.0, 0, 0])
        pos_0 = np.array([krho, phi_0, kz])

        pol_1 = xr.DataArray([0, -1.0, 0])
        pos_1 = np.array([krho, phi_1, kz])

        args = (scatterer, medium_wavevec, medium_index)

        fields_0 = theory._raw_fields(pos_0, *args, pol_0)
        fields_1 = theory._raw_fields(pos_1, *args, pol_1)

        self.assertTrue(np.allclose(fields_1[0],  fields_0[1], **TOLS))
        self.assertTrue(np.allclose(fields_1[1], -fields_0[0], **TOLS))
Beispiel #2
0
    def test_raw_fields_similar_mielens_ypolarization(self):
        detector = SMALL_DETECTOR
        scatterer = test_common.sphere
        medium_wavevec = 2 * np.pi / test_common.wavelen
        medium_index = test_common.index
        illum_polarization = xr.DataArray([0, 1.0, 0])

        theory_old = MieLens(lens_angle=LENS_ANGLE)
        pos_old = theory_old._transform_to_desired_coordinates(
            detector, scatterer.center, wavevec=medium_wavevec)

        theory_new = LENSMIE
        pos_new = theory_new._transform_to_desired_coordinates(
            detector, scatterer.center, wavevec=medium_wavevec)

        args = (scatterer, medium_wavevec, medium_index, illum_polarization)
        f0x, f0y, f0z = theory_old._raw_fields(pos_old, *args)
        fx, fy, fz = theory_new._raw_fields(pos_new, *args)
        assert_allclose(f0x, fx, atol=2e-3)
        assert_allclose(f0y, fy, atol=2e-3)
        assert_allclose(f0z, fz, atol=2e-3)