How to use the starry.Star 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_transits.py View on Github external
f = 2 * np.pi / P * time
    b = a * np.sqrt(1 - np.sin(np.pi / 2. + f) ** 2
                    * np.sin(inc * np.pi / 180) ** 2)
    nF = np.zeros_like(time)
    for i in range(npts):
        nF[i] = NumericalFlux(b[i], rplanet, u1, u2)
    nF /= np.nanmax(nF)
    den = (1 - nF)
    den[den == 0] = 1e-10

    # Compute the starry flux
    # Instantiate a second-order map and a third-order map with u(3) = 0
    # The second-order map is optimized for speed and uses different
    # equations, but they should yield identical results.
    for lmax in [2, 3]:
        star = Star(lmax)
        star.map[1] = u1
        star.map[2] = u2
        planet = Planet(r=rplanet, a=a, inc=inc, porb=P, lambda0=90)
        system = System([star, planet])
        system.compute(time)
        sF = np.array(star.flux)
        sF /= sF[0]

        # Compute the error, check that it's better than 1 ppb
        error = np.max((np.abs(nF - sF) / den)[np.where(nF < 1)])
        assert error < 1e-9
github rodluger / starry / misc / delay.py View on Github external
"""Testing light travel time delay."""
import numpy as np
import matplotlib.pyplot as pl
import starry

star = starry.Star()
planet = starry.Planet(L=1e-1, prot=1, porb=1, r=1, Omega=1)
sys = starry.System([star, planet])
planet.a /= 50
time = np.linspace(0.4999, 0.5001, 100000)

for R in [0, 1, 5, 10]:
    sys.scale = R
    sys.compute(time)
    a = planet.a * R * 0.00464913034
    pl.plot(time, planet.flux, label="a=%.3f AU" % a)

    print("Secondary eclipse time: ", time[np.argmin(planet.flux)])
    print("Analytic solution: ", 0.5 + 2 * planet.a * R * 6.957e8 /
          299792458 / 86400)

pl.legend()
github rodluger / starry / misc / inclined.py View on Github external
inc = planet.inc * np.pi / 180
    Omega = planet.Omega * np.pi / 180

    # Rotate the map to the correct orientation on the sky
    planet.map.rotate(axis=(1, 0, 0), theta=np.pi / 2 - inc)
    planet.map.rotate(axis=(0, 0, 1), theta=Omega)

    # Rotate the axis of rotation in the same way
    planet.axis = np.dot(R((1, 0, 0), np.pi / 2 - inc), planet.axis)
    planet.axis = np.dot(R((0, 0, 1), Omega), planet.axis)


# Instantiate the system
planet = starry.Planet(L=1, porb=1, prot=1)
star = starry.Star()
sys = starry.System([star, planet])
time = np.linspace(0, 1, 1000)
Omega = 0
planet.Omega = Omega

# Set up the figure
fig = pl.figure(figsize=(12, 6))
ax = np.array([[pl.subplot2grid((5, 16), (i, j)) for j in range(8)]
               for i in range(5)])
ax_lc = pl.subplot2grid((5, 16), (0, 9), rowspan=5, colspan=8)
x, y = np.meshgrid(np.linspace(-1, 1, 100), np.linspace(-1, 1, 100))
lam = np.linspace(0, 2 * np.pi, 8, endpoint=False)
phase = np.linspace(90, 450, 1000)
phase[np.argmax(phase > 360)] = np.nan
phase[phase > 360] -= 360
github rodluger / starry / misc / luminosity_units.py View on Github external
"""Test the luminosity units."""
import matplotlib.pyplot as pl
import starry
import numpy as np

star = starry.Star()
planet = starry.Planet(L=1e-2, r=0.1, a=3)
sys = starry.System([star, planet])
time = np.linspace(0.25, 1.25, 10000)
sys.compute(time)
pl.plot(time, sys.flux, label="Uniform")

star[1] = 0.4
star[2] = 0.26
sys.compute(time)
pl.plot(time, sys.flux, label="Limb-Darkened")

pl.legend()
pl.show()
github rodluger / starry / tex / figures / spidercomp.py View on Github external
spider_params.rp = 0.1594           # Planet to star radius ratio
    spider_params.a = 4.855             # Semi-major axis scaled by rstar
    spider_params.p_u1 = 0.0            # Planetary limb darkening parameter
    spider_params.p_u2 = 0.0            # Planetary limb darkening parameter

    # SPIDERMAN spherical harmonics parameters
    ratio = 1.0e-3                                  # Planet-star flux ratio
    spider_params.sph = [ratio, ratio / 2, 0, 0]      # vector of Ylm coeffs
    spider_params.degree = 2
    spider_params.la0 = 0.0
    spider_params.lo0 = 0.0

    # Define starry model parameters to match SPIDERMAN system

    # Define star
    star = starry.Star()

    # Define planet
    planet = starry.Planet(lmax=2,
                           lambda0=90.0,
                           w=spider_params.w,
                           r=spider_params.rp,
                           # Factor of pi to match SPIDERMAN normalization
                           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
github rodluger / starry / tex / figures / system.py View on Github external
fig, ax = pl.subplots(2, figsize=(12, 6))
fig.subplots_adjust(hspace=0.35)
ax[0].set_ylabel('Normalized flux', fontsize=16)
ax[0].set_xlabel('Time [days]', fontsize=16)
ax[1].set_ylabel('Normalized flux', fontsize=16)
ax[1].set_xlabel('Time [days]', fontsize=16)
ax[0].set_xlim(0, 20)
ax[1].set_xlim(0, 20)
time = np.linspace(0, 20, 10000)


# System #1: A one-planet system with a hotspot offset
# ----------------------------------------------------

# Instantiate the star
star = Star()

# Give the star a quadratic limb darkening profile
star.map[1] = 0.4
star.map[2] = 0.26

# Instantiate planet b
b = Planet(r=0.091679,
           L=5e-3,
           inc=90,
           porb=4.3,
           prot=4.3,
           a=11.127991,
           lambda0=90,
           tref=2,
           axis=[0, 1, 0])