How to use the starry.System function in starry

To help you get started, we’ve selected a few starry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rodluger / starry / tests / greedy / test_exceptions_greedy.py View on Github external
def test_bad_sys_settings():
    pri = starry.Primary(starry.Map())
    sec = starry.Secondary(starry.Map(), porb=1.0)

    # Bad exposure time
    with pytest.raises(AssertionError) as e:
        sys = starry.System(pri, sec, texp=-1.0)

    # Bad oversample factor
    with pytest.raises(AssertionError) as e:
        sys = starry.System(pri, sec, oversample=-1)

    # Bad integration order
    with pytest.raises(AssertionError) as e:
        sys = starry.System(pri, sec, order=99)

    # Bad primary
    with pytest.raises(AssertionError) as e:
        sys = starry.System(sec, sec)

    # Reflected light primary
    with pytest.raises(AssertionError) as e:
        sys = starry.System(starry.Primary(starry.Map(reflected=True)), sec)

    # Bad secondary
    with pytest.raises(AssertionError) as e:
        sys = starry.System(pri, pri)

    # No secondaries
    with pytest.raises(AssertionError) as e:
        sys = starry.System(pri)
github rodluger / starry / tests / greedy / test_system_rv_greedy.py View on Github external
starry.Map(rv=True, amp=1, veq=0),
        r=0.1,
        porb=1.0,
        m=0.01,
        t0=0.0,
        inc=86.0,
        ecc=0.3,
        w=60,
        length_unit=u.Rsun,
        mass_unit=u.Msun,
        angle_unit=u.degree,
        time_unit=u.day,
    )

    # Define the system
    sys = starry.System(A, b)

    # Time array
    time = np.linspace(-0.05, 0.05, 1000)

    # Get the positions of both bodies
    x, y, z = sys.position(time)

    # Compute the relative positions
    xo = x[1] - x[0]
    yo = y[1] - y[0]
    zo = z[1] - z[0]
    ro = b.r / A.r

    # Compare
    rv1 = map.rv(xo=xo, yo=yo, ro=ro)
    rv2 = sys.rv(time, keplerian=False)
github rodluger / starry / tests / greedy / test_system_greedy.py View on Github external
def test_bodies():
    pri = starry.Primary(starry.Map())
    sec = starry.Secondary(starry.Map(ydeg=1), porb=1.0)
    sys = starry.System(pri, sec)
    assert sys.primary == pri
    assert sys.secondaries[0] == sec
github rodluger / starry / tests / greedy / test_system_greedy.py View on Github external
def test_reflected_light():
    pri = starry.Primary(starry.Map(amp=0), r=1)
    sec = starry.Secondary(starry.Map(reflected=True), porb=1.0, r=1)
    sys = starry.System(pri, sec)
    t = np.concatenate((np.linspace(0.1, 0.4, 50), np.linspace(0.6, 0.9, 50)))
    flux = sys.flux(t)
github rodluger / starry / tests / greedy / test_show_greedy.py View on Github external
def test_system_rv_show(mp4=False):
    pri = starry.Primary(starry.Map(rv=True))
    sec = starry.Secondary(starry.Map(rv=True), porb=1.0)
    sys = starry.System(pri, sec)
    sys.show(0.1, file="tmp.pdf")
    os.remove("tmp.pdf")
    if mp4:
        sys.show([0.1, 0.2], file="tmp.mp4")
        os.remove("tmp.mp4")
github rodluger / starry / tests / greedy / test_system_greedy.py View on Github external
def test_orientation(Omega=45, inc=35):
    # Instantiate
    pri = starry.Primary(starry.Map(amp=0))
    sec = starry.Secondary(
        starry.Map(ydeg=1, amp=1),
        porb=1.0,
        r=0,
        m=0,
        inc=inc,
        Omega=Omega,
        prot=1.0,
        theta0=180.0,
    )
    sec.map[1, 0] = 1.0
    sys = starry.System(pri, sec)

    # Align the rotational axis with the orbital axis
    sec.map.inc = sec.inc
    sec.map.obl = sec.Omega

    # Compute the flux
    t = np.linspace(-0.5, 0.5, 1000)
    flux = sys.flux(t)

    # This is the analytic result
    flux_analytic = 1.0 - np.sin(inc * np.pi / 180.0) * (
        2.0 / np.sqrt(3.0)
    ) * np.cos(2 * np.pi * t)

    assert np.allclose(flux, flux_analytic)
github rodluger / starry / starry / extensions / nexsci / nexsci.py View on Github external
)
        r = np.asarray(d.pl_radj * u.jupiterRad.to(u.solRad)) / np.asarray(
            d.st_rad
        )

        planet = Secondary(
            Map(amp=0),
            porb=d.pl_orbper,
            t0=d.pl_tranmid,
            r=r,
            inc=d.pl_orbincl,
            ecc=d.pl_eccen,
            w=d.pl_orblper,
        )
        planets.append(planet)
    sys = System(star, *planets)
    return sys
github rodluger / starry / tex / figures / spidercomp.py View on Github external
L=1.0e-3 * np.pi,
                           inc=spider_params.inc,
                           a=spider_params.a,
                           porb=spider_params.per,
                           tref=spider_params.t0,
                           prot=spider_params.per,
                           ecc=spider_params.ecc)

    # Define spherical harmonic coefficients
    planet.map[0, 0] = 1.0
    planet.map[1, -1] = 0.0
    planet.map[1, 0] = 0.0
    planet.map[1, 1] = 0.5

    # Make a system
    system = starry.System([star, planet])

    # Now make a multiprecision system to compute error estimates
    mstar = starry.multi.Star()
    mplanet = starry.multi.Planet(lmax=2, lambda0=90., w=spider_params.w,
                                  r=spider_params.rp, L=1.0e-3 * np.pi,
                                  inc=spider_params.inc, a=spider_params.a,
                                  porb=spider_params.per,
                                  tref=spider_params.t0,
                                  prot=spider_params.per,
                                  ecc=spider_params.ecc)
    mplanet.map[:] = planet.map[:]
    msystem = starry.multi.System([mstar, mplanet])

    # ## Speed test! ## #

    # Number of time array points