How to use the phoebe.Bundle function in phoebe

To help you get started, we’ve selected a few phoebe 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 phoebe-project / phoebe2 / phoebe-testlib / test_interferometry / test_interferometry.py View on Github external
sep = np.sqrt((x1-x2)**2 + (y1-y2)**2)
        y = y2-y1
        if x2==x1 and y1y2:
            pa = 90.0
        else:
            pa = np.arctan((y1-y2)/(x2-x1))/np.pi*180.
        
        
        print('{} (sep={}, theta1={}, theta2={}, fr={}, y={}, pa={})'.format(ff, sep, ang_diam1, ang_diam2, fr, y, pa))
        
        
        # Define the system
        binary = phoebe.Bundle()
        binary.get_parameter('teff@primary').set_limits(0, 50000)
        binary.get_parameter('teff@secondary').set_limits(0, 50000)
        binary['period'] = 100000000.0
        binary['t0'] = 0.0 + 0.25*binary['period'] - pa/360.0*binary['period']
        binary['distance'] = 1.0, 'kpc'
        binary['sma'] = sep, 'au'
        binary['incl'] = 0., 'deg'
        phoebe.compute_pot_from(binary, ang_diam1/sep/2.0, component='primary')
        phoebe.compute_pot_from(binary, ang_diam2/sep/2.0, component='secondary')
        binary['teff@secondary'] = binary['teff@primary'] * fr**-0.25 * np.sqrt(ang_diam1/ang_diam2)
        binary.set_value_all('atm', 'blackbody')
        binary.set_value_all('ld_func', 'uniform')
        binary.set_value_all('delta', 0.2)
        binary.set_value_all('maxpoints', 300000)
        
        # Load the observations from a textfile
github phoebe-project / phoebe2 / phoebe-testlib / test_kpd1946 / kpd1946_testoversampling.py View on Github external
def test_boosting():
    """
    Boosting: amplitude match
    """
    phases = [0.75]
    bundle1 = phoebe.Bundle('KPD1946+4340')
    bundle1.data_fromarrays(phase=phases,passband='KEPLER.V', dataref='keplc')
    bundle1.run_compute(boosting_alg='simple')

    bundle2 = phoebe.Bundle('KPD1946+4340')

    bundle2.data_fromarrays(phase=phases,passband='KEPLER.V', dataref='keplc')
    bundle2.run_compute(boosting_alg='none')
    b1dat = bundle1.get_syn('keplc@KPD1946+4340') # doesn't work
    b2dat = bundle2.get_syn('keplc@KPD1946+4340') # doesn't work
    #b1dat = bundle1.get_system().get_synthetic()
    #b2dat = bundle2.get_system().get_synthetic()
        
    assert(b1dat['flux'][0]/b2dat['flux'][0]>1.0007 and b1dat['flux'][0]/b2dat['flux'][0]<1.0008)
github phoebe-project / phoebe2 / tests / nosetests / test_constructors / test_constructors.py View on Github external
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)
    # b = phoebe.default_triple(inner_as_primary=True)
github phoebe-project / phoebe2 / phoebe-testlib / 1to2 / 1to2.py View on Github external
timings = np.zeros((Ncurves, 10))

for i in range(Ncurves):
    
    # Set random parameters in Phoebe1
    phb.setpar("phoebe_pot1", st.uniform.rvs(4.0, 1.0))
    phb.setpar("phoebe_pot2", st.uniform.rvs(5.0, 1.0))
    phb.setpar("phoebe_incl", st.uniform.rvs(80, 10))
    phb.setpar("phoebe_ecc", st.uniform.rvs(0.0, 0.0))
    phb.setpar("phoebe_perr0", st.uniform.rvs(0.0, 2*np.pi))
    phb.setpar("phoebe_rm", st.uniform.rvs(0.5, 0.5))
    phb.setpar("phoebe_teff2", st.uniform.rvs(6000, 500))

    # Set parameters in Phoebe2 to match Phoebe1
    mybundle = phb2.Bundle('default.phoebe')

    mybundle.set_value('pot@primary', phb.getpar('phoebe_pot1'))
    mybundle.set_value('pot@secondary', phb.getpar('phoebe_pot2'))
    mybundle.set_value('incl', phb.getpar('phoebe_incl'))
    mybundle.set_value('ecc', phb.getpar('phoebe_ecc'))
    mybundle.set_value('per0', phb.getpar('phoebe_perr0'))
    mybundle.set_value('q', phb.getpar('phoebe_rm'))
    mybundle.set_value('teff@secondary', phb.getpar('phoebe_teff2'))

    # Report
    print("# Qual = Phoebe1 -- Phoebe2")
    print("# pot1 = %f -- %f" % (phb.getpar("phoebe_pot1"), mybundle.get_value('pot@primary')))
    print("# pot2 = %f -- %f" % (phb.getpar("phoebe_pot2"), mybundle.get_value('pot@secondary')))
    print("# incl = %f -- %f" % (phb.getpar("phoebe_incl"), mybundle.get_value('incl')))
    print("# ecc  = %f -- %f" % (phb.getpar("phoebe_ecc"), mybundle.get_value('ecc')))
    print("# per0 = %f -- %f" % (phb.getpar("phoebe_perr0"), mybundle.get_value('per0')))
