How to use the starry.kepler.Secondary 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 / test_mcmc.py View on Github external
def generate(x, tstart=1, tend=5.3, npts=100, ning=100, neg=100):
    """Generate a synthetic light curve."""
    # Instantiate the star (params known exactly)
    star = Primary()
    star[1] = 0.4
    star[2] = 0.26

    # Instantiate the planet
    planet = Secondary(lmax=1)
    planet.lambda0 = 270
    planet.r = 0.0916
    planet.L = 5e-3
    planet.inc = 87
    planet.a = 11.12799
    planet.prot = 4.3
    planet.porb = 4.3
    planet.tref = 2.0

    # Instantiate the system
    system = System(star, planet)

    # Set the map coeffs
    set_coeffs(x, planet)

    # Time array w/ extra resolution at ingress/egress
github rodluger / starry / tests / test_system_gradients.py View on Github external
def lightcurve(x, eps=np.zeros(22), gradient=False, delay=False, event="phase"):
    """Compute the light curve."""
    star = starry.kepler.Primary(multi=True)
    b = starry.kepler.Secondary(multi=True)
    if delay:
        star.r_m = 3e11
    else:
        star.r_m = 0
    star.axis = [1, 3, 2]
    b.axis = [1, 2, 3]
    time = [x[0]] + eps[0]
    star.prot = x[1] + eps[1]
    star.tref = x[2] + eps[2]
    star[1, -1] = x[3] + eps[3]
    star[1, 0] = x[4] + eps[4]
    star[1, 1] = x[5] + eps[5]
    star[1] = x[6] + eps[6]
    b.r = x[7] + eps[7]
    b.L = x[8] + eps[8]
    b.prot = x[9] + eps[9]
github rodluger / starry / tests / test_system_gradients2.py View on Github external
def test_gradients(plot=False):
    """Test the gradients in the `System` class."""
    # Limb-darkened star
    A = Primary(lmax=3)
    A[1] = 0.4
    A[2] = 0.26
    A[3] = -0.25
    A.r_m = 1e11

    # Dipole-map hot jupiter
    b = Secondary(lmax=2)
    b.r = 0.09
    b.a = 60
    b.inc = 89.943
    b.porb = 50
    b.prot = 2.49
    b.lambda0 = 89.9
    b.ecc = 0.3
    b.w = 89
    b.L = 1.75e-3
    b[1, 0] = 0.5
    b[2, 1] = 0.1
    b[2, 2] = -0.05

    # Dipole-map hot jupiter
    c = Secondary(lmax=1)
    c.r = 0.12
github rodluger / starry / tests / test_system_gradients2.py View on Github external
b = Secondary(lmax=2)
    b.r = 0.09
    b.a = 60
    b.inc = 89.943
    b.porb = 50
    b.prot = 2.49
    b.lambda0 = 89.9
    b.ecc = 0.3
    b.w = 89
    b.L = 1.75e-3
    b[1, 0] = 0.5
    b[2, 1] = 0.1
    b[2, 2] = -0.05

    # Dipole-map hot jupiter
    c = Secondary(lmax=1)
    c.r = 0.12
    c.a = 80
    c.inc = 89.95
    c.porb = 100
    c.prot = 7.83
    c.lambda0 = 85
    c.ecc = 0.29
    c.w = 87.4
    c.L = 1.5e-3
    c[1, 0] = 0.4

    # Instantiate the system
    # We're adding a ton of light travel delay
    # and a finite exposure time: this is a
    # comprehensive test of the main `starry` features
    system = System(A, b, c)
github rodluger / starry / docs / tutorials / orbit_edgeon.py View on Github external
import starry
import numpy as np
import matplotlib.pyplot as pl

star = starry.kepler.Primary()
planet = starry.kepler.Secondary()
planet.porb=1
planet.prot=1
planet.a=50
planet[1, 0] = 0.5
system = starry.kepler.System(star, planet)
nt = 1000
system.compute(np.linspace(0, 1, nt))

fig, ax = pl.subplots(1, figsize=(8, 3.5))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
ax.plot(planet.X, planet.Y, color='k')
asini = 50 * np.sin(planet.inc * np.pi / 180)
acosi = 50 * np.cos(planet.inc * np.pi / 180)
ax.plot(np.array([-asini, asini]), np.array([-acosi, acosi]), 'k--', alpha=0.5)
ax.plot(0, 0, marker="*", color='k', ms=30)
ax.set_xlim(-50, 50)
github rodluger / starry / tex / figures / hd189733b.py View on Github external
lmax = 1
    lambda0 = 90
    r = 0.155313
    L = 0.00344
    inc = 85.71
    a = 8.863
    prot = 2.21858
    porb = 2.21858
    tref = -2.21858 / 2.

    # Instantiate the star
    star = starry.kepler.Primary()

    # Instantiate the planet
    planet = starry.kepler.Secondary(lmax=lmax)
    planet.lambda0 = lambda0
    planet.r = r
    planet.L = L
    planet.inc = inc
    planet.a = a
    planet.prot = prot
    planet.porb = porb
    planet.tref = tref

    # Instantiate the system
    system = starry.kepler.System(star, planet)

    return star, planet, system
github rodluger / starry / docs / tutorials / orbit_good.py View on Github external
ux, uy, uz = u
    R = np.zeros((3, 3))
    R[0, 0] = cost + ux ** 2 * (1 - cost)
    R[0, 1] = ux * uy * (1 - cost) - uz * sint
    R[0, 2] = ux * uz * (1 - cost) + uy * sint
    R[1, 0] = uy * ux * (1 - cost) + uz * sint
    R[1, 1] = cost + uy ** 2 * (1 - cost)
    R[1, 2] = uy * uz * (1 - cost) - ux * sint
    R[2, 0] = uz * ux * (1 - cost) - uy * sint
    R[2, 1] = uz * uy * (1 - cost) + ux * sint
    R[2, 2] = cost + uz ** 2 * (1 - cost)
    return R


star = starry.kepler.Primary()
planet = starry.kepler.Secondary()
planet.inc=60
planet.Omega=30
planet.porb=1
planet.prot=1
planet.a=50
planet[1, 0] = 0.5
system = starry.kepler.System(star, planet)
nt = 1000
system.compute(np.linspace(0, 1, nt))

fig, ax = pl.subplots(1, figsize=(8, 6.5))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
ax.plot(planet.X, planet.Y, color='k')
asini = 50 * np.sin(planet.inc * np.pi / 180)
acosi = 50 * np.cos(planet.inc * np.pi / 180)
ax.plot(np.array([-asini, asini]), np.array([-acosi, acosi]), 'k--', alpha=0.5)
github rodluger / starry / docs / tutorials / orbit_bad.py View on Github external
import starry
import numpy as np
import matplotlib.pyplot as pl

star = starry.kepler.Primary()
planet = starry.kepler.Secondary()
planet.inc=60
planet.Omega=30
planet.porb=1
planet.prot=1
planet.a=50
planet[1, 0] = 0.5
system = starry.kepler.System(star, planet)
nt = 1000
system.compute(np.linspace(0, 1, nt))

fig, ax = pl.subplots(1, figsize=(8, 6.5))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
ax.plot(planet.X, planet.Y, color='k')
asini = 50 * np.sin(planet.inc * np.pi / 180)
acosi = 50 * np.cos(planet.inc * np.pi / 180)
ax.plot(np.array([-asini, asini]), np.array([-acosi, acosi]), 'k--', alpha=0.5)
github rodluger / starry / starry / kepler.py View on Github external
def __init__(self, map, **kwargs):
        # Initialize `Body`
        super(Secondary, self).__init__(map, **kwargs)
        for kw in [
            "r",
            "m",
            "prot",
            "t0",
            "theta0",
            "length_unit",
            "mass_unit",
            "time_unit",
            "angle_unit",
        ]:
            kwargs.pop(kw, None)

        # Attributes
        if kwargs.get("porb", None) is not None:
            self.porb = kwargs.pop("porb", None)