Пример #1
0
def test_varyElngZeta90():
    alpha_rad = 0
    maxZenithAngle_rad = np.radians(90)
    func = obs.computeExtremaOfOrbitalPhase_rad

    eLng = [30, 60, 90, 120, 150, 210, 240, 270, 300, 330]
    expected = [
        [153.435, 333.435],
        [139.106, 319.107],
        [135, 315],
        [139.106, 319.107],
        [153.435, 333.435],
        #180 is not tested in the loop
        [26.565, 206.565],
        [40.893, 220.893],
        [45, 225],
        [40.893, 220.893],
        [26.565, 206.565],
    ]

    starUnitVec = obs.computeStarUnitVector(0, 45)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.degrees(res)
    assert isZeroAndPi(res)

    starUnitVec = obs.computeStarUnitVector(180, 45)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.degrees(res)
    assert isZeroAndPi(res)

    for i, lng in enumerate(eLng):
        starUnitVec = obs.computeStarUnitVector(lng, 45)
        res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
        res = np.degrees(res)
        assert np.allclose(res, expected[i]), "%i %s" % (i, res)
Пример #2
0
def test_varyAlphaElng0Elat45Zeta60():
    """Test different earth orbital phase for zeta=60"""

    maxZenithAngle_rad = np.radians(60)
    func = obs.computeExtremaOfOrbitalPhase_rad

    starUnitVec = obs.computeStarUnitVector(0, 45)

    alpha_deg = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330]
    alpha_rad = np.radians(alpha_deg)
    expected = [
        [45.000000, 135.000000],
        [65.796572, 167.333531],
        [73.204928, 188.581861],
        [75.000000, 195.000000],  #90
        [73.204928, 188.581861],
        [65.796572, 167.333531],
        [45.000000, 135.000000],  #180
        [12.666469, 114.203428],
        [106.795072, 351.418139],
        [105.000000, 345.000000],  #270
        [106.795072, 351.418139],
        [12.666469, 114.203428],
    ]

    assert len(alpha_rad) == len(expected)  #Sanity check
    for i in range(len(alpha_rad)):
        res = func(alpha_rad[i], starUnitVec, maxZenithAngle_rad)
        res = np.degrees(res)
        msg = "alpha=%.1f Expected %s Computed %s" % (alpha_deg[i],
                                                      expected[i], res)
        assert np.allclose(res, expected[i], atol=1e-3), msg

    res = func(np.pi, starUnitVec, maxZenithAngle_rad)
    assert isZeroAndPi(res)
Пример #3
0
def test_varyElngZeta80():
    alpha_rad = 0
    elat_deg = 45
    maxZenithAngle_rad = np.radians(80)
    func = obs.computeExtremaOfOrbitalPhase_rad

    eLng = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330]
    expected = [
        [14.2158, 165.7841],  #0
        [140.74650147, 346.12339618],  #30
        [128.40829078047892, 329.8049199212592],  #60
        #
        [125, 325],  #90
        [128.40829078047892, 329.8049199212592],  #120
        [140.74650147, 346.12339618],  #150
        [14.2158, 165.7841],  #180
        [39.25349853102525, 193.87660382313072],  #210
        [51.591709, 210.195],  #240
        [55.000, 215],  #270
        [51.591709, 210.195],  #300
        [39.25349853102525, 193.87660382313072],  #330
    ]

    for i, lng in enumerate(eLng):
        starUnitVec = obs.computeStarUnitVector(lng, elat_deg)
        res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
        res = np.degrees(res)
        assert np.allclose(res,
                           expected[i]), "%i %s %s" % (i, res, expected[i])
Пример #4
0
def test_alwaysInvisible():
    alpha_rad = np.radians(90)
    elng_deg = 90
    elat_deg = 0
    maxZenith_rad = np.radians(100)
    func = obs.computeExtremaOfOrbitalPhase_rad

    starUnitVec = obs.computeStarUnitVector(elng_deg, elat_deg)

    res = func(alpha_rad, starUnitVec, maxZenith_rad)
    print(res)
Пример #5
0
def test_varyZetaElng0():
    alpha_rad = 0
    func = obs.computeExtremaOfOrbitalPhase_rad
    starUnitVec = obs.computeStarUnitVector(0, 85)

    expected = [
        [81.329, 98.671],
        [60.381, 119.619],
        [30.12643986, 149.87356014],
        [10.03859332, 169.96140668],
    ]

    for i, z in enumerate([10, 30, 60, 80]):
        maxZenithAngle_rad = np.radians(z)
        res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
        res = np.degrees(res)
        assert np.allclose(res, expected[i]), "%i %s" % (i, res)

    res = func(alpha_rad, starUnitVec, np.pi / 2.)
    assert isZeroAndPi(res)
Пример #6
0
def main():
    #Number of grid cells to plot
    nTheta = 160
    nPhi = 160

    #What range of ecliptic longitudes to plot
    phi0 = 0
    phi1 = 360
#    nTheta = 40
#    nPhi = 40

    alpha_rad = np.radians(90)
    maxOffZenith_rad = np.radians(80)
    maxAntiSolar_rad = np.radians(80)

    theta = np.linspace(-90, 90, nTheta)
    phi = np.linspace(phi0, phi1, nPhi)

    dutyCycle = np.zeros( (len(theta), len(phi)) )
    for i in range(nTheta):
        for j in range(nPhi):
            starVec = strat.computeStarUnitVector(phi[j], theta[i])

            try:
                dutyCycle[i, j] = \
                        strat.computeDutyCycle(alpha_rad,
                                               starVec,
                                               maxAntiSolar_rad,
                                               maxOffZenith_rad)
            except AssertionError:
                print("Assertion raised")
                dutyCycle[i, j] = -1
#        print(x1[i])
#        print( dutyCycle[i])

    plt.clf()
        apj.pre()
Пример #7
0
def test_varyAlphaElng0Elat45Zeta90():
    """Test different earth orbital phase for zeta=90"""
    maxZenithAngle_rad = np.radians(90)
    func = obs.computeExtremaOfOrbitalPhase_rad

    starUnitVec = obs.computeStarUnitVector(0, 45)

    alpha_deg = [0, 30, 60, 90, 120, 150, 210, 240, 270, 300, 330]
    alpha_rad = np.radians(alpha_deg)
    expected = [
        [0, 180],
        [26.565051, 206.565051],
        [40.893395, 220.893395],
        [45.000000, 225.000000],  #90
        [40.893395, 220.893395],
        [26.565051, 206.565051],

        #180 is done outside the loop
        [153.434949, 333.434949],
        [139.106605, 319.106605],
        [135, 315],  #270
        [139.106605, 319.106605],
        [153.434949, 333.434949],
    ]

    assert len(alpha_rad) == len(expected)  #Sanity check
    #    debug()
    for i in range(len(alpha_rad)):
        res = func(alpha_rad[i], starUnitVec, maxZenithAngle_rad)
        res = np.degrees(res)
        msg = "alpha=%.1f Expected %s Computed %s" % (alpha_deg[i],
                                                      expected[i], res)
        assert np.allclose(res, expected[i], atol=1e-3), msg

    res = func(np.pi, starUnitVec, maxZenithAngle_rad)
    assert isZeroAndPi(res)
Пример #8
0
def test_varyElngElatAlpha0Zeta90():
    """Increase epsilon, earth avoidance angle"""

    alpha_rad = 0
    maxZenithAngle_rad = np.radians(90)
    func = obs.computeExtremaOfOrbitalPhase_rad

    starUnitVec = obs.computeStarUnitVector(0, 30)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert isZeroAndPi(res)

    starUnitVec = obs.computeStarUnitVector(0, -30)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert isZeroAndPi(res)

    starUnitVec = obs.computeStarUnitVector(30, 0)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert isZeroAndPi(res)

    starUnitVec = obs.computeStarUnitVector(-30, 0)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert isZeroAndPi(res)

    starUnitVec = obs.computeStarUnitVector(30, 30)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert np.allclose(res, [139.1066, 319.1066]), res

    starUnitVec = obs.computeStarUnitVector(90, 30)
    res = func(alpha_rad, starUnitVec, maxZenithAngle_rad)
    res = np.sort(np.degrees(res))
    assert np.allclose(res, [120, 300]), res