github phoebe-project / phoebe2 / phoebe-testlib / 1to2 / volume.py View on Github external
import matplotlib.pyplot as plt
import numpy as np

def count_rectangles(N):
    count = 0
    theta = [np.pi/2*(k-0.5)/N for k in range(1,N+1)]
    for th in theta:
        Mk = 1+int(1.3*N*np.sin(th))
        phi = [np.pi*(l-0.5)/Mk for l in range(1,Mk+1)]
        count += len(phi)
    return 8*count

N = 200
delta = 0.012

eb = phb2.Bundle('default.phoebe')
eb['maxpoints@mesh:marching@primary'] = 1e8
eb['maxpoints@mesh:marching@secondary'] = 1e8
eb['pot@primary'] = 3.8
eb['pot@secondary'] = 3.8

deltas, Ntriangles, V12s, V22s = [], [], [], []
for delta in np.linspace(0.1, delta, 25):
    eb['delta@mesh:marching@primary'] = delta
    eb['delta@mesh:marching@secondary'] = delta
    eb.get_system().reset()
    eb.get_system().set_time(0)
    vol1_2 = eb.get_object('primary').volume()
    vol2_2 = eb.get_object('secondary').volume()
    deltas.append(delta)
    Ntriangles.append(len(eb['primary'].get_mesh()['teff']))
    V12s.append(vol1_2)
github phoebe-project / phoebe2 / phoebe-testlib / test_bundle / test_io.py View on Github external
def test_json():
    """
    Bundle: basic json input and output
    """
    mybundle = phoebe.Bundle()
    
    # attach a non-standard  parameter set
    #mybundle.attach_ps(phoebe.PS('reddening:interstellar'))
    mybundle.set_value('passband@reddening', 'JOHNSON.K')
    
    # change a value
    mybundle.set_value('period',200)
    
    # change adjust
    mybundle.set_adjust('period',True)

    # create a synthetic dataset
    mybundle.rv_fromarrays(phase=np.linspace(0,1,100),objref=['primary','secondary'],dataref='myrv_phase')
    mybundle.rv_fromarrays(time=np.linspace(0,1,50),objref='primary',dataref='myrv_time')
    mybundle.lc_fromarrays(time=np.linspace(0,1,10),dataref='mylc_time')
github phoebe-project / phoebe2 / tests / nosetests / test_blackbody / test_blackbody.py View on Github external
def test_binary(plot=False):
    b = phoebe.Bundle.default_binary()

    # Two spherical suns
    b.set_value_all('teff', value=5772.)
    b.set_value('sma', component='binary', value=100.)
    b.set_value('period', component='binary', value=81.955)

    b.add_dataset('lc', times=np.linspace(0,100,21))
    b.add_compute('phoebe', compute='phoebe2')
    b.add_compute('legacy', compute='phoebe1')

    # set matching atmospheres
    b.set_value_all('atm', 'extern_planckint')

    # turn off limb-darkening:
    b.set_value_all('ld_func_bol', 'linear')
    b.set_value_all('ld_coeffs_bol', [0.0])
github phoebe-project / phoebe2 / phoebe-testlib / test_tutorials / test_online_tutorial_03.py View on Github external
def test_02():
    """
    Test online tutorial 03 (OIFITS)
    """
    filename = os.path.join(basedir, 'example_oifits.fits')
    
    eb = phoebe.Bundle()
    eb['distance'] = 1, 'kpc'
    eb['period'] = 1e8, 'd'
    eb['t0'] = 56848.97824354 + 0.25*eb['period']
    eb['sma'] = 5, 'au'
    eb['incl'] = 0, 'deg'
    eb['pot@primary'] = 21.
    eb['pot@secondary'] = 21.
    eb['teff@primary'] = 6000.0
    eb['teff@secondary'] = 6000.0
    eb.set_value_all('atm', 'blackbody')
    eb.set_value_all('ld_func', 'uniform')
    
    eb.lc_fromarrays(phase=[0.25])
    
    #~ eb.plot_mesh(phase=0.25, dataref='lc01', label='preview')  # FIXING THIS SOON
github phoebe-project / phoebe2 / phoebe-testsuite / frontend_tutorials / first_binary_from_scratch.py View on Github external
"""
Building my first binary from scratch with PHOEBE 2.0-alpha
===========================================================

Last updated: ***time***

This tutorial will cover the basic steps of creating the model of a binary star using the PHOEBE 2.0-alpha frontend. All frontend functionality is documented in the frontend Application Programming Interface (API) and you can refer to it for further details on any of the used commands in this tutorial. If you haven't done so already, you may want to read the :doc:`First steps with PHOEBE 2.0-alpha ` tutorial first -- it covers the details that we will assume you are familiar with.

Ok, enough warnings and disclaimers, let us build our first binary from scratch! As before, we will start by creating a bundle. So fire up python, import phoebe and initialize a new bundle:
"""

import phoebe
eb = phoebe.Bundle()

"""
This will create a new binary with default parameters. Take some time to get familiar with the structure of the newly created system:
"""

print eb.summary()

"""
You can get further information on any part of the structure by accessing it explicitly, e.g.:
"""

print eb['position']
print eb['primary']

"""
or, to print all information on the system: