I am working on the file "2.0/tutorials/backend.ipynb".
The first task is:
We can easily check to make sure an eclipse happened by computing the ratio of triangles for each component that are currently visible.
Can you write Python code for it?

visibilities = system.meshes.get_column('visibilities')
print "primary visibility:", visibilities['primary'].sum() / len(visibilities['primary'])
print "secondary visibility:", visibilities['secondary'].sum() / len(visibilities['secondary'])


I am working on the file "2.0/tutorials/backend.ipynb".
The first task is:
We can pull any column out of the mesh in a similar dictionary style (with an entry for each component)
Can you write Python code for it?


I am working on the file "2.0/tutorials/backend.ipynb".
The first task is:
or as a single flat array
Can you write Python code for it?


I am working on the file "2.0/tutorials/beaming_boosting.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/beaming_boosting.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Can you write Python code for it?

b.run_compute(boosting_method='none', model='boosting_none')

b.run_compute(boosting_method='linear', model='boosting_linear')

axs, artists = b['lc01'].plot()
leg = plt.legend()

axs, artists = b['lc01'].plot(ylim=(1.01,1.03))
leg = plt.legend()


I am working on the file "2.0/tutorials/beaming_boosting.ipynb".
The first task is:
Influence on Meshes
Can you write Python code for it?

fig = plt.figure(figsize=(10,6))
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)

axs, artists = b['mesh@boosting_none'].plot(time=0.6, facecolor='boost_factors@lc01', edgecolor=None, ax=ax1)
axs, artists = b['mesh@boosting_linear'].plot(time=0.6, facecolor='boost_factors@lc01', edgecolor=None, ax=ax2)


I am working on the file "2.0/tutorials/beaming_boosting.ipynb".
The first task is:
Influence on Radial Velocities
Can you write Python code for it?

fig = plt.figure(figsize=(10,6))
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)

axs, artists = b['rv01@boosting_none'].plot(ax=ax1)
axs, artists = b['rv01@boosting_linear'].plot(ax=ax2)


I am working on the file "2.0/tutorials/beaming_boosting.ipynb".
The first task is:
Relevant Parameters
Can you write Python code for it?

b.set_value('irrad_method', 'none')

print b['boosting_method@compute']

print b['boosting_method@compute'].choices


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
But there are also shortcut methods for add_star and add_orbit.  In these cases you don't need to provide the function, but only the component tag of your star/orbit.
Any of these functions also accept values for any of the qualifiers of the created parameters.
Can you write Python code for it?


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
From now on, we'll just quickly do common setup at the beginning of each tutorial.
For full gory details on the general concepts here, make sure to read General Concepts.
We'll always start by doing our basic imports, setting up a logger, and initializing
an empty Bundle.
Can you write Python code for it?

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

logger = phoebe.logger()

b = phoebe.Bundle()


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
Here we call the add_component method of the bundle with several arguments:

a function (or the name of a function) in phoebe.parameters.component.  This
  function tells the bundle what parameters need to be added.
component: the tag that we want to give this component for future reference.
any additional keyword arguments: you can also provide initial values for Parameters
  that you know will be created.  In the last example you can see that the
  effective temperature will already be set to 6000 (in default units which is K).

and then we'll do the same to add an orbit:
Can you write Python code for it?


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
If you access the value that this set, you'll see that it really just resulted
in a simple string representation:
Can you write Python code for it?


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
Or you can ask for the component tag of the top-level item in the hierarchy
Can you write Python code for it?


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
This hierarchy parameter then has several methods unique to itself.  You can, for instance, list the component tags of all the stars or orbits in the hierarchy:
Can you write Python code for it?

print b.hierarchy.get_stars()

print b.hierarchy.get_orbits()


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
We can also check whether a given component (by component tag) is the primary or secondary component in its parent orbit.  Note that here its just a coincidence (although on purpose) that the component tag is also 'secondary'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/building_a_system.ipynb".
The first task is:
or through any of these shortcuts:
Can you write Python code for it?


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
Adding Compute Options
In other cases, we may want to manually add additional sets of compute options.
This syntax should look very familiar by now, it takes a function (or the name of a recognized function in phoebe.parameters.compute) and then any
kwargs to set in that ParameterSet.
Let's say that we want to create two sets of compute options - in this example, we'll create one called 'preview' which will cut some corners to quickly get us a model, and one called 'detailed' which will get a much more precise model but likely take longer.  As with other tags, the string you provide for the compute tag is up to you (so long as it doesn't raise an error because it conflicts with other tags).
Can you write Python code for it?

b.add_compute(phoebe.compute.phoebe, compute='preview', irrad_method='none')

print b['preview@compute']

b.add_compute('phoebe', compute='detailed', irrad_method='wilson')

print b.get_compute('detailed')


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
And we'll attach some dummy datasets.  See Datasets for more details.
Can you write Python code for it?

b.add_dataset(phoebe.dataset.orb, times=np.linspace(0,10,10), dataset='orb01', component=['primary', 'secondary'])

times, fluxes, sigmas = np.loadtxt('test.lc.in', unpack=True)

# test.lc.in has 1000 datapoints... let's use every 10 just for brevity
times, fluxes, sigmas = times[:10], fluxes[:10], sigmas[:10]

b.add_dataset(phoebe.dataset.lc, times=times, fluxes=fluxes, sigmas=sigmas, dataset='lc01')


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
Default Compute Options
Any default Bundle already has a set of default compute options to run the backend for PHOEBE 2.  In most cases, you can just edit the options in this default set of compte options.
Can you write Python code for it?

print b.computes

print b.filter(context='compute')

b.set_value('irrad_method', 'none')


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
Editing Compute Options
Backend-Specific Compute Options
Most of the parameters in the compute options are specific to the backend being used.  Here, of course, we're using the PHOEBE 2.0 backend - but for details on other backends see the Alternate Backends Tutorial.
The PHOEBE 2.0 compute options are described in the tutorial on their relevant dataset types:

Orbits (orb)
Meshes (mesh)
Light Curves/Fluxes (lc)
Radial Velocities (rv)

Enabling/Disabling Datasets
By default, synthetic models will be created for all datasets in the Bundle when run_compute is called.  But you can disable a dataset to have run_compute ignore that dataset.  This is handled by a BoolParameter with the qualifier 'enabled' - and has a copy that lives in each set of compute options
Let's say we wanted to compute the orbit but not light curve - so we want to see enabled@lc01:
Can you write Python code for it?


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
So in this case, 'lc01' will be computed using the options in 'detailed' while 'orb01' will use the options in 'preview'.
Can you write Python code for it?

b.run_compute(compute=['detailed', 'preview'], model='multiplecompute')

b.models


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
Storing Models
Now let's compute models for three different 'versions' of parameters.  By providing a model tag, we can keep the synthetics for each of these different runs in the bundle - which will be handy later on for plotting and comparing models.
Can you write Python code for it?

b.set_value('incl@orbit', 90)
b.run_compute(compute='preview', model='run_with_incl_90')

b.set_value('incl@orbit', 85)
b.run_compute(compute='preview', model='run_with_incl_85')

b.set_value('incl@orbit', 80)
b.run_compute(compute='preview', model='run_with_incl_80')


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
We will now have three new sets of synthetics which can be compared, plotted, or removed.
Can you write Python code for it?


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
as you can see, there is a copy for both of our compute options ('preview' and 'detailed').
If we know which set of compute options we'll be using, or only want to enable/disable for a given set, then we can do that:
Can you write Python code for it?

b['enabled@lc01@preview'] = False
print b['enabled@lc01']


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
or of course through method access:
Can you write Python code for it?

print b.get_value(qualifier='xs', dataset='orb01', component='primary', model='run_with_incl_90')[:10]


I am working on the file "2.0/tutorials/compute.ipynb".
The first task is:
or to enable/disable a dataset for all sets of compute options, we can use the set_value_all method:
Can you write Python code for it?

b.set_value_all('enabled@lc01', False)
print b['enabled@lc01']


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Changing Hierarchies
NOTE: this is an experimental feature.  Just as when re-parameterizing, please be
careful and make sure all results and parameters make sense.
Some of the built-in constraints depend on the system hierarchy, and will automatically adjust to reflect changes to the hierarchy.
For example, the masses depend on the period and semi-major axis of the parent orbit but also depend on the mass-ratio (q) which is defined as the primary mass over secondary mass.  For this reason, changing the roles of the primary and secondary components should be reflected in the masses (so long as q remains fixed).
In order to show this example, let's set the mass-ratio to be non-unity.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Even though under-the-hood the constraints are being rebuilt from scratch, they will remember if you have flipped them to solve for some other parameter.
To show this, let's flip the constraint for the secondary mass to solve for 'period' and then change the hierarchy back to its original value.
Can you write Python code for it?

print "M1: {}, M2: {}, period: {}, q: {}".format(b.get_value('mass@primary@component'),
                                                 b.get_value('mass@secondary@component'),
                                                 b.get_value('period@binary@component'),
                                                 b.get_value('q@binary@component'))

b.flip_constraint('mass@secondary@constraint', 'period')

print "M1: {}, M2: {}, period: {}, q: {}".format(b.get_value('mass@primary@component'),
                                                 b.get_value('mass@secondary@component'),
                                                 b.get_value('period@binary@component'),
                                                 b.get_value('q@binary@component'))

b.set_value('mass@secondary@component', 1.0)

print "M1: {}, M2: {}, period: {}, q: {}".format(b.get_value('mass@primary@component'),
                                                 b.get_value('mass@secondary@component'),
                                                 b.get_value('period@binary@component'),
                                                 b.get_value('q@binary@component'))


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Here the star with component tag 'primary' is actually the primary component in the hierarchy, so should have the LARGER mass (for a q < 1.0).
Can you write Python code for it?

print "M1: {}, M2: {}".format(b.get_value('mass@primary@component'),
                              b.get_value('mass@secondary@component'))


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Here we see the equation used to derive the mass of the primary star
from its orbit, as well as the current value
If we access the Parameter that it is constraining we can see that it
is automatically kept up-to-date.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Notice that the qualifier tag has changed from 'mass' to 'period' and the 'component' tag has changed from 'primary' to 'binary' (since sma is in the binary).
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
Now let's flip the hierarchy so that the star with the 'primary' component tag is actually the secondary component in the system (and so takes the role of numerator in q = M2/M1).
For more information on the syntax for setting hierarchies, see the Building a System Tutorial.
Can you write Python code for it?

b.set_hierarchy('orbit:binary(star:secondary, star:primary)')

print b.get_value('q')

print "M1: {}, M2: {}".format(b.get_value('mass@primary@component'),
                              b.get_value('mass@secondary@component'))


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
To see what all of these constraints do, see the 'Built-in Constraints' section below.
For now let's look at a single constraint.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
What are Constraints?
Constraints live in their own context of the Bundle, and many are created
by default - either when you add a component or when you set the system hierarchy.
Let's look at all the existing constraints for our binary system.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
You'll see that when we set the primary mass, the secondary mass has also changed (because the masses are related through q) and the period has changed (based on resolving the Kepler's third law constraint).
Note that the tags for the constraint are based on those of the constrained parameter, so to switch the parameterization back, we'll have to use a slightly different twig.
Can you write Python code for it?

