예제 #1
0
def test_singular_points():
    u = tt.vector()
    b = tt.vector()
    r = tt.vector()
    lc = LimbDarkLightCurve(u)
    f = lc._compute_light_curve(b, r)
    func = theano.function([u, b, r], f)
    u_val = np.array([0.2, 0.3, 0.1, 0.5])

    def compare(b_val, r_val, b_eps, r_eps):
        """
        Compare the flux at a singular point
        to the flux at neighboring points.

        """
        b_val = [b_val - b_eps, b_val + b_eps, b_val]
        r_val = [r_val - r_eps, r_val + r_eps, r_val]
        flux = func(u_val, b_val, r_val)
        assert np.allclose(np.mean(flux[:2]), flux[2])

    # Test the b = 1 - r singular point
    compare(0.1, 0.9, 1e-8, 0.0)

    # Test the b = r = 0.5 singular point
    compare(0.5, 0.5, 1e-8, 0.0)

    # Test the b = 0 singular point
    compare(0.0, 0.1, 1e-8, 0.0)

    # Test the b = 0, r = 1 singular point
    compare(0.0, 1.0, 0.0, 1e-8)

    # Test the b = 1 + r singular point
    compare(1.1, 0.1, 1e-8, 0.0)
예제 #2
0
def test_light_curve():
    u_val = np.array([0.2, 0.3])
    b_val = np.linspace(-1.5, 1.5, 100)
    r_val = 0.1 + np.zeros_like(b_val)
    lc = LimbDarkLightCurve(u_val[0], u_val[1])
    evaluated = lc._compute_light_curve(b_val, r_val).eval()

    if version.parse(starry.__version__) < version.parse("0.9.9"):
        m = starry.Map(lmax=len(u_val))
        m[:] = u_val
        expect = m.flux(xo=b_val, ro=r_val) - 1
    else:
        m = starry.Map(udeg=len(u_val))
        m[1:] = u_val
        expect = m.flux(xo=b_val, ro=r_val[0]).eval() - 1

    assert np.allclose(expect, evaluated)
예제 #3
0
def test_light_curve():
    u = tt.vector()
    b = tt.vector()
    r = tt.vector()
    lc = LimbDarkLightCurve(u)
    f = lc._compute_light_curve(b, r)
    func = theano.function([u, b, r], f)

    u_val = np.array([0.2, 0.3, 0.1, 0.5])
    b_val = np.linspace(-1.5, 1.5, 100)
    r_val = 0.1 + np.zeros_like(b_val)

    if version.parse(starry.__version__) < version.parse("0.9.9"):
        m = starry.Map(lmax=len(u_val))
        m[:] = u_val
        expect = m.flux(xo=b_val, ro=r_val) - 1
    else:
        m = starry.Map(udeg=len(u_val))
        m[1:] = u_val
        expect = m.flux(xo=b_val, ro=r_val[0]).eval() - 1

    evaluated = func(u_val, b_val, r_val)

    utt.assert_allclose(expect, evaluated)