Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
These "constraints" should not be confused with priors - they should not
constrain the limits of a particular parameter for fitting, but rather
should constrain a parameter to be some function of other parameters.
"""
"""
Example with existing parameters
------------------------------------
Let's start with the default binary
"""
import phoebe
logger = phoebe.get_basic_logger()
b = phoebe.Bundle()
print b.list
"""
Output::
new_system (BodyBag)
|
+----------> primary (BinaryRocheStar)
|
+----------> secondary (BinaryRocheStar)
"""
"""
by default this binary consists of two components ('primary' and 'secondary'),
* Claret's limbdarkening law
* Spherical stellar surfaces (i.e. not rotationally deformed)
* Intensities in SDSS.GP and SDSS.RP band
Initialisation
--------------
"""
# First, import the necessary modules
import time
import matplotlib.pyplot as plt
import numpy as np
import phoebe
logger = phoebe.get_basic_logger()
c0 = time.time()
# Parameter preparation
#----------------------
# Create a ParameterSet with parameters of the binary system. We add common
# default constraints, so that more information is accessible (such as the
# individual masses). Most of the default parameters are kept, except the
# value for the semi-major axis ``sma``.
# Next, create the parameters of the uniform source. This includes a parameter
# that sets the density of the mesh, and also the radius of the secondary
# sphere, because we will need that in the computation of the analytical flux.
# The second sphere will have a radius half of the primary.
deceleration, as well as solid-body rotation. For each of these examples,
we compute an image, an effective temperature map and a radial velocity map.
Finally, the spectroscopic line profile is computed for each of them.
Initialisation
--------------
"""
# First, import necessary modules
import time
import numpy as np
from matplotlib import pyplot as plt
import phoebe
c0 = time.time()
logger = phoebe.get_basic_logger()
# Parameter preparation
# ---------------------
# Create a ParameterSet with parameters closely matching Vega. We use a
# Kurucz atmosphere and set the rotation period to about 50% of the
# critical rotation period of Vega.
star = phoebe.ParameterSet(context='star')
star['rotperiod'] = 22.8,'h'
star['teff'] = 8900.,'K'
star['mass'] = 2.3,'Msol'
star['gravb'] = 1.0
star['radius'] = 2.26,'Rsol'
star['incl'] = 90.,'deg'
star['atm'] = 'kurucz'
star['ld_coeffs'] = 'kurucz'
Astrometry: Lambda Aquarius (ecliptic plane)
HIP112961
"""
x, y = setup_star( 19.51,32.71,343.15360192,-7.5796787, 1000./8.33)
x_,y_ = np.loadtxt(os.path.join(basedir,'lam_aqr.pm'), unpack=True)
assert(np.allclose(x,x_,atol=1.e-5))
assert(np.allclose(y,y_,atol=1.e-5))
#np.savetxt('lam_aqr.pm', np.column_stack([x,y]))
#return x,y
if __name__ == "__main__":
import matplotlib.pyplot as plt
logger = phoebe.get_basic_logger()
test_eta_dra()
#plt.subplot(111,aspect='equal')
#plt.plot(x,y,'k-')
output =test_polaris(return_output=True)
if output is not None:
plt.figure()
plt.subplot(111,aspect='equal')
plt.plot(output[0][0]-output[1][0],output[0][1]-output[1][1])
plt.title('error in polaris')
print(output[0])
print(output[1])
plt.show()
test_lam_aqr()
"""
Simple binary (fitting)
==========================
In this example we'll create a simple binary, starting from two stars, and
fit it. We'll use the results from the other simple binary tutorial as input
observations.
"""
# Import necessary modules and set up a logger.
import phoebe
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.get_basic_logger()
# Parameter preparation
#-----------------------
# Define two stars, and set some of their parameters to be not the default ones.
star1 = phoebe.ParameterSet('star', mass=1.2, radius=1.1, teff=6321.,
atm='kurucz', ld_coeffs='kurucz', ld_func='claret')
star2 = phoebe.ParameterSet('star', mass=0.8, radius=0.9, teff=4123.,
atm='kurucz', ld_coeffs='kurucz', ld_func='claret')
# Derive component parameters (i.e. Roche potentials, synchronicity parameters)
# and orbit parameters (semi-major axis) from the stellar parameters. We need
# set of course the period of the system. Let's take 10 days.
comp1, comp2, orbit = phoebe.create.binary_from_stars(star1, star2, period=(10.,'d'))
The parameters for the mode are also greatly exaggerated for the purpose of
generating nice images rather than representing any physical reality. In
particular, the temperature amplitude is gigantic and only chosen such that
the intensity varies visibly over the surface.
Initialisation
--------------
"""
# Import necessary modules
import numpy as np
from matplotlib import pyplot as plt
import phoebe
from phoebe.utils import pergrams
logger = phoebe.get_basic_logger()
# Parameter preparation
# ---------------------
# Create a ParameterSet with parameters matching 12 Lac.
lac = phoebe.ParameterSet(frame='phoebe',context='star',add_constraints=True)
lac['teff'] = 25600.
lac['incl'] = 90.,'deg'
lac['radius'] = 8.8,'Rsol'
lac['mass'] = 14.4,'Msol'
lac['rotperiod'] = 2.925,'d'
lac['ld_func'] = 'claret'
lac['atm'] = 'kurucz'
lac['ld_coeffs'] = 'kurucz'
lac['shape'] = 'sphere'
mesh = phoebe.ParameterSet(context='mesh:marching',alg='c')
* The limb darkening is parametrizable via Claret's 4-parameter law
* It has a spherical surface (i.e. not rotationally deformed)
Initialisation
--------------
"""
# First, we need to import the Phoebe namespace and create a basic logger
# to log information to the screen.
import time
import numpy as np
import phoebe
from phoebe.atmospheres import limbdark
from phoebe.parameters import tools
logger = phoebe.get_basic_logger()
c0 = time.time()
# Parameter preparation
# ---------------------
# Most objects we place in the :py:mod:`universe `, need some set of parameters. Therefore,
# we start with the default ParameterSet linked to a specific object. In the
# case of the Sun, which we want to model as a single star, we need the default
# ParamaterSet of the :ref:`Star ` body. We're lucky, since most of the default
# parameters are set to represent the Sun, so we don't need to set the
# effective temperature, radius etc.
# Extra parameters that we set here concern the shape of the surface (``shape``),
# the distance to the Sun from the Earth (``distance``), the type of atmosphere
# to use for the emergent fluxes (``atm``) and limb darkening coefficients.
sun = phoebe.ParameterSet(context='star')
* spherical surface (i.e. not Roche-deformed)
* linear limbdarkening law
* Black body atmosphere
Initialisation
--------------
"""
# First, import the necessary modules and create a logger to show messages
# to the screen:
import time
import numpy as np
from matplotlib import pyplot as plt
import phoebe
logger = phoebe.get_basic_logger()
c0 = time.time()
# Parameter preparation
# ---------------------
# Create a :ref:`star ParameterSet ` with parameters
# matching the Sun, but make a fine-enough mesh. Also, the rotation period is
# set to almost 90% of the Sun's critical rotation period.
star = phoebe.ParameterSet(context='star')
star['atm'] = 'blackbody'
star['ld_func'] = 'linear'
star['ld_coeffs'] = [0.6]
star['rotperiod'] = 0.24,'d'
star['shape'] = 'sphere'
star['teff'] = 10000.
* The limb darkening is parametrizable via Claret's 4-parameter law
* It has a spherical surface (i.e. not rotationally deformed)
Initialisation
--------------
First, we need to import the Phoebe namespace and create a basic logger
to log information to the screen.
"""
import numpy as np
import matplotlib.pyplot as plt
import phoebe
from phoebe.atmospheres.limbdark import sphere_intensity
logger = phoebe.get_basic_logger()
"""
Parameter preparation
---------------------
Starting with PHOEBE 2.0, the implementation of a shiney new front-end interface makes system set up much easier
than with previous iterations of PHOEBE. The front-end provides many pre-set Bundles from :py:mod:``
instead of having to build a :ref:`Star ` Body from an empty ParameterSet. Since we are working with
the Sun in this example, we can use the preset bundle for the Sun and tweak a few parameters.
"""
sun = phoebe.Bundle('sun')
"""
With this, we've set up a single star body with a full attached ParamaterSet. To view the parameters we simply issue:
"""
import glob
import pyfits
import numpy as np
import matplotlib.pyplot as plt
import phoebe
import sys
#from phoebe.atmospheres import limbdark
from phoebe.atmospheres import create_atmospherefits as limbdark
logger = phoebe.get_basic_logger(clevel='INFO')
def build_grid(filetag='kurucz', passbands=None, ld_func='claret', fitmethod='equidist_r_leastsq',
limb_zero=True,
redlaw='fitzpatrick2004', Rv=3.1, z='p00', vmic=2, ebvs=None,
vgamma=None, add_boosting_factor=True):
if passbands is None:
passbands = ('MOST.V','COROT.SIS','COROT.EXO','KEPLER.V',
'2MASS.J','2MASS.H','2MASS.KS','OPEN.BOL',
'JOHNSON.V','JOHNSON.U','JOHNSON.B','JOHNSON.J','JOHNSON.H','JOHNSON.K',
'STROMGREN.U','STROMGREN.B','STROMGREN.V','STROMGREN.Y',
'TYCHO2.BT','TYCHO2.VT','HIPPARCOS.HP',
'ANS.15N','ANS.15W','ANS.18',
'ANS.25','ANS.33',
'JOHNSON.L','JOHNSON.M','GENEVA.V','GENEVA.B','JOHNSON.I',
'GENEVA.V1','JOHNSON.R',