print b['constraint']

b['period@constraint@binary']

b['period@constraint@binary'].meta


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
component sma
This constraint handles computing the semi-major axis of a component about the center of mass of its parent orbit.  Note that this is not the same as the semi-major axis of the parent orbit.
This currently can be inverted to solve for 'sma' of the parent orbit, but not 'q'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
esinw, ecosw
These constraints handle computing the projected eccentricity which can be helpful in that they are better representations of the geometry of a light curve and result in symmetric posteriors for near-circular orbits.
Both can be inverted to also automatically solve for 'ecc' or 'per0'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
freq
This constraint handles the simple conversion to frequency from period - whether that be rotational or orbital - and does support inversion to solve for 'period'.
Can you write Python code for it?

b['freq@constraint']

b['freq@binary@constraint']

b['freq@primary@constraint']


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
inclination (aligned binary)
This constraint handles requiring the inclination of a star to be the same as that of the parent orbit.  With the constraint enabled, the binary is required to be "aligned".  Disabling this constraint (which currently is not yet supported) will allow for misaligned binaries.
This constraint can be inverted to solve for either 'incl'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
rotation period
This constraint handles computing the rotation period of a star given its synchronicity parameter (syncpar).
It can be inverted to solve for any of the three parameters 'period' (both rotational and orbital) and 'syncpar'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/constraints.ipynb".
The first task is:
t0
This constraint handles converting between different t0 conventions - namely providing a reference time at periastron passage (t0_perpass) and at superior conjunction (t0_supconj).
Currently, this constraint only supports inverting to be solved for 't0_supconj' (ie you cannot automatically invert this constraint to constraint phshift or per0).
Can you write Python code for it?


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
All of these by default use the period in the top-level of the current hierarchy,
but accept a component keyword argument if you'd like the ephemeris of an
inner-orbit or the rotational ephemeris of a star in the system.
We'll see how plotting works later, but if you manually wanted to plot the dataset
with phases, all you'd need to do is:
Can you write Python code for it?


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Alternatively, you could of course not pass the values while calling add_dataset and instead call the set_value method after and explicitly state the components at that time.
With Passband Options
Passband options follow the exact same rules as dataset columns.
Sending a single value to the argument will apply it to each component in which the time array is attached (either based on the list of components sent or the defaults from the dataset method).
Note that for light curves, in particular, this rule gets slightly bent.  The dataset arrays for light curves are attached at the system level, always.  The passband-dependent options, however, exist for each star in the system.  So, that value will get passed to each star if the component is not explicitly provided.
Can you write Python code for it?

b.add_dataset('lc', times=[0,1], ld_func='logarithmic', ld_coeffs=[0,0], dataset='lc02')

print b['times@lc02']

print b['ld_coeffs@lc02']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
As you could probably predict by now, add_dataset can either take a function or the name of a function in phoebe.parameters.dataset.  The following line would do the same thing (except we'll give it a new dataset tag to avoid throwing an error).
Can you write Python code for it?

b.add_dataset('orb', times=np.linspace(0,10,20), dataset='orb02', component=['primary', 'secondary'])


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
As you might expect, if you want to pass different values to different components, simply provide them in a dictionary.
Can you write Python code for it?

b.add_dataset('lc', times=[0,1], ld_func='logarithmic', ld_coeffs={'primary': [0,0], 'secondary': [0.25, 0.25]}, dataset='lc03')

print b['ld_coeffs@lc03']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
But remove_dataset also takes any other tag(s) that could be sent to filter.
Can you write Python code for it?


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Enabling and Disabling Datasets
See the Compute Tutorial
Dealing with Phases
Datasets will no longer accept phases.  It is the user's responsibility to convert
phased data into times given an ephemeris.  But it's still useful to be able to
convert times to phases (and vice versa) and be able to plot in phase.
The following functions handle those conversions:
Can you write Python code for it?

print b.get_ephemeris()

print b.to_phase(0.0)

print b.to_time(-0.25)


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
For datasets which attach to individual components, however, this isn't always the desired behavior.
For a single-lined RV where we only attach to one component, everything is as expected.
Can you write Python code for it?

b.add_dataset('rv', times=[0,1], rvs=[-3,3], dataset='rv02', component='primary')

print b['rvs@rv02']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Here we added an RV dataset and can see that it was automatically created for both stars in our system.  Under-the-hood, another entry is created for component='_default'.  The default parameters hold the values that will be replicated if a new component is added to the system in the future.  In order to see these hidden parameters, you need to pass check_default=False to any filter-type call.  Note that for set_value_all this is automatically set to False.
Since we did not explicitly state that we only wanted the primary and secondary components, the time array on '_default' is filled as well.  If we were then to add a tertiary component, its RVs would automatically be computed because of this replicated time array.
Can you write Python code for it?

print b.filter(dataset='rv01', check_default=False).components

print b.get('times@_default@rv01', check_default=False)


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
However, for a double-lined RV we probably don't want to do the following:
Can you write Python code for it?

b.add_dataset('rv', times=[0,1], rvs=[-3,3], dataset='rv03')

print b['rvs@rv03']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Instead we want to pass different arrays to the 'rvs@primary' and 'rvs@secondary'.  This can be done by explicitly stating the components in a dictionary sent to that argument:
Can you write Python code for it?

b.add_dataset('rv', times=[0,1], rvs={'primary': [-3,3], 'secondary': [4,-4]}, dataset='rv04')

print b['rvs@rv04']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Note here that we didn't explicitly override the defaults for '_default', so they used the phoebe-wide defaults.  If you wanted to set a value for the ld_coeffs of any star added in the future, you would have to provide a value for '_default' in the dictionary as well.
This syntax may seem a bit bulky - but alternatively you can add the dataset without providing values and then change the values individually using dictionary access or set_value.
Adding a Dataset from a File
Manually from Arrays
For now, the only way to load data from a file is to do the parsing externally and pass the arrays on (as in the previous section).
Here we'll load times, fluxes, and errors of a light curve from an external file and then pass them on to a newly created dataset.  Since this is a light curve, it will automatically know that you want the summed light from all copmonents in the hierarchy.
Can you write Python code for it?

times, fluxes, sigmas = np.loadtxt('test.lc.in', unpack=True)
b.add_dataset(phoebe.dataset.lc, times=times, fluxes=fluxes, sigmas=sigmas, dataset='lc04')


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
Removing Datasets
Removing a dataset will remove matching parameters in either the dataset, model, or constraint contexts.  This action is permanent and not undo-able via Undo/Redo.
Can you write Python code for it?


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
The simplest way to remove a dataset is by its dataset tag:
Can you write Python code for it?


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
With Observations
Loading datasets with observations is (nearly) as simple.
Passing arrays to any of the dataset columns will apply it to all of the same components in which the time will be applied (see the 'Without Observations' section above for more details).  This make perfect sense for fluxes in light curves where the time and flux arrays are both at the system level:
Can you write Python code for it?

b.add_dataset('lc', times=[0,1], fluxes=[1,0.5], dataset='lc01')

print b['fluxes@lc01@dataset']


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
You may notice that add_dataset does take some time to complete.  In the background, the passband is being loaded (when applicable) and many parameters are created and attached to the Bundle.
If you do not provide a list of component(s), they will be assumed for you based on the dataset method.  Light curves and meshes can only attach at the system level (component=None), for instance, whereas RVs can attach for each star.
Can you write Python code for it?

b.add_dataset('rv', times=np.linspace(0,10,20), dataset='rv01')

print b.filter(dataset='rv01').components


I am working on the file "2.0/tutorials/datasets.ipynb".
The first task is:
or
Can you write Python code for it?


I am working on the file "2.0/tutorials/distance.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/distance.ipynb".
The first task is:
Influence on Light Curves (Fluxes)
Fluxes are, however, affected by distance exactly as you'd expect as inverse of distance squared.
To illustrate this, let's add an 'lc' dataset and compute synthetic fluxes at 1 and 2 m.
Can you write Python code for it?


I am working on the file "2.0/tutorials/distance.ipynb".
The first task is:
Influence on Orbits (Positions)
The distance has absolutely NO effect on the synthetic orbit as the origin of the orbit's coordinate system is such that the barycenter of the system is at 0,0,0 at t0.
To demonstrate this, let's create an 'orb' dataset and compute models at both 1 m and 2 m and then plot the resulting synthetic models.
Can you write Python code for it?

b.add_dataset('orb', times=np.linspace(0,3,101), dataset='orb01')

b.set_value('distance', 1.0)

b.run_compute(model='dist1')

b.set_value('distance', 2.0)

b.run_compute(model='dist2')

fig = plt.figure()
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)

axs, artists = b['orb01'].plot(model='dist1', ax=ax1)
axs, artists = b['orb01'].plot(model='dist2', ax=ax2)


I am working on the file "2.0/tutorials/distance.ipynb".
The first task is:
Note that 'pblum' is defined such that a (spherical, non-eclipsed, non-limb darkened) star with a pblum of 4pi will contribute a flux of 1.0 at 1.0 m (the default distance).
For more information, see the pblum tutorial
Influence on Meshes (Intensities)
Distance does not affect the intensities stored in the mesh (including those in relative units).  In other words, like third light, distance only scales the fluxes.
NOTE: this is different than pblums which DO affect the relative intensities.  Again, see the pblum tutorial for more details.
To see this we can run both of our distances again and look at the values of the intensities in the mesh.
Can you write Python code for it?

b.add_dataset('mesh', times=[0], dataset='mesh01')

b.set_value('distance', 1.0)

b.run_compute(model='dist1')

b.set_value('distance', 2.0)

b.run_compute(model='dist2')

print "dist1 abs_intensities: ", b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='dist1').mean()
print "dist2 abs_intensities: ", b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='dist2').mean()

print "dist1 intensities: ", b.get_value(qualifier='intensities', component='primary', dataset='lc01', model='dist1').mean()
print "dist2 intensities: ", b.get_value(qualifier='intensities', component='primary', dataset='lc01', model='dist2').mean()


I am working on the file "2.0/tutorials/distance.ipynb".
The first task is:
To make things easier to compare, let's disable limb darkening
Can you write Python code for it?

b.set_value_all('ld_func', 'logarithmic')
b.set_value_all('ld_coeffs', [0.,0.])

b.set_value('distance', 1.0)

b.run_compute(model='dist1')

b.set_value('distance', 2.0)

b.run_compute(model='dist2')


I am working on the file "2.0/tutorials/ecc.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.0/tutorials/ecc.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Can you write Python code for it?

b.add_dataset('lc', times=np.linspace(0,1,51))

b.run_compute()

axs, artists = b.plot()


I am working on the file "2.0/tutorials/ecc.ipynb".
The first task is:
Influence on Meshes (potentials, volumes)
Can you write Python code for it?

b.add_dataset('mesh', times=np.linspace(0,1,11))

b.set_value('ecc', 0.2)

b.run_compute()

print b['pot@primary@model']

ax, artists = b['mesh01'].plot(x='times', y='pot')

print b['rpole@primary@model']

axs, artists = b['mesh01'].plot(x='times', y='rpole')

print b['volume@primary@model']

ax, artists = b['mesh01'].plot(x='times', y='volume')

b.remove_dataset('mesh01')


I am working on the file "2.0/tutorials/eclipse.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.0/tutorials/eclipse.ipynb".
The first task is:
Let's just compute the mesh at a single time-point that we know should be during egress.
Can you write Python code for it?


I am working on the file "2.0/tutorials/eclipse.ipynb".
The first task is:
Native
The 'native' eclipse method computes what percentage (by area) of each triangle is visible at the current time.  It also determines the centroid of the visible portion of each triangle.
Physical quantities (temperatures, intensities, velocities, etc) are computed at the vertices of each triangle, and this centroid is then used to determine the average quantity across the visible portion of the triangle (by assuming a linear gradient across the triangle).
Let's plot the visibilities (ratio of the area that is visible) as the color scale, with red being completely hidden and green being completely visible.  We'll also plot the centroids themselves.  Here we can see that the centroids for green/visible triangles are exactly in the center, whereas for partially visible triangles the centroid is leaning towards the visible portion of the star.
Can you write Python code for it?

b.run_compute(eclipse_method='native')

fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
axs, artists = b.plot(component='primary', facecolor='visibilities', ax=ax)

wcs = b['visible_centroids@primary'].get_value()

ax.plot(wcs[:,0], wcs[:,1], 'b.')
xlim = ax.set_xlim(-0.5,0.25)
ylim = ax.set_ylim(-0.4,0.4)

b.run_compute(eclipse_method='visible_partial')

fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
axs, artists = b.plot(component='primary', facecolor='visibilities', ax=ax)

xlim = ax.set_xlim(-0.5,0.25)
ylim = ax.set_ylim(-0.4,0.4)


I am working on the file "2.0/tutorials/fti.ipynb".
The first task is:
An 'fti_method' parameter exists for each set of compute options and each lc dataset.  By default this is set to 'none' - meaning that the exposure times are ignored during b.run_compute().
Can you write Python code for it?

print(b['fti_method'])

b['fti_method'] = 'oversample'


I am working on the file "2.0/tutorials/fti.ipynb".
The first task is:
Influence on Light Curves
Can you write Python code for it?

b.run_compute(fti_method='none', irrad_method='none', model='fti_off')

b.run_compute(fti_method='oversample', irrad_method='none', model='fit_on')


I am working on the file "2.0/tutorials/fti.ipynb".
The first task is:
Once we set fti_method to be 'oversample', the corresponding 'fti_oversample' parameter(s) become visible.  This option defines how many different time-points PHOEBE should sample over the width of the exposure time and then average to return a single flux point.  By default this is set to 5.
Note that increasing this number will result in better accuracy of the convolution caused by the exposure time - but increases the computation time essentially linearly.  By setting to 5, our computation time will already be almost 5 times that when fti is disabled.
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
All of these arguments are optional and will default to clevel='WARNING' if not provided.  There is therefore no need to provide a filename if you don't provide a value for flevel.
So with this logger, anything with "WARNING, ERROR, or CRITICAL levels will be printed to the screen.  All messages of any level will be written to a file named 'tutorial.log' in the current directory.
Note: the logger messages are not included in the outputs shown below.
Parameters
Parameters hold a single value, but need to be aware about their own types, limits, and connection with other Parameters (more on this later when we discuss ParameterSets).
Note that generally you won't ever have to "create" or "define" your own Parameters, those will be created for you by helper functions, but we have to start somewhere... so let's create our first Parameter.
We'll start with creating a StringParameter since it is the most generic, and then discuss and specific differences for each type of Parameter.
Can you write Python code for it?

param = phoebe.parameters.StringParameter(qualifier='myparameter',
                                          description='mydescription',
                                          value='myvalue')


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
As with Python, an empty string will cast to False and a non-empty string will cast to True
Can you write Python code for it?

param.set_value('')
print param.get_value()

param.set_value('some_string')
print param.get_value()


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
But note that the limits are still stored as a quantity object in the originally defined default_units
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Calling get_value will then return a float in these units
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatArrayParameters
FloatArrayParameters are essentially the same as FloatParameters (in that they have the same unit treatment, although obviously no limits) but hold numpy arrays rather than a single value.
By convention in Phoebe, these will (almost) always have a pluralized qualifier.
Can you write Python code for it?

param = phoebe.parameters.FloatArrayParameter(qualifier='myfloatarrayparameters',
                                              description='mydescription',
                                              default_unit=u.m,
                                              value=np.array([0,1,2,3]))

print param

print param.attributes

print param.get_value(unit=u.km)


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatArrayParameters also allow for built-in interpolation... but this requires them to be a member of a Bundle, so we'll discuss this in just a bit.
ParametersSets
ParameterSets are a collection of Parameters that can be filtered by their tags to return another ParameterSet.
For illustration, let's create 3 random FloatParameters and combine them to make a ParameterSet.
Can you write Python code for it?

