Beispiel #1
0
def test_latexrepr(verbose=False):

    b = phoebe.default_binary(contact_binary=True)
    b.add_dataset('lc')
    b.add_dataset('rv')
    b.add_dataset('mesh')
    b.add_dataset('lp')

    b.add_compute('legacy')
    # b.add_compute('photodynam')
    b.add_compute('jktebop')
    b.add_compute('ellc')

    b.add_spot(component='primary')
    b.add_gaussian_process(dataset='lc01')

    for param in b.to_list():
        if verbose:
            print("param: {}".format(param.twig))
        param.latextwig

    b = phoebe.default_star()
    for param in b.to_list():
        if verbose:
            print("param: {}".format(param.twig))
        param.latextwig

    return b
Beispiel #2
0
def test_sun(plot=False):
    b = phoebe.default_star(starA='sun')

    b.set_value('teff', 1.0*u.solTeff)
    b.set_value('requiv', 1.0*u.solRad)
    b.set_value('mass', 1.0*u.solMass)
    b.set_value('period', 24.47*u.d)

    b.set_value('incl', 23.5*u.deg)
    b.set_value('distance', 1.0*u.AU)

    assert(b.get_value('teff', u.K)==5772)
    assert(b.get_value('requiv', u.solRad)==1.0)
    assert(b.get_value('mass', u.solMass)==1.0)
    assert(b.get_value('period', u.d)==24.47)
    assert(b.get_value('incl', u.deg)==23.5)
    assert(b.get_value('distance', u.m)==1.0*u.AU.to(u.m))

    b.add_dataset('lc', pblum=1*u.solLum)
    b.add_dataset('mesh', times=[0], columns=['teffs', 'areas', 'volume'], dataset='mesh01')

    b.run_compute(irrad_method='none', distortion_method='rotstar')

    #print abs(b.get_value('teffs', dataset='pbmesh').mean()-b.get_value('teff', context='component'))

    assert(abs(np.average(b.get_value('teffs', dataset='mesh01'), weights=b.get_value('areas', dataset='mesh01')) - b.get_value('teff', context='component')) < 1e-6)
    assert(abs(b.get_value('volume', dataset='mesh01')-4./3*np.pi*b.get_value('requiv', context='component')**3) < 1e-6)

    #print abs(b.get_value('fluxes@model')[0]-1357.12228578)

    if plot:
        axs, artists = b['mesh01'].plot(facecolor='teffs', show=True)

    return b
Beispiel #3
0
def single_star_lc(stellar_params,
        use_blackbody_atm=False,
        num_triangles=1500):
    # Read in the stellar parameters of the current star
    (star_mass, star_rad, star_teff, star_logg,
     [star_mag_Kp, star_mag_H],
     [star_pblum_Kp, star_pblum_H]) = stellar_params
    
    err_out = np.array([-1.])

    # Set up a single star model
    sing_star = phoebe.default_star()
    
    # Light curve dataset
    if use_blackbody_atm:
        sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_Kp', passband='Keck_NIRC2:Kp', ld_func='linear', ld_coeffs=[0.0])
        sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_H', passband='Keck_NIRC2:H', ld_func='linear', ld_coeffs=[0.0])
        # sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_V', passband='Johnson:V', ld_func='linear', ld_coeffs=[0.0])
    else:
        sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_Kp', passband='Keck_NIRC2:Kp')
        sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_H', passband='Keck_NIRC2:H')
        # sing_star.add_dataset(phoebe.dataset.lc, times=[0], dataset='mod_lc_V', passband='Johnson:V')
    
    # Set up compute
    if use_blackbody_atm:
        sing_star.add_compute('phoebe', compute='detailed', distortion_method='sphere', irrad_method='none', atm='blackbody')
    else:
        sing_star.add_compute('phoebe', compute='detailed', distortion_method='sphere', irrad_method='none')
    
    # Set a default distance
    sing_star.set_value('distance', 10 * u.pc)
    
    # Set the passband luminosities
    sing_star.set_value('pblum@mod_lc_Kp', star_pblum_Kp)
    sing_star.set_value('pblum@mod_lc_H', star_pblum_H)
    
    # Set the stellar parameters
    sing_star.set_value('teff@component', star_teff)
    sing_star.set_value('requiv@component', star_rad)
    
    # Set the number of triangles in the mesh
    sing_star.set_value('ntriangles@detailed@compute', num_triangles)
    
    # Run compute
    try:
        sing_star.run_compute(compute='detailed', model='run',
                              progressbar=False)
    except: # Catch errors during computation (probably shouldn't happen during individual star computation)
        print("Error during primary ind. star compute: {0}".format(sys.exc_info()[0]))
        return (err_out, err_out)
    
    # Retrieve computed fluxes from phoebe
    sing_star_fluxes_Kp = np.array(sing_star['fluxes@lc@mod_lc_Kp@model'].value) * u.W / (u.m**2)
    sing_star_mags_Kp = -2.5 * np.log10(sing_star_fluxes_Kp / flux_ref_Kp) + 0.03
    
    sing_star_fluxes_H = np.array(sing_star['fluxes@lc@mod_lc_H@model'].value) * u.W / (u.m**2)
    sing_star_mags_H = -2.5 * np.log10(sing_star_fluxes_H / flux_ref_H) + 0.03
        
    return (sing_star_mags_Kp, sing_star_mags_H)
def test_all():
    print("phoebe.Bundle() ...")
    b = phoebe.Bundle()
    print("phoebe.default_star()) ...")
    b = phoebe.default_star()
    print("phoebe.default_binary() ...")
    b = phoebe.default_binary()
    print("phoebe.default_binary(contact_binary=True) ...")
    b = phoebe.default_binary(contact_binary=True)
def get_foreground_flux_tess(teff, d):
    base_flux = get_flux_value_tess(teff)
    d0 = 1
    #kepler passband flux
    star_pb1 = phoebe.default_star()
    star_pb1.set_value('teff', value=teff)
    star_pb1.add_dataset('lc',
                         dataset='lc01',
                         atm='blackbody',
                         ld_func='interp',
                         times=phoebe.linspace(0, 2, 101),
                         passband='TESS:default',
                         intens_weighting='energy')
    #    star_pb1.add_dataset('lc',dataset='lc01',ld_func='interp',times = phoebe.linspace(0,1,101),passband='TESS:default',intens_weighting='energy')
    star_pb1.run_compute(irrad_method='none')
    star_pb1_flux = star_pb1['value@fluxes@lc01@latest@model'] * (
        d0 / d)**2 * base_flux
    return star_pb1_flux
Beispiel #6
0
# As always, let's do imports and initialize a logger and a new bundle.  See [Building a System](../tutorials/building_a_system.html) for more details.

# In[1]:

get_ipython().run_line_magic('matplotlib', 'inline')

# In[2]:

import phoebe
from phoebe import u  # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

b = phoebe.default_star(starA='sun')

# Setting Parameters
# -----------------------

# In[3]:

print b['sun']

# Let's set all the values of the sun based on the nominal solar values provided in the units package.

# In[4]:

b.set_value('teff', 1.0 * u.solTeff)
b.set_value('rpole', 1.0 * u.solRad)
b.set_value('mass', 1.0 * u.solMass)
import phoebe

print("creating default_star.bundle")
b = phoebe.default_star(force_build=True)
b.save('./default_star.bundle', compact=True, incl_uniqueid=False)

print("creating default_binary.bundle")
b = phoebe.default_binary(force_build=True)
b.save('./default_binary.bundle', compact=True, incl_uniqueid=False)

print("creating default_contact_binary.bundle")
b = phoebe.default_binary(contact_binary=True, force_build=True)
b.save('./default_contact_binary.bundle', compact=True, incl_uniqueid=False)
Beispiel #8
0
# In[ ]:

get_ipython().system('pip install -I "phoebe>=2.1,<2.2"')

# As always, let's do imports and initialize a logger and a new bundle.  See [Building a System](../tutorials/building_a_system.html) for more details.

# In[1]:

import phoebe
from phoebe import u  # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

b = phoebe.default_star()

# Adding Spots
# ---------------------

# Let's add one spot to our star.  Since there is only one star, the spot will automatically attach without needing to provide component (as is needed in the [binary with spots example](./binary_spots)

# In[2]:

b.add_spot(radius=30, colat=80, long=0, relteff=0.9)

# Spot Parameters
# -----------------

# A spot is defined by the colatitude and longitude of its center, its angular radius, and the ratio of temperature of the spot to the local intrinsic value.
def test_star():
    b1 = phoebe.default_star(force_build=True)
    b2 = phoebe.default_star()
Beispiel #10
0
def test_all():
    b = phoebe.Bundle()
    b = phoebe.default_star()
    b = phoebe.default_binary()
    b = phoebe.default_binary(contact_binary=True)
Beispiel #11
0
plt.ylabel('flux')
plt.plot(times1,fluxes1,c='red',linewidth=0.5,label='kepler')
plt.plot(times2,fluxes2,c='blue',linewidth=0.5,label='tess')
plt.legend(loc='lower right')
plt.savefig("kepler_tess_cl.eps")

#including foreground bright star
#assumption the distance between binary and us is 1;
#the flux of foreground star 100 times the maximum of flux of binary
#the distance of the binary and foreground star is a function of flux, temperature

foreground_t=6000
d0=1
d=0.1
#kepler passband flux 
star_pb1=phoebe.default_star()
star_pb1.set_value('teff', value=6000)
star_pb1.add_dataset('lc',dataset='lc01',ld_func='interp',times = phoebe.linspace(0,2,101),passband='Kepler:mean',intens_weighting='energy')
star_pb1.run_compute(irrad_method='none')
star_pb1_flux=star_pb1['value@fluxes@lc01@latest@model']*(d0/d)**2

#Tess passband flux
star_pb2=phoebe.default_star()
star_pb2.set_value('teff', value=6000)
star_pb2.add_dataset('lc',dataset='lc01',ld_func='interp',times = phoebe.linspace(0,2,101),passband='TESS:default',intens_weighting='energy')
star_pb2.run_compute(irrad_method='none')
star_pb2_flux=star_pb1['value@fluxes@lc01@latest@model']*(d0/d)**2



fig=plt.figure()