Пример #1
0
    def testBuildFromFractionalJ(self):
        pr = Cn2Profile.from_fractional_j(0.1, 1.0, 30, 100, 10, 0.3)
        self.assertAlmostEqual(0.1, pr.r0().value)
        pr = Cn2Profile.from_fractional_j(0.13, [0.1, 0.9], [30, 42], [0, 100],
                                          [3.14, 10], [0, 0.3])
        self.assertAlmostEqual(0.13, pr.r0().value)

        dontSumToOne = np.array([0.1, 42])
        self.assertRaises(Exception, Cn2Profile.from_fractional_j, 42,
                          dontSumToOne, 30, 100, 10, 0)
Пример #2
0
 def testSingleLayer(self):
     pr = Cn2Profile.from_r0s([0.1], [30], [100], [10], [0.3])
     self.assertAlmostEqual([100], pr.layers_distance().value)
     self.assertAlmostEqual(0.1, pr.r0().value)
     pr = Cn2Profile.from_fractional_j(0.12, [1.0], [30], [100], [10],
                                       [0.3])
     self.assertAlmostEqual(0.12, pr.r0().value)
    def testCovarianceZernikeOnSeveralModes(self):
        cn2 = Cn2Profile.from_fractional_j(0.1, [1.0], [25], [0], [10], [0])
        rho, theta = (0, 0)
        source = GuideSource((rho, theta), np.inf)
        radius = 10
        center = [0, 0, 0]
        aperture = CircularOpticalAperture(radius, center)
        spatial_freqs = np.logspace(-2, 2, 100)

        modes_j = [2, 3, 4]
        modes_k = [3, 4]

        vk_cov = VonKarmanSpatioTemporalCovariance(source, source, aperture,
                                                   aperture, cn2,
                                                   spatial_freqs)

        got = vk_cov.getZernikeCovariance(modes_j, modes_k).value

        self.assertAlmostEqual(
            vk_cov.getZernikeCovariance(2, 3).value, got[0, 0])
        self.assertAlmostEqual(
            vk_cov.getZernikeCovariance(3, 3).value, got[1, 0])
        self.assertAlmostEqual(
            vk_cov.getZernikeCovariance(4, 4).value, got[2, 1])
        self.assertTrue(got.shape == (3, 2))
Пример #4
0
 def testR0ScaleWithAirmass(self):
     pr = Cn2Profile.from_fractional_j(0.1, 1.0, 30, 100, 10, 0.3)
     pr.set_zenith_angle(0)
     self.assertAlmostEqual(0.1, pr.r0().value)
     pr.set_zenith_angle(60)
     self.assertAlmostEqual(0.1 * 2**(-3. / 5), pr.r0().value)
     pr.set_zenith_angle(45)
     self.assertAlmostEqual(0.1 * np.sqrt(2)**(-3. / 5), pr.r0().value)
Пример #5
0
 def testTau0OfSingleLayer(self):
     zenAngle = 10.
     r0 = 0.13
     h = 1234.
     wspd = 10.
     pr = Cn2Profile.from_fractional_j(r0, 1.0, 30, h, wspd, 0.3)
     pr.set_zenith_angle(zenAngle)
     pr.set_wavelength(1.0e-6)
     wanted = (2.914 / 0.422727)**(-3. / 5) * pr.r0().value / (wspd)
     self.assertAlmostEqual(wanted, pr.tau0().value)
Пример #6
0
 def testTheta0OfSingleLayer(self):
     zenAngle = 23.5
     airmass = Cn2Profile.zenith_angle_to_airmass(zenAngle)
     r0 = 0.13
     h = 1000.
     pr = Cn2Profile.from_fractional_j(r0, 1.0, 30, h, 10, 0.3)
     pr.set_zenith_angle(zenAngle)
     pr.set_wavelength(1.0e-6)
     wanted = (2.914 / 0.422727)**(-3. / 5) * pr.r0().value / (
         h * airmass) * Constants.RAD2ARCSEC
     self.assertAlmostEqual(wanted, pr.theta0().value)
    def testCovarianceZernikeOnTheSameSourceAndAperture(self):
        cn2 = Cn2Profile.from_fractional_j(0.1, [1.0], [25], [0], [10], [0])
        rho, theta = (0, 0)
        source = GuideSource((rho, theta), np.inf)
        radius = 10
        center = [0, 0, 0]
        aperture = CircularOpticalAperture(radius, center)
        spatial_freqs = np.logspace(-2, 2, 100)

        vk_cov = VonKarmanSpatioTemporalCovariance(source, source, aperture,
                                                   aperture, cn2,
                                                   spatial_freqs)
        wanted = 0
        got = vk_cov.getZernikeCovariance(2, 3).value

        self.assertAlmostEqual(wanted, got)
Пример #8
0
 def testTheta0AtGroundIsInfinite(self):
     pr = Cn2Profile.from_fractional_j(0.1, 1.0, 30, 0, 10, 0.3)
     pr.set_zenith_angle(42)
     self.assertAlmostEqual(np.inf, pr.theta0())
Пример #9
0
 def testScalarAsArguments(self):
     pr = Cn2Profile.from_r0s(0.1, 30, 100, 10, 0.3)
     self.assertAlmostEqual(100, pr.layers_distance().value)
     self.assertAlmostEqual(0.1, pr.r0().value)
     pr = Cn2Profile.from_fractional_j(0.12, 1.0, 30, 100, 10, 0.3)
     self.assertAlmostEqual(0.12, pr.r0().value)