param1 = phoebe.parameters.FloatParameter(qualifier='param1',
                                          description='param1 description',
                                          default_unit=u.m,
                                          limits=[None,20],
                                          value=5,
                                          context='context1',
                                          kind='kind1')

param2 = phoebe.parameters.FloatParameter(qualifier='param2',
                                          description='param2 description',
                                          default_unit=u.deg,
                                          limits=[0,2*np.pi],
                                          value=0,
                                          context='context2',
                                          kind='kind2')

param3 = phoebe.parameters.FloatParameter(qualifier='param3',
                                          description='param3 description',
                                          default_unit=u.kg,
                                          limits=[0,2*np.pi],
                                          value=0,
                                          context='context1',
                                          kind='kind2')

ps = phoebe.parameters.ParameterSet([param1, param2, param3])

print ps.to_list()


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatArrayParameters: interpolation
As mentioned earlier, when a part of a Bundle, FloatArrayParameters can handle simple linear interpolation with respect to another FloatArrayParameter in the same Bundle.
Can you write Python code for it?

xparam = phoebe.parameters.FloatArrayParameter(qualifier='xs',
                                               default_unit=u.d,
                                               value=np.linspace(0,1,10),
                                               context='context1')

yparam = phoebe.parameters.FloatArrayParameter(qualifier='ys',
                                               default_unit=u.m,
                                               value=np.linspace(0,1,10)**2,
                                               context='context1')

b = phoebe.Bundle([xparam, yparam])

b.filter('ys').get().twig

b['ys'].get_value()


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatParameters
FloatParameters are probably the most common Parameter used in PHOEBE and hold both a float and a unit, with the ability to retrieve the value in any other convertible unit.
Can you write Python code for it?

param = phoebe.parameters.FloatParameter(qualifier='myfloatparameter',
                                         description='mydescription',
                                         default_unit=u.m,
                                         limits=[None,20],
                                         value=5)

print param


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatParameters also have their own method to access an astropy Quantity object that includes both the value and the unit
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
FloatParameters have an attribute which hold the "limits" - whenever a value is set it will be checked to make sure it falls within the limits.  If either the lower or upper limit is None, then there is no limit check for that extreme.
Can you write Python code for it?

print param['limits'], param.limits

#param.set_value(30) # would raise a ValueError
param.set_value(2)
print param.get_value()


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
For the special case of the 'value' attribute, there is also a get method (will become handy later when we want to be able to request the value in a specific unit).
Can you write Python code for it?

print param.get_value(), param['value'], param.value


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Here we were returned a ParameterSet of all Parameters that matched the filter criteria.  Since we're returned another ParameterSet, we can chain additional filter calls together.
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
If for some reason you want to change the default_unit, you can do so as well:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
If you ever need to know the type of a Parameter, you can always use python's built-in type functionality:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
If you want to access the actual Parameter, you must use get instead of (or in addition to) filter.  All of the following lines do the exact same thing:
Can you write Python code for it?

print ps.filter(context='context1', kind='kind1').get()

print ps.get(context='context1', kind='kind1')


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
IntParameters
IntParameters are essentially the same as FloatParameters except they always cast to an Integer and they have no units.
Can you write Python code for it?

param = phoebe.parameters.IntParameter(qualifier='myintparameter',
                                       description='mydescription',
                                       limits=[0,None],
                                       value=1)

print param

print param.attributes


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Let's get started with some basic imports
Can you write Python code for it?

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


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Note that if you try to set the value to a float it will not raise an error, but will cast that value to an integer (following python rules of truncation, not rounding)
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Now we can interpolate the 'ys' param for any given value of 'xs'
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Now we see that we have drilled down to a single Parameter.  Note that a ParameterSet is still returned - filter will always return a ParameterSet.
We could have accomplished the exact same thing with a single call to filter:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Of course, once you get the Parameter you can then use dictionary keys to access any attributes of that Parameter.
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
Or we can use those twigs.  Remember that twigs are just a combination of these tags separated by the @ symbol.  You can use these for dictionary access in a ParameterSet - without needing to provide the name of the tag, and without having to worry about order.  And whenever this returns a ParameterSet, these are also chainable, so the following two lines will do the same thing:
Can you write Python code for it?

print ps['context1@kind1']

print ps['context1']['kind1']


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
So we decided we might as well allow access to those attributes directly from the twig as well
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
The 'visible_if' attribute only comes into play when the Parameter is a member of a ParameterSet, so we'll discuss it at the end of this tutorial when we get to ParameterSets.
The 'copy_for' attribute is only used when the Parameter is in a particular type of ParameterSet called a Bundle (explained at the very end of this tutorial).  We'll see the 'copy_for' capability in action later in the Datasets Tutorial, but for now, just know that you can view this property only and cannot change it... and most of the time it will just be an empty string.
StringParameters
We'll just mention StringParameters again for completeness, but we've already seen about all they can do - the value must cast to a valid string but no limits or checks are performed at all on the value.
ChoiceParameters
ChoiceParameters are essentially StringParameters with one very important exception: the value must match one of the prescribed choices.
Therefore, they have a 'choice' attribute and an error will be raised if trying to set the value to any string not in that list.
Can you write Python code for it?

param = phoebe.parameters.ChoiceParameter(qualifier='mychoiceparameter',
                                          description='mydescription',
                                          choices=['choice1', 'choice2'],
                                          value='choice1')

print param

print param.attributes

print param['choices'], param.choices

print param.get_value()

#param.set_value('not_a_choice') # would raise a ValueError
param.set_value('choice2')
print param.get_value()


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
The Bundle
The Bundle is nothing more than a glorified ParameterSet with some extra methods to compute models, add new components and datasets, etc.
You can initialize an empty Bundle as follows:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
The value attribute is also the only attribute that you'll likely want to change, so it also has a set method:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
This returns None since not all objects in this ParameterSet share a single context.  But you can see all the options for a given tag by providing the plural version of that tag name:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
You can see here that we've defined three a few things about parameter: the qualifier, description, and value (others do exist, they just don't show up in the summary).
These "things" can be split into two groups: tags and attributes (although in a pythonic sense, both can be accessed as attributes).  Don't worry too much about this distinction - it isn't really important except for the fact that tags are shared across all Parameters whereas attributes are dependent on the type of the Parameter.
The tags of a Parameter define the Parameter and how it connects to other Parameters (again, more on this when we get to ParameterSets).  For now, just now that you can access a list of all the tags as follows:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
You may notice that the final result was a Parameter, not a ParameterSet.  Twig dictionary access tries to be smart - if exactly 1 Parameter is found, it will return that Parameter instead of a ParameterSet.  Notice the difference between the two following lines:
Can you write Python code for it?

print ps['context1']

print ps['context1@kind1']


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
You'll notice here a few new mentions in the summary... "Constrained by", "Constrains", and "Related to" are all referring to constraints which will be discussed in a future tutorial.
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
and again, each of these are available through both a dictionary key and as an object attribute.  For example, all parameters have a 'description' attribute which gives additional information about what the Parameter means:
Can you write Python code for it?


I am working on the file "2.0/tutorials/general_concepts.ipynb".
The first task is:
and filter just as you would for a ParameterSet
Can you write Python code for it?


I am working on the file "2.0/tutorials/grav_redshift.ipynb".
The first task is:
Besides the obvious change in the Rossiter-McLaughlin effect (not due to gravitational redshift), we can see that making the radii smaller shifts the entire RV curve up (the spectra are redshifted as they have to climb out of a steeper potential at the surface of the stars).
Can you write Python code for it?

print b['rvs@rv01@primary@defaultradii_true'].get_value().min()
print b['rvs@rv01@primary@smallradii_true'].get_value().min()
print b['rvs@rv01@primary@smallradii_false'].get_value().min()

print b['rvs@rv01@primary@defaultradii_true'].get_value().max()
print b['rvs@rv01@primary@smallradii_true'].get_value().max()
print b['rvs@rv01@primary@smallradii_false'].get_value().max()


I am working on the file "2.0/tutorials/grav_redshift.ipynb".
The first task is:
Influence on Radial Velocities
Can you write Python code for it?

fig = plt.figure(figsize=(10,6))
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)

axs, artists = b['rv01@defaultradii_true'].plot(ax=ax1, ylim=(-150,150))
axs, artists = b['rv01@smallradii_true'].plot(ax=ax2, ylim=(-150,150))

fig = plt.figure(figsize=(10,6))
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)

axs, artists = b['rv01@smallradii_true'].plot(ax=ax1, ylim=(-150,150))
axs, artists = b['rv01@smallradii_false'].plot(ax=ax2, ylim=(-150,150))


I am working on the file "2.0/tutorials/grav_redshift.ipynb".
The first task is:
Now let's run another model but with much smaller stars (but with the same masses).
Can you write Python code for it?

b['rpole@primary'] = 0.4
b['rpole@secondary'] = 0.4

b.run_compute(rv_method='flux-weighted', rv_grav=True, irrad_method='none', model='smallradii_true')


I am working on the file "2.0/tutorials/grav_redshift.ipynb".
The first task is:
Relevant Parameters
Gravitational redshifts are only accounted for flux-weighted RVs (dynamical RVs literally only return the z-component of the velocity of the center-of-mass of each star).
First let's run a model with the default radii for our stars.
Can you write Python code for it?


I am working on the file "2.0/tutorials/gravb_bol.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/gravb_bol.ipynb".
The first task is:
If you have a logger enabled, PHOEBE will print a warning if the value of gravb_bol is outside the "suggested" ranges.  Note that this is strictly a warning, and will never turn into an error at b.run_compute().
You can also manually call b.run_checks().  The first returned item tells whether the system has passed checks: True means it has, False means it has failed, and None means the tests pass but with a warning.  The second argument tells the first warning/error message raised by the checks.
The checks use the following "suggested" values:
 * teff 8000+: gravb_bol >= 0.9 (suggest 1.0)
 * teff 6600-8000: gravb_bol 0.32-1.0
 * teff 6600-: grav_bol < 0.9 (suggest 0.32)
Can you write Python code for it?

print(b.run_checks())

b['teff@primary'] = 8500
b['gravb_bol@primary'] = 0.8
print(b.run_checks())

b['teff@primary'] = 7000
b['gravb_bol@primary'] = 0.2
print(b.run_checks())

b['teff@primary'] = 6000
b['gravb_bol@primary'] = 1.0
print(b.run_checks())


I am working on the file "2.0/tutorials/intens_weighting.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()

b.add_dataset('lc', times=np.linspace(0,1,101))

b.add_dataset('mesh', times=[0])


I am working on the file "2.0/tutorials/intens_weighting.ipynb".
The first task is:
Relevant Parameters
Can you write Python code for it?

b['intens_weighting']

print b['intens_weighting']


I am working on the file "2.0/tutorials/irrad_method_horvat.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger('error')

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/irrad_method_horvat.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Let's (roughtly) reproduce Figure 8 from Prsa et al. 2016 which shows the difference between Wilson and Horvat schemes for various inclinations.
<img src="prsa+2016_fig8.png" alt="Figure 8" width="600px"/>
First we'll roughly create a A0-K0 binary and set reasonable albedos.
Can you write Python code for it?

b['teff@primary'] = 11000
b['rpole@primary'] = 2.5
b['gravb_bol@primary'] = 1.0

b['teff@secondary'] = 5000
b['rpole@secondary'] = 0.85

b['q@binary'] = 0.8/3.0

b.flip_constraint('mass@primary', solve_for='sma@binary')
b['mass@primary'] = 3.0

print(b.filter(qualifier=['mass', 'rpole', 'teff'], context='component'))

b['irrad_frac_refl_bol@primary'] = 1.0
b['irrad_frac_refl_bol@secondary'] = 0.6


I am working on the file "2.0/tutorials/irrad_method_horvat.ipynb".
The first task is:
Now we'll compute the light curves with wilson and horvat irradiation, and plot the relative differences between the two as a function of phase, for several different values of the inclination.
Note that Figure 8 excluded eclipse effects, but that ability is not included in PHOEBE 2.0, so there will be a slight discrepancy for inclinations which exhibit eclipses.
Can you write Python code for it?

phases = np.linspace(0,1,101)
b.add_dataset('lc', times=b.to_time(phases))

for incl in [0,30,60,90]:
    b.set_value('incl@binary', incl)
    b.run_compute(irrad_method='wilson')
    fluxes_wilson = b.get_value('fluxes', context='model')
    b.run_compute(irrad_method='horvat')
    fluxes_horvat = b.get_value('fluxes', context='model')
    plt.plot(phases, (fluxes_wilson-fluxes_horvat)/fluxes_wilson, label='i={}'.format(incl))

plt.xlabel('phase')
plt.ylabel('[F(wilson) - F(horvat)] / F(wilson)')
plt.legend(loc='upper center')
plt.show()


I am working on the file "2.0/tutorials/l3.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.0/tutorials/l3.ipynb".
The first task is:
Influence on Light Curves (Fluxes)
"Third" light is simply additional flux added to the light curve from some external source - whether it be crowding from a background object, light from the sky, or an extra component in the system that is unaccounted for in the system hierarchy.
To see this we'll compare a light curve with and without "third" light.
Can you write Python code for it?

b.run_compute(irrad_method='none', model='no_third_light')

b['l3@lc01'] = 5

b.run_compute(irrad_method='none', model='with_third_light')


I am working on the file "2.0/tutorials/l3.ipynb".
The first task is:
Influence on Meshes (Intensities)
"Third" light does not affect the intensities stored in the mesh (including those in relative units).  In other words, like distance, "third" light only scales the fluxes.
NOTE: this is different than pblums which DO affect the relative intensities.  Again, see the pblum tutorial for more details.
To see this we can run both of our models again and look at the values of the intensities in the mesh.
Can you write Python code for it?

b.add_dataset('mesh', times=[0], dataset='mesh01')

b['l3@lc01'] = 0.0

b.run_compute(irrad_method='none', model='no_third_light')

b['l3@lc01'] = 5

b.run_compute(irrad_method='none', model='with_third_light')

print "no_third_light abs_intensities: ", b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='no_third_light').mean()
print "with_third_light abs_intensities: ", b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='with_third_light').mean()

print "no_third_light intensities: ", b.get_value(qualifier='intensities', component='primary', dataset='lc01', model='no_third_light').mean()
print "with_third_light intensities: ", b.get_value(qualifier='intensities', component='primary', dataset='lc01', model='with_third_light').mean()


I am working on the file "2.0/tutorials/l3.ipynb".
The first task is:
Relevant Parameters
The 'l3' parameter describes how much third light exists in a given passband.  Since this is passband dependent and only used for flux measurments - it does not yet exist for a new empty Bundle.
Can you write Python code for it?


I am working on the file "2.0/tutorials/l3.ipynb".
The first task is:
So let's add a LC dataset
Can you write Python code for it?


I am working on the file "2.0/tutorials/limb_darkening.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Can you write Python code for it?

b.run_compute(model='mymodel')

axs, artists = b['lc01@mymodel'].plot()


I am working on the file "2.0/tutorials/limb_darkening.ipynb".
The first task is:
Note that ld_coeffs isn't visible (relevant) if ld_func=='interp'
Can you write Python code for it?

b['ld_func@lc01@primary'] = 'logarithmic'

print b['ld_coeffs@lc01@primary']


I am working on the file "2.0/tutorials/ltte.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.0/tutorials/ltte.ipynb".
The first task is:
Comparing with and without ltte
In order to have a binary system with any noticeable ltte effects, we'll set a somewhat extreme mass-ratio and semi-major axis.
Can you write Python code for it?


I am working on the file "2.0/tutorials/ltte.ipynb".
The first task is:
Relevant Parameters
The 'ltte' parameter in context='compute' defines whether light travel time effects are taken into account or not.
Can you write Python code for it?


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
As you can see, the intensities are not available here - their dataset tags match the dataset of the light curve.  Instead let's access the mesh by dataset-kind:
Can you write Python code for it?

b.filter(kind='mesh', context='model', component='primary')

b.filter(dataset='lc01', kind='mesh', context='model', component='primary')


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
But we can still plot any of the dataset-independent quantities
Can you write Python code for it?

b.filter(dataset='mesh01', kind='mesh', context='model', component='primary', time=0.5)

axs, artists = b.filter(dataset='mesh01', kind='mesh', context='model', time=0.5).plot(facecolor='teffs', edgecolor=None)


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
Now let's look at the parameters in the protomesh
Can you write Python code for it?

b.filter(dataset='protomesh', context='model')

b.filter(dataset='protomesh', context='model', component='primary')

b.get_value(dataset='protomesh', context='model', component='primary', qualifier='teffs')

axs, artists = b.filter(dataset='protomesh', context='model', component='secondary').plot(facecolor='teffs', edgecolor=None)


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
Now let's run_compute with protomesh and pbmesh set to False (these will default to the values in the compute options - which themselves are defaulted to False).
Can you write Python code for it?


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
Our model now has dataset kinds for both the 'mesh' and 'lc' and has dataset tags for our newly-created 'lc01' dataset as well as the 'pbmesh' datasets in the model created only because pbmesh=True.
Can you write Python code for it?

print b['model'].kinds

print b['model'].datasets


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
Since there was no lc requested at these times, the 'intensities' columns will be empty.
Can you write Python code for it?

b.get_value(kind='mesh', context='model', dataset='lc01', time=0.5, qualifier='intensities', component='primary')


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
The 'pbmesh'
'pbmesh' is an automatically-created dataset in the returned model which stores the mesh at every time-point at which it was required to be built by other existing datasets.
Again, these will only be stored in the returned model if pbmesh=True is passed during run_compute or is True in the passed compute options.
Can you write Python code for it?

b.add_dataset('lc', times=[0,1,2], dataset='lc01')

b.run_compute(pbmesh=True)


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
The 'protomesh'
The 'protomesh' is the mesh of each star in its own reference frame at periastron.  The coordinates are defined such that the x-axis points towards the other component in the parent orbit.
To build the protomesh, set 'protomesh' to be True, either in the compute options or directly as a keyword argument when calling run_compute.
Can you write Python code for it?


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
This time let's look at the parameters in the 'pbmesh' dataset of the model.
Can you write Python code for it?

b.filter(dataset='pbmesh', context='model')

b.filter(dataset='pbmesh', context='model', component='primary')


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
To plot the intensities as color on the mesh, we can just plot the mesh and then reference the correct column by using twig access:
Can you write Python code for it?

axs, artists = b.filter(kind='mesh', context='model', time=1.0).plot(facecolor='intensities@lc01', edgecolor='teffs')


I am working on the file "2.0/tutorials/meshes.ipynb".
The first task is:
You'll see that the resulting model has a single dataset kind ('mesh') and with a dataset tag of 'protomesh'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Checking the content property again shows that the table has been successfully computed:
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Getting started
Let us start by importing phoebe, numpy and matplotlib:
Can you write Python code for it?

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

logger = phoebe.logger(clevel='WARNING')


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
I don't care about the details, just show/remind me how it's done
Makes sense, and we don't judge: you want to get to science. Provided that you have the passband transmission file available and the ck2004 database already downloaded, the sequence that will generate/register a new passband is:
Can you write Python code for it?

import phoebe
from phoebe import u

# Register a passband:
pb = phoebe.atmospheres.passbands.Passband(
    ptf='my_passband.ptf', pbset='Custom', pbname='mypb',
    effwl=330., wlunits=u.nm, calibrated=True,
    reference='A completely made-up passband published in Nowhere (2017)', version=1.0,
    comments='This is my first custom passband')

# Blackbody response:
pb.compute_blackbody_response()

# Castelli & Kurucz (2004) response:
pb.compute_ck2004_response(path='ck2004i')
pb.compute_ck2004_intensities(path='ck2004i')
pb.compute_ck2004_ldcoeffs()
pb.compute_ck2004_ldints()

# Wilson-Devinney response:
pb.import_wd_atmcof('atmcofplanck.dat', 'atmcof.dat', 22)

# Save the passband:
pb.save('my_passband.pb')


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Let us now save these data in a file that we will use to register a new passband.
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Let us now use the same low-level function as before to compare normal emergent passband intensity for our custom passband for blackbody and ck2004 model atmospheres. One other complication is that, unlike blackbody model that depends only on the temperature, the ck2004 model depends on surface gravity (log g) and heavy metal abundances as well, so we need to pass those arrays.
Can you write Python code for it?

loggs = np.ones(len(teffs))*4.43
abuns = np.zeros(len(teffs))
plt.xlabel('Temperature [K]')
plt.ylabel('Inorm [W/m^2/A]')
plt.plot(teffs, pb.Inorm(teffs,               atm='blackbody', ld_func='linear', ld_coeffs=[0.0]), label='blackbody')
plt.plot(teffs, pb.Inorm(teffs, loggs, abuns, atm='ck2004',    ld_func='linear', ld_coeffs=[0.0]), label='ck2004')
plt.legend(loc='lower right')
plt.show()


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Let us plot this simulated passband transmission function to see what it looks like:
Can you write Python code for it?

plt.xlabel('Wavelength [nm]')
plt.ylabel('Passband transmission')
plt.plot(wl, ptf, 'b-')
plt.show()


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Note, of course, that you will need to change the path to point to the directory where you unpacked the ck2004 database. The verbosity parameter verbose will report on the progress as computation is being done. Depending on your computer speed, this step will take ~10 minutes to complete. We can now check the passband's content attribute again:
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Passband transmission function
The passband transmission function is typically a user-provided two-column file. The first column is wavelength, and the second column is passband transmission. For the purposes of this tutorial, we will simulate the passband as a uniform box.
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
Still an appreciable difference. This hopefully illustrates why excrutiating caution should be exercised at all times when dealing with modeling radiation.
Saving the passband table
The final step of all this (computer's) hard work is to save the passband file so that these steps do not need to be ever repeated. From now on you will be able to load the passband file explicitly and PHOEBE will have full access to all of its tables. Your new passband will be identified as 'Custom:mypb'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
This completes the computation of Castelli & Kurucz auxiliary tables.
Importing Wilson-Devinney response
PHOEBE no longer shares any codebase with the WD code, but for comparison purposes it is sometimes useful to use the same atmosphere tables. If the passband you are registering with PHOEBE has been defined in WD's atmcof.dat and atmcofplanck.dat files, PHOEBE can import those coefficients and use them to compute intensities.
To import a set of WD atmospheric coefficients, you need to know the corresponding index of the passband (you can look it up in the WD user manual available here) and you need to grab the files atmcofplanck.dat and atmcof.dat from Bob Wilson's webpage. For this particular passband the index is 22. To import, issue:
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
This makes perfect sense: Johnson V transmission function is wider than our boxed transmission function, so intensity in the V band is larger the lower temperatures. However, for the hotter temperatures the contribution to the UV flux increases and our box passband with a perfect transmission of 1 takes over.
Computing Castelli & Kurucz (2004) response
For any real science you will want to generate model atmosphere tables. The default choice in PHOEBE are the models computed by Fiorella Castelli and Bob Kurucz (website, paper) that feature new opacity distribution functions. In principle, you can generate PHOEBE-compatible tables for any model atmospheres, but that would require a bit of book-keeping legwork in the PHOEBE backend. Contact Andrej Prša to discuss an extension to other model atmospheres.
To compute Castelli & Kurucz (2004) tables for the passband of your choice, you will need to download a precomputed database of absolute intensities. This database is huge, so beware. You will need approximately 140GB of free space. Once you are sure you have this kind of space available, proceed to download the database tarball (28GB):
[cd into a parent directory that will hold the database]
wget http://phoebe-project.org/static/ck2004i.tgz
tar xzf ck2004i.tgz
Keep in mind that this will take a long time. Plan to go for lunch or leave it overnight. The good news is that this needs to be done only once.
Once the database is unpacked, you are ready to compute the tables. We start with the ck2004 response table:
Can you write Python code for it?


I am working on the file "2.0/tutorials/passbands.ipynb".
The first task is:
We can consult the content attribute to see the entire set of supported tables, and plot different atmosphere models for comparison purposes:
Can you write Python code for it?

print pb.content

plt.xlabel('Temperature [K]')
plt.ylabel('Inorm [W/m^2/A]')
plt.plot(teffs, pb.Inorm(teffs,               atm='blackbody',   ld_func='linear', ld_coeffs=[0.0]), label='blackbody')
plt.plot(teffs, pb.Inorm(teffs, loggs, abuns, atm='ck2004',      ld_func='linear', ld_coeffs=[0.0]), label='ck2004')
plt.plot(teffs, pb.Inorm(teffs, loggs, abuns, atm='extern_atmx', ld_func='linear', ld_coeffs=[0.0]), label='wd_atmx')
plt.legend(loc='lower right')
plt.show()


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
'normal_intensities' are scaled from 'abs_normal_intensities' so that the computed luminosity matches the prescribed luminosity (pblum).
Here we compute the luminosity by summing over each triangle's intensity in the normal direction, and multiply it by pi to account for blackbody intensity emitted in all directions in the solid angle, and by the area of that triangle.
Can you write Python code for it?

pblum = b.get_value(qualifier='pblum', component='primary', context='dataset')
print np.sum(normal_intensities * ldint * np.pi * areas) * ptfarea, pblum


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
And if we halve the temperature of the secondary star - the resulting light curve changes to the new sum of fluxes, where the primary star dominates since the secondary star flux is reduced by a factor of 16, so we expect a total out-of-eclipse flux of ~0.5 + ~0.5/16 = ~0.53.
Can you write Python code for it?

b['teff@secondary'] = 0.5 * b.get_value('teff@primary')

print b['teff']

b.run_compute()

axs, artists = b.plot()


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
And we'll add a single light curve dataset so that we can see how passband luminosities affect the resulting synthetic light curve model.
Can you write Python code for it?


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
Decoupled Luminosities
The luminosities are decoupled when pblums are provided for the individual components.  To accomplish this, all 'pblum_ref' parameters should be set to 'self'.
Can you write Python code for it?


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
However, if we change the temperature of the secondary star again, since the pblums are coupled, we'd expect the synthetic luminosity of the primary to remain fixed but the secondary to decrease.
Can you write Python code for it?

b['teff@secondary@component'] = 3000

b.run_compute()

print b.get_value(qualifier='pblum', time=t0, component='primary', kind='mesh', context='model')

print b.get_value(qualifier='pblum', time=t0, component='secondary', kind='mesh', context='model')


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
If we now set pblum to be only 2 pi, we should expect the entire light curve to be scaled in half.
Can you write Python code for it?

b['pblum@primary'] = 2 * np.pi

b.run_compute()

axs, artist = b.plot()


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
If we set these to 4pi, then we'd expect each star to contribute 1.0 in flux units, meaning the baseline of the light curve should be at approximately 2.0
Can you write Python code for it?

b.set_value_all('pblum', 4*np.pi)

b.run_compute()

axs, artists = b.plot()


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
NOTE: other parameters also affect flux-levels, including limb darkening and distance
Coupled Luminosities
Passband luminosities are considered coupled when a single pblum value is provided, while the passband luminosity of the other component(s) is scaled by the same factor.  To accomplish this, ONE pblum_ref in the system must be set as 'self' and ALL OTHER pbscales must refer to that component. This is the default case, set explicitly by:
Can you write Python code for it?

b['pblum_ref@primary'] = 'self'

b['pblum_ref@secondary'] = 'primary'


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
Now let's compare the value of the synthetic luminosities to those of the input pblum
Can you write Python code for it?

t0 = b.get_value('t0@system')

print b.get_value(qualifier='pblum', time=t0, component='primary', kind='mesh', context='model')

print b.get_value('pblum@primary@dataset')


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
Now let's make a significant temperature-ratio by making a very cool secondary star.  Since the luminosities are decoupled - this temperature change won't affect the resulting light curve very much (compare this to the case above with coupled luminosities).  What is happening here is that even though the secondary star is cooler, its luminosity is being rescaled to the same value as the primary star, so the eclipse depth doesn't change (you would see a similar lack-of-effect if you changed the radii).
Can you write Python code for it?

print b['teff']

b['teff@secondary'] = 3000

b.run_compute()

axs, artists = b.plot()


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
Now note that only a single pblum parameter is visible.
Can you write Python code for it?


I am working on the file "2.0/tutorials/pblum.ipynb".
The first task is:
The values of 'normal_intensities', however, are significantly samller (in this case).  These are the intensities in relative units which will eventually be integrated to give us flux for a light curve.
Can you write Python code for it?


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
3D Axes
To plot a in 3d, simply provide a 3D axes (or have it as your current axes available through plt.gca())
Here many of the same principles apply as above - you can change the array by pointing to a parameter for z, set zlim, zunit, zlabel, etc.
Can you write Python code for it?

figure = plt.figure()
ax = figure.add_subplot(111, projection='3d')

axes, artists = b['orb@run_with_incl_80'].plot(time=0, facecolor='teffs', edgecolor=None, ax=ax)


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
An advantage to this last approach (providing a twig as a positional argument to the plot method) is that it can accept multiple positional arguments to plot from multiple datasets in a single call.
When these have the same dataset method, they will automatically be drawn to the same axes (by default).
Can you write Python code for it?

axs, artists = b.plot('primary@orb@run_with_incl_80', 'secondary@orb@run_with_incl_80')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
And run the forward models.  See Computing Observables for more details.
Can you write Python code for it?

b.set_value('incl@orbit', 90)
b.run_compute(model='run_with_incl_90')

b.set_value('incl@orbit', 85)
b.run_compute(model='run_with_incl_85')

b.set_value('incl@orbit', 80)
b.run_compute(model='run_with_incl_80')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
And we'll attach some dummy datasets.  See Datasets for more details.
Can you write Python code for it?

b.add_dataset('orb', times=np.linspace(0,4,1000), dataset='orb01', component=['primary', 'secondary'])

times, fluxes, sigmas = np.loadtxt('test.lc.in', unpack=True)

b.add_dataset('lc', times=times, fluxes=fluxes, sigmas=sigmas, dataset='lc01')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Any call to plot returns 2 lists - a list of the axes and a list of the artists that were drawn on those axes.  Generally we won't need to do anything with these, but having them returned could come in handy if you want to manually edit those axes or artists before saving the image.
In this example with so many different models and datasets, it is quite simple to build a single plot by filtering the bundle and calling the plot method on the resulting ParameterSet.
Can you write Python code for it?

axs, artists = b['orb@run_with_incl_80'].plot()


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

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

logger = phoebe.logger()

b = phoebe.default_binary()
b['q'] = 0.8
b['ecc'] = 0.1
b['irrad_method'] = 'none'


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Choosing colors works slightly differently for meshes (ie you can set facecolor and edgecolor and facecmap and edgecmap).  For more details, see the tutorial on the mesh dataset.
Colormaps
The colormaps is determined automatically based on the parameter used for coloring (ie RVs will be a red-blue colormap).  To override this, pass a matplotlib recognized colormap to the cmap keyword.
Can you write Python code for it?

axs, artists = b['orb01@primary@run_with_incl_80'].plot(time=1.0, x='times', color='vzs', cmap='spring')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Custom Subplots
The plot method can both optionally take and return a matplotlib axes object.
This makes it quite easy to quickly build a figure with multiple subplots.
Below we'll mix a bunch of different ways to call plotting , and mix in highlighting
and uncovering.  The only real difference here from before is that we pass a
single matplotlib axes to the plot call - that is the axes on which all lines
will be drawn during that call, even if it loops and creates multiple lines.
The actual axes instance is returned, and we want to create the legend on that
axes.
Can you write Python code for it?

fig = plt.figure(figsize=(14,10))
ax = [fig.add_subplot(2,2,i+1) for i in range(4)]

axs, artists = b.plot('orb01@primary', y='ys', ax=ax[0])
ax[0].legend()

axs, artists = b['orb01@run_with_incl_80'].plot(y='ys', linestyle='--', time=5, uncover=True, ax=ax[1])
ax[1].legend()

axs, artists = b.plot(dataset='orb01', y='ys', ax=ax[2])
ax[2].legend()

axs, artists = b.plot(dataset='orb01', model='run_with_incl_80', x='times', y='vys', time=5, uncover=True, ax=ax[3])
ax[3].legend()


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Errorbars
In the cases of observational data, errorbars can be added by passing the name of the column.
Can you write Python code for it?

axs, artists = b['lc01@dataset'].plot(yerrors='sigmas')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
For more information on each of the available arrays, see the relevant tutorial on that dataset method:

orb dataset
mesh dataset
lc dataset
rv dataset

Selecting Phase
And to plot in phase we just send x='phases' or x='phases:binary'.
Setting x='phases' will use the ephemeris from the top-level of the hierarchy
(as if you called b.get_ephemeris()), whereas passing a string after the colon,
will use the ephemeris of that component.
Can you write Python code for it?

axs, artists = b['lc01@dataset'].plot(x='phases', yerrors=None)


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
If the datasets have multiple dataset kinds, subplots will automatically be created.
Can you write Python code for it?

axs, artists = b['run_with_incl_80'].plot('primary@orb', 'lc01')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Later we'll see how to customize the layout of these subplots in the figure and how to pass other plotting options.
Selecting Arrays
So far, each plotting call automatically chose default arrays from that dataset to plot along each axis.  To override these defaults, simply point to the qualifier of the array that you'd like plotted along a given axis.
Can you write Python code for it?

axs, artists = b['orb01@primary@run_with_incl_80'].plot(x='times', y='vxs')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Note that now when passing additional arguments, those will apply as defaults to EACH of the dictionaries, but will not override any values explicitly provided in the dictionaries.
Can you write Python code for it?

fig = plt.figure(figsize=(14,10))
ax = [fig.add_subplot(2,2,i+1) for i in range(4)]

plot1 = {'twig': 'orb01@primary', 'y': 'ys', 'ax':ax[0]}
plot2 = {'twig': 'orb01@run_with_incl_80', 'y': 'ys', 'linestyle': '--', 'time': 5, 'uncover': True, 'ax':ax[1]}
plot3 = {'twig': 'orb01', 'y': 'ys', 'ax': ax[2]}
plot4 = {'dataset': 'orb01', 'model': 'run_with_incl_80', 'x': 'times', 'y': 'vys', 'time': 5, 'uncover': True, 'ax': ax[3]}

axs, artists = b.plot(plot1, plot2, plot3, plot4, x='xs', y='zs', color='r')
for axi in ax:
    axi.legend()


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Showing and Saving
NOTE: in IPython notebooks calling plot will display directly below the call to plot.  When not in IPython you have several options for viewing the figure:

call plt.show() after calling plot
use the returned axes and artist objects however you'd like
pass show=True to the plot method (same as calling plt.show())
pass save='myfilename' to the plot method (same as calling plt.savefig('myfilename'))

Default Plots
To see the options for plotting that are dataset-dependent see the tutorials on that dataset method:

ORB dataset
MESH dataset
LC dataset
RV dataset

By calling the plot method on the bundle (or any ParameterSet) without any arguments, a plot or series of subplots will be built based on the contents of that ParameterSet.
Can you write Python code for it?


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
This first line is only necessary for ipython noteboooks - it allows the plots to be shown on this page instead of in interactive mode
Can you write Python code for it?


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
To disable the errorbars, simply set yerrors=None.
Can you write Python code for it?

axs, artists = b['lc01@dataset'].plot(yerrors=None)


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
To see the list of available qualifiers that could be passed for x or y, call the qualifiers (or twigs) property on the ParameterSet.
Can you write Python code for it?


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Uncover
Uncover shows the observations or synthetic model up to the provided time and is disabled by default, even when a time is provided, but is enabled simply by providing uncover=True.  There are no additional options available for uncover.
Can you write Python code for it?

axs, artists = b['orb@run_with_incl_80'].plot(time=1.0, uncover=True)


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
Units
Likewise, each array that is plotted is automatically plotted in its default units. To override these defaults, simply provide the unit (as a string or as a astropy units object) for a given axis.
Can you write Python code for it?

axs, artists = b['orb01@primary@run_with_incl_80'].plot(xunit='AU', yunit='AU')


I am working on the file "2.0/tutorials/plotting.ipynb".
The first task is:
WARNING: when plotting two arrays with the same dimensions, PHOEBE attempts to set the aspect ratio to equal, but overriding to use two different units will result in undesired results.  This may be fixed in the future, but for now can be avoided by using consistent units for the x and y axes when they have the same dimensions.
Axes Labels
Axes labels are automatically generated from the qualifier of the array and the plotted units.  To override these defaults, simply pass a string for the label of a given axis.
Can you write Python code for it?

axs, artists = b['orb01@primary@run_with_incl_80'].plot(xlabel='X POS', ylabel='Z POS')


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Alternatively, you could also manually check with the critical potentials.
The set value (or constrained value) of the equipotential (which is defined at periastron) must be GREATER than the critical potentials at each of the lagrange points in order to not overflow.
Can you write Python code for it?

q = b.get_value('q@binary@component')
F = b.get_value('syncpar@primary@component')
# instantaneous distance in units of sma at periastron is 1-e
d = 1 - b.get_value('ecc@binary@component')
crit_pots = phoebe.libphoebe.roche_critical_potential(q, F, d, L1=True, L2=True, L3=True)
pot = b.get_value('pot@primary@component')
print "pot: {}\nL1_crit: {}\nL2_crit: {}\nL3_crit: {}".format(pot, crit_pots['L1'], crit_pots['L2'], crit_pots['L3'])


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
At this time, if you were to call run_compute, an error would be thrown.  An error isn't immediately thrown when setting rpole, however, since the overflow can be recitified by changing any of the other relevant parameters.  For instance, let's change sma to be large enough to account for this value of rpole and you'll see that the error does not occur again.
Can you write Python code for it?

b.set_value('sma@binary@component', 5)

b.set_value('sma@binary@component', 10)


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Critical Potentials and System Checks
If you set a value such that the system becomes non-computable, a logger warning will immediately be raised.  This will happen in a detached system, for example, if any of the stars are predicted to overflow at periastron.  Since the surface of the star (potential) depends on many parameters (see the constraint above), this can be triggered by changing any of:

rpole
pot
q
sma
ecc
syncpar
Can you write Python code for it?


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Here we can see that our star is overflowing at L2.  By changing the sma to a value that passed before, we see that the potential changes to a value that is allowed.
Can you write Python code for it?

b.set_value('sma@binary@component', 10)

q = b.get_value('q@binary@component')
F = b.get_value('syncpar@primary@component')
# instantaneous distance in units of sma at periastron is 1-e
d = 1 - b.get_value('ecc@binary@component')
crit_pots = phoebe.libphoebe.roche_critical_potential(q, F, d, L1=True, L2=True, L3=True)
pot = b.get_value('pot@primary@component')
print "pot: {}\nL1_crit: {}\nL2_crit: {}\nL3_crit: {}".format(pot, crit_pots['L1'], crit_pots['L2'], crit_pots['L3'])


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Note that when calling critical potentials for the secondary component, you must invert q.
Can you write Python code for it?

q = 1./b.get_value('q@binary@component')
F = b.get_value('syncpar@secondary@component')
# instantaneous distance in units of sma at periastron is 1-e
d = 1 - b.get_value('ecc@binary@component')
crit_pots = phoebe.libphoebe.roche_critical_potential(q, F, d, L1=True, L2=True, L3=True)
pot = b.get_value('pot@primary@component')
print "pot: {}\nL1_crit: {}\nL2_crit: {}\nL3_crit: {}".format(pot, crit_pots['L1'], crit_pots['L2'], crit_pots['L3'])


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Now let's add a mesh dataset at a few different times so that we can see how the potentials affect the surfaces of the stars.
Can you write Python code for it?


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Now whenever any of the relevant parameters (q, ecc, syncpar, sma) are changed, the rpole and pot will automatically adjust so that they are at the critical L1 value.
Accessing Synthetic Potentials and Polar Radiii
Potentials and Polar Radii are stored in the synthetic meshes for every time in which a mesh is computed.  For circular orbits, these should remain constant over time and be equivalent to the input parameters.  In the next section, we'll look at an eccentric case which will show how having access to these values as a function of time can be quite handy.
Can you write Python code for it?

b.run_compute(irrad_method='none')

print b['rpole@primary@model']

print b['rpole@secondary@model']

print b['pot@primary@model']

print b['pot@secondary@model']


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
Semi-Detached Systems
NOTE: Support for semi-detached systems is introduced in version 2.0.5
Semi-detached systems are implemented by constraining either the potential or polar radius to be at the critical L1 value.
Here since the potential is already constrained by rpole, we'll constrain rpole.  This is done by applying the 'critical_rpole' constraint on the 'primary' component.
Can you write Python code for it?


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
The 'rpole' parameter is defined as the polar radius of the star at periastron.
Can you write Python code for it?

print b['rpole']

print b['rpole@primary']


I am working on the file "2.0/tutorials/pot.ipynb".
The first task is:
These logger warnings are handy when running phoebe interactively, but in a script its also handy to be able to check whether the system is currently computable /before/ running run_compute.
This can be done by calling run_checks which returns a boolean (whether the system passes all checks) and a message (a string describing the first failed check).
Can you write Python code for it?

passed, message = b.run_checks()
print passed, message

b.set_value('sma@binary@component', 5)

passed, message = b.run_checks()
print passed, message


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

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

logger = phoebe.logger('error')

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Can you write Python code for it?


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
Let's run models with the reflection switch both turned on and off so that we can compare the two results.  We'll also override delta to be a larger number since the computation time required by delta depends largely on the number of surface elements.
Can you write Python code for it?

b.run_compute(irrad_method='none', ntriangles=700, model='refl_false')

b.run_compute(irrad_method='wilson', ntriangles=700, model='refl_true')

axs, artists = b.plot()

artists = plt.plot(b['value@times@refl_false'], b['value@fluxes@refl_true']-b['value@fluxes@refl_false'], 'r-')


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
Reflection has the most noticeable effect when the two stars are close to each other and have a large temperature ratio.
Can you write Python code for it?

b['sma@orbit'] = 4.0

b['teff@primary'] = 10000

b['teff@secondary'] = 5000


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
Relevant Parameters
The parameters that define reflection and heating are all prefaced by "irrad_frac" (fraction of incident flux) and suffixed by "bol" to indicate that they all refer to a bolometric (rather than passband-dependent) process.  For this reason, they are not stored in the dataset, but rather directly in the component.
Each of these parameters dictates how much incident flux will be handled by each of the available processes.  For now these only include reflection (heating with immediate re-emission, without heat distribution) and lost flux.  In the future, heating with distribution and scattering will also be supported.
For each component, these parameters must add up to exactly 1.0 - and this is handled by a constraint which by default constrains the "lost" parameter.
Can you write Python code for it?

print b['irrad_frac_refl_bol']

print b['irrad_frac_lost_bol']

print b['irrad_frac_refl_bol@primary']

print b['irrad_frac_lost_bol@primary@component']


I am working on the file "2.0/tutorials/reflection_heating.ipynb".
The first task is:
Since reflection can be a computationally expensive process and in most cases is a low-order effect, there is a switch in the compute options that needs to be enabled in order for reflection to be taken into account.  If this switch is False (which it is by default), the albedos are completely ignored and will be treated as if all incident light is lost/ignored.
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
Accessing Settings
Settings are found with their own context in the Bundle and can be accessed through the get_setting method
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

import phoebe
from phoebe import u # units

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
Available Settings
Now let's look at each of the available settings and what they do
log_history
log_history is a BooleanParameter (defaults to False) that controls whether undo/redo ability is enabled.
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
If you want dictionary access to use set_value_all instead of set_value, you can enable this parameter
Can you write Python code for it?

b['dict_set_all@setting'] = True
b['teff@component'] = 8000
print b['value@teff@primary@component'], b['value@teff@secondary@component']


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
Now let's reset this option... keeping in mind that we no longer have access to the 'setting' context through twig access, we'll have to use methods to clear the dict_filter
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
Now we no longer see the constraint parameters.
All parameters are always accessible with method access:
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
This parameter can also be set by calling b.enable_history() or b.disable_history() and can be accessed with b.history_enabled.
Can you write Python code for it?

b['log_history@setting']

b.history_enabled

b.enable_history()

b['log_history@setting']

b.history_enabled


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
and can be set as any other Parameter in the Bundle
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
dict_set_all
dict_set_all is a BooleanParameter (defaults to False) that controls whether attempting to set a value to a ParameterSet via dictionary access will set all the values in that ParameterSet (if True) or raise an error (if False)
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
or via filtering/twig access
Can you write Python code for it?


I am working on the file "2.0/tutorials/settings.ipynb".
The first task is:
plotting_backend
plotting_backend sets the default backend to use in all plotting calls.  See the Plotting tutorial for more details.
Can you write Python code for it?