I am working on the file "2.1/tutorials/constraints.ipynb".
The first task is:
pitch/yaw (incl/long_an)
 NEW IN PHOEBE 2.1
pitch constrains the relation between the orbital and rotational inclination whereas yaw constrains the relation between the orbital and rotational long_an.  When pitch and yaw are set to 0, the system is aligned.
Can you write Python code for it?

b['incl@constraint']

b['incl@primary@constraint']

b['long_an@constraint']

b['long_an@primary@constraint']


I am working on the file "2.1/tutorials/datasets.ipynb".
The first task is:
Adding a Dataset from Arrays
To add a dataset, you need to provide the function in
phoebe.parameters.dataset for the particular type of data you're dealing with, as well
as any of your "observed" arrays.
The current available methods include:

orb (orbit/positional data)
mesh (discretized mesh of stars)
lc (light curve)
rv (radial velocity)
lp (spectral line profiles)

Without Observations
The simplest case of adding a dataset is when you do not have observational "data" and only want to compute a synthetic model.  Here all you need to provide is an array of times and information about the type of data and how to compute it.
This situation will almost always be the case for orbits and meshes - its unlikely that you have observed positions and velocities for each of your components, but you still may like to store that information for plotting or diagnostic purposes.
Here we'll do just that - we'll add an orbit dataset which will track the positions and velocities of both our 'primary' and 'secondary' stars (by their component tags) at each of the provided times.
Can you write Python code for it?

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


I am working on the file "2.1/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.1/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.1/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.
Those conversions can be handled via b.get_ephemeris, b.to_phase, and b.to_time.
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.1/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.1/tutorials/datasets.ipynb".
The first task is:
For the 'orb' datasets defined earlier, on the other hand, we explicitly provided components.  In that case the '_default' times will be empty - adding a new component will result in this empty array being replicated and the orbit will NOT be computed for the tertiary component.  Of course, you could always manually copy the time array at a later time if you wanted the orbit to be computed..
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/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.1/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.1/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.1/tutorials/datasets.ipynb".
The first task is:
or
Can you write Python code for it?


I am working on the file "2.1/tutorials/detach.ipynb".
The first task is:
And at any point we can choose to "re-attach".  If the job isn't yet complete, we'll be in a wait loop until it is.  Once the job is complete, the new model will be loaded and accessible.
Can you write Python code for it?

b['mymodel'].attach()

b['mymodel']

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


I am working on the file "2.1/tutorials/detach.ipynb".
The first task is:
Now we'll add datasets
Can you write Python code for it?


I am working on the file "2.1/tutorials/detach.ipynb".
The first task is:
Re-attaching to a Job
We can check on the job's status
Can you write Python code for it?


I am working on the file "2.1/tutorials/detach.ipynb".
The first task is:
Run Compute
Here we just pass detach=True to any run_compute call.  We'll immediately be returned to the prompt instead of waiting for the results to complete.
Can you write Python code for it?


I am working on the file "2.1/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.1/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')

afig, mplfig = b['orb01'].plot(y='ws', show=True, legend=True)


I am working on the file "2.1/tutorials/distance.ipynb".
The first task is:
Relevant Parameters
The 'distance' parameter lives in the 'system' context and is simply the distance between the center of the coordinate system and the observer (at t0)
Can you write Python code for it?

print b.get_parameter(qualifier='distance', context='system')

print b.get_parameter(qualifier='t0', context='system')


I am working on the file "2.1/tutorials/distance.ipynb".
The first task is:
Since we doubled the distance from 1 to 2 m, we expect the entire light curve at 2 m to be divided by 4 (note the y-scales on the plots below).
Can you write Python code for it?

afig, mplfig = b['lc01'].plot(show=True, legend=True)


I am working on the file "2.1/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()

afig, mplfig = b['lc@model'].plot(show=True)


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

b.add_dataset('mesh', times=np.linspace(0,1,11), columns=['volume'])

b.set_value('ecc', 0.2)

b.run_compute()

print b['volume@primary@model']

afig, mplfig = b['mesh01'].plot(x='times', y='volume', show=True)

b.remove_dataset('mesh01')


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

print b.get(qualifier='ecosw', context='constraint')

print b.get(qualifier='esinw', context='constraint')


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

print b.get(qualifier='ecc')

print b.get(qualifier='ecosw', context='component')

print b.get(qualifier='esinw', context='component')


I am working on the file "2.1/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?

%matplotlib inline

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

phoebe.devel_on() # DEVELOPER MODE REQUIRED FOR VISIBLE_PARTIAL - DON'T USE FOR SCIENCE

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.1/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.1/tutorials/eclipse.ipynb".
The first task is:
Visible Partial
The 'visible partial' eclipse method simply determines which triangles are hidden, which are visible, and which are partially visible.  It then assigns a visibility of 0.5 to any partially visible triangles - meaning they will contribute half of their intensities when integrated (assume that half of the area is visible).  There are no longer any centroids - values are still computed at the vertices but are then averaged to be at the geometric center of EACH triangle.
Again, 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.
Can you write Python code for it?

b.run_compute(eclipse_method='visible_partial')

afig, mplfig = b.plot(component='primary', fc='visibilities', xlim=(-0.5, 0.25), ylim=(-0.4, 0.4), show=True)


I am working on the file "2.1/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.1/tutorials/fti.ipynb".
The first task is:
Let's set the exposure time to 1 hr to make the convolution obvious in our 1-day default binary.
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/fti.ipynb".
The first task is:
Relevant Parameters
An 'exptime' parameter exists for each lc dataset and is set to 0.0 by default.  This defines the exposure time that should be used when fti is enabled.  As stated in its description, the time stamp of each datapoint is defined to be the time of mid-exposure.  Note that the exptime applies to all times in the dataset - if times have different exposure-times, then they must be split into separate datasets manually.
Can you write Python code for it?


I am working on the file "2.1/tutorials/fti.ipynb".
The first task is:
The phase-smearing (convolution) caused by the exposure time is most evident in areas of the light curve with sharp derivatives, where the flux changes significantly over the course of the single exposure.  Here we can see that the 1-hr exposure time significantly changes the observed shapes of ingress and egress as well as the observed depth of the eclipse.
Can you write Python code for it?

afig, mplfig = b.plot(show=True, legend=True)


I am working on the file "2.1/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 INFO, 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.1/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.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
Filtering
Any of the tags can also be used to filter the ParameterSet:
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/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.1/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.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
However, SelectParameters also allow you to use * as a wildcard and will expand to any of the choices that match that wildcard.  For example,
Can you write Python code for it?

param.set_value(["choice*"])

print param.get_value()

print param.expand_value()


I am working on the file "2.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
If running in IPython notebooks, you may see a "ShimWarning" depending on the version of Jupyter you are using - this is safe to ignore.
PHOEBE 2 uses constants defined in the IAU 2015 Resolution which conflict with the constants defined in astropy.  As a result, you'll see the warnings as phoebe.u and phoebe.c "hijacks" the values in astropy.units and astropy.constants.
Whenever providing units, please make sure to use phoebe.u instead of astropy.units, otherwise the conversions may be inconsistent.
Logger
Before starting any script, it is a good habit to initialize a logger and define which levels of information you want printed to the command line (clevel) and dumped to a file (flevel).  A convenience function is provided at the top-level via phoebe.logger to initialize the logger with any desired level.
The levels from most to least information are:

DEBUG
INFO
WARNING
ERROR
CRITICAL
Can you write Python code for it?

logger = phoebe.logger(clevel='INFO', flevel='DEBUG', filename='tutorial.log')


I am working on the file "2.1/tutorials/general_concepts.ipynb".
The first task is:
If we print a ParameterSet, we'll see a listing of all the Parameters and their values.
Can you write Python code for it?


I am working on the file "2.1/tutorials/general_concepts.ipynb".
The first task is:
If we print the parameter object we can see a summary of information
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
It doesn't make much sense to need to define a mass if this thing isn't baryonic.  So if we change the value of 'what_is_this' to 'aether' then the 'mass' Parameter will temporarily hide itself.
Can you write Python code for it?

b.set_value('what_is_this', 'aether')
print b.filter()


I am working on the file "2.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
Note that this returned the ParameterObject itself, so you can now use any of the Parameter methods or attributes we saw earlier.  For example:
Can you write Python code for it?


I am working on the file "2.1/tutorials/general_concepts.ipynb".
The first task is:
Note that, like IntParameters, BoolParameters will attempt to cast anything you give it into True or False.
Can you write Python code for it?

param.set_value(0)
print param.get_value()

param.set_value(None)
print param.get_value()


I am working on the file "2.1/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.1/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.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
Similarly to Parameters, we can access the tags of a ParameterSet
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
Tags
Each Parameter has a number of tags, and the ParameterSet has the same tags - where the value of any given tag is None if not shared by all Parameters in that ParameterSet.
So let's just print the names of the tags again and then describe what each one means.
Can you write Python code for it?


I am working on the file "2.1/tutorials/general_concepts.ipynb".
The first task is:
The 'qualifier' attribute is essentially an abbreviated name for the Parameter.
These tags will be shared across all Parameters, regardless of their type.
Attributes, on the other hand, can be dependent on the type of the Parameter and tell the Parameter its rules and how to interpret its value.  You can access a list of available attributes as follows:
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
The only exception to this is that (unlike Python), 'true' or 'True' will cast to True and 'false' or 'False' will cast to False.
Can you write Python code for it?

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

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


I am working on the file "2.1/tutorials/general_concepts.ipynb".
The first task is:
The set_value method also accepts a unit - this doesn't change the default_unit internally, but instead converts the provided value before storing.
Can you write Python code for it?

param.set_value(10)
print param.get_quantity()

param.set_value(0.001*u.km)
print param.get_quantity()

param.set_value(10, unit='cm')
print param.get_quantity()


I am working on the file "2.1/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_value method:
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
Twigs
The string notation used for the Parameters is called a 'twig' - its simply a combination of all the tags joined with the '@' symbol and gives a very convenient way to access any Parameter.
The order of the tags doesn't matter, and you only need to provide enough tags to produce a unique match.  Since there is only one parameter with kind='kind1', we do not need to provide the extraneous context='context1' in the twig to get a match.
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/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.1/tutorials/general_concepts.ipynb".
The first task is:
and that each of these is available through both a dictionary key and an object attribute.  For example:
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/grav_redshift.ipynb".
The first task is:
Influence on Radial Velocities
Can you write Python code for it?

afig, mplfig = b.filter(model=['defaultradii_true', 'smallradii_true']).plot(legend=True, show=True)

afig, mplfig = b.filter(model=['smallradii_true', 'smallradii_false']).plot(legend=True, show=True)


I am working on the file "2.1/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()

b.add_dataset('lc', dataset='lc01')
b.add_dataset('mesh', times=[0], columns=['intensities*'])


I am working on the file "2.1/tutorials/gravb_bol.ipynb".
The first task is:
Comparing these two plots, it is essentially impossible to notice any difference between the two models.  But if we compare the intensities directly, we can see that there is a subtle difference, with a maximum difference of about 3%.
Can you write Python code for it?

np.nanmax((b.get_value('intensities', component='primary', model='gravb_bol_32') - b.get_value('intensities', component='primary', model='gravb_bol_10'))/b.get_value('intensities', component='primary', model='gravb_bol_10'))


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

b['teff@primary'] = 6000
b['gravb_bol@primary'] = 0.32

b.run_compute(model='gravb_bol_32')

afig, mplfig = b['primary@mesh01@gravb_bol_32'].plot(fc='intensities', ec='None', show=True)

b['gravb_bol@primary'] = 1.0

b.run_compute(model='gravb_bol_10')

afig, mplfig = b['primary@mesh01@gravb_bol_10'].plot(fc='intensities', ec='None', show=True)


I am working on the file "2.1/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))


I am working on the file "2.1/tutorials/intens_weighting.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Let's (roughtly) reproduce Figure 5 from Prsa et al. 2016 which shows the difference between photon and energy intensity weighting.
<img src="prsa+2016_fig5.png" alt="Figure 8" width="600px"/>
Can you write Python code for it?

for teff_primary in [5000,7500,10000,12500,15000]:
    b['teff@primary'] = teff_primary
    b['teff@secondary'] = 0.9 * teff_primary

    for weighting in ['energy', 'photon']:
        b['intens_weighting'] = weighting
        b.run_compute(irrad_method='none', model='{}_{}'.format(teff_primary, weighting))

teff_colormap = {5000: 'm', 7500: 'r', 10000: 'g', 12500: 'c', 15000: 'b'}

fig = plt.figure()
ax1, ax2 = fig.add_subplot(211), fig.add_subplot(212)

for teff, color in teff_colormap.items():
    fluxes_energy = b.get_value('fluxes@{}_energy'.format(teff))
    fluxes_photon = b.get_value('fluxes@{}_photon'.format(teff))
    phases = b.to_phase('times@lc@dataset')

    # alias data from -0.6 to 0.6
    fluxes_energy = np.append(fluxes_energy, fluxes_energy[abs(phases) > 0.4])
    fluxes_photon = np.append(fluxes_photon, fluxes_photon[abs(phases) > 0.4])
    phases = np.append(phases, phases[abs(phases)>0.4]+1.0)
    phases[phases > 1.0] = phases[phases > 1.0] - 2.0

    sort = phases.argsort()
    phases = phases[sort]
    fluxes_energy = fluxes_energy[sort]
    fluxes_photon = fluxes_photon[sort]

    ax1.plot(phases, fluxes_energy, color=color)
    ax2.plot(phases, fluxes_photon-fluxes_energy, color=color)

lbl = ax1.set_xlabel('')
lbl = ax1.set_ylabel('flux')
lbl = ax2.set_xlabel('phase')
lbl = ax2.set_ylabel('flux diff')


I am working on the file "2.1/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.1/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['requiv@primary'] = 2.5
b['gravb_bol@primary'] = 1.0

b['teff@secondary'] = 5000
b['requiv@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', 'requiv', '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.1/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 = phoebe.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.1/tutorials/irrad_method_horvat.ipynb".
The first task is:
Relevant Parameters
For parameters that affect reflection and heating (irrad_frac_*) see the tutorial on reflection and heating.
The 'irrad_method' compute option dictates whether irradiation is handled according to the new Horvat scheme which includes Lambert Scattering, Wilson's original reflection scheme, or ignored entirely.
Can you write Python code for it?


I am working on the file "2.1/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?

%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.1/tutorials/l3.ipynb".
The first task is:
As expected, adding 5 W/m^3 of third light simply shifts the light curve up by that exact same amount.
Can you write Python code for it?

afig, mplfig = b['lc01'].plot(model='no_third_light')
afig, mplfig = b['lc01'].plot(model='with_third_light', legend=True, show=True)


I am working on the file "2.1/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', columns=['intensities@lc01', 'abs_intensities@lc01'])

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: ", np.nanmean(b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='no_third_light'))
print "with_third_light abs_intensities: ", np.nanmean(b.get_value(qualifier='abs_intensities', component='primary', dataset='lc01', model='with_third_light'))

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


I am working on the file "2.1/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.1/tutorials/l3.ipynb".
The first task is:
We now see that the LC dataset created 'l3' parameters for the new dataset.
Can you write Python code for it?

b.filter(qualifier='l3')

print b['l3@lc01']


I am working on the file "2.1/tutorials/limb_darkening.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.1/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')

afig, mplfig = b['lc01@mymodel'].plot(show=True)


I am working on the file "2.1/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.1/tutorials/limb_darkening.ipynb".
The first task is:
Relevant Parameters
Can you write Python code for it?

print b['ld_func_bol@primary']

print b['ld_func_bol@primary'].choices

print b['ld_coeffs_bol@primary']

print b['ld_func@lc01']

print b['ld_func@lc01@primary'].choices


I am working on the file "2.1/tutorials/limb_darkening.ipynb".
The first task is:
We'll just add an 'lc' dataset
Can you write Python code for it?


I am working on the file "2.1/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?

%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.1/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.1/tutorials/ltte.ipynb".
The first task is:
Now let's add a light curve dataset to see how ltte affects the timings of eclipses.
Can you write Python code for it?

b.add_dataset('lc', times=phoebe.linspace(-0.05, 0.05, 51), dataset='lc01')


I am working on the file "2.1/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.1/tutorials/ltte.ipynb".
The first task is:
We'll just ignore the fact that this will be a completely unphysical system since we'll leave the radii and temperatures alone despite somewhat ridiculous masses - but since the masses and radii disagree so much, we'll have to abandon atmospheres and use blackbody.
Can you write Python code for it?

b.set_value_all('atm', 'blackbody')
b.set_value_all('ld_func', 'logarithmic')

b.run_compute(irrad_method='none', ltte=False, model='ltte_off')

b.run_compute(irrad_method='none', ltte=True, model='ltte_on')

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/tutorials/meshes.ipynb".
The first task is:
Any of the exposed columns are then available for plotting the mesh, via b.plot.
Can you write Python code for it?

afig, mplfig = b['mesh@model'].plot(time=0.2, fc='teffs', ec='none', show=True)


I am working on the file "2.1/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.1/tutorials/meshes.ipynb".
The first task is:
But we can also specify other columns to be included (by setting the columns parameter before calling run_compute)
Can you write Python code for it?

print b['columns@mesh']

b['columns@mesh'] = ['teffs']

b.run_compute()

print b['mesh@model'].qualifiers

print b.get_value('teffs', time=0.0, component='primary')


I am working on the file "2.1/tutorials/meshes.ipynb".
The first task is:
By default, the mesh only exposes the geometric columns of the triangles
Can you write Python code for it?


I am working on the file "2.1/tutorials/meshes.ipynb".
The first task is:
Note that we can no manually set the times of the mesh AND/OR reference the times for existing non-mesh datasets (such as the light curve we just added) as well as any of the various t0s in the system.
Can you write Python code for it?

b['times@mesh'] = [10]

b['include_times@mesh'] = ['lc01']

b.run_compute()

print b['mesh@model'].times


I am working on the file "2.1/tutorials/meshes.ipynb".
The first task is:
The 'Mesh' Dataset
NOTE: the "pbmesh" and "protomesh" have been removed as of PHOEBE 2.1+.
You must create a mesh dataset and specify the times and columns which you'd like exposed.  For more information, see the tutorial on the MESH dataset.
The mesh will be exposed at the times specified by the 'times' Parameter, as well as any times referenced by the 'include_times' SelectParameter.
So let's add a LC and MESH dataset.
Can you write Python code for it?

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

b.add_dataset('mesh')

print b['times@mesh']

print b['include_times@mesh']


I am working on the file "2.1/tutorials/mpi.ipynb".
The first task is:
MPI Modes
As of the 2.1 release, PHOEBE officially support parallelization using MPI.  Note that the 2.1.1 release fixed a bug related to using PHOEBE within non-openmpi environments.
There are several "modes of operation" depending on your settings and whether you're running your script within python or mpirun.  You can enable/disable MPI within phoebe by placing phoebe.mpi_on() or phoebe.mpi_off() at the top of your script.  If you do not do this, MPI will be enabled by default if within mpirun and disabled otherwise.
When MPI is enabled, PHOEBE will do the following:
* if within mpirun: uses PHOEBE's built-in per-dataset or per-time parallelization.  The main code you write in your script is executed on a single processor, but during run_compute the task is divided among the available resources.
* if not within mpirun (ie. in a serial python environment): will spawn a separate thread at phoebe.frontend.bundle.Bundle.run_compute, using number of processors sent to phoebe.mpi_on (for example: phoebe.mpi_on(nprocs=4)).
When MPI is disabled, PHOEBE will do the following:
* if within mpirun: PHOEBE will run equally on all processors. The user can customize parallelization with access to phoebe.mpi.nprocs, phoebe.mpi.myrank.  Your script runs equally on each processor, meaning you have multiple (separate) copies of the bundle.
* if not within mpirun (ie. in a serial python environment): PHOEBE will run on a single processor in serial-mode.
Accessing/Changing MPI Settings
To check the currently adopted settings, as well as quickly access information needed for manually doing your own parallelization, access the phoebe.mpi object.
Can you write Python code for it?

print(phoebe.mpi.enabled)

print(phoebe.mpi.mode)

phoebe.mpi_on()

print(phoebe.mpi.enabled)

print(phoebe.mpi.mode)

print(phoebe.mpi.myrank)

print(phoebe.mpi.nprocs)


I am working on the file "2.1/tutorials/mpi.ipynb".
The first task is:
PHOEBE determines whether the current script is running within an MPI environment by checking for environment variables set by mpirun/mpiexec.  If you run into any issues with PHOEBE not behaving as expected, check to see whether PHOEBE thinks its within mpirun.
Can you write Python code for it?


I am working on the file "2.1/tutorials/optimizing.ipynb".
The first task is:
If disabled, you can always manually run the checks via b.run_checks().
Can you write Python code for it?

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

b.set_value('requiv', component='primary', value=50)

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


I am working on the file "2.1/tutorials/optimizing.ipynb".
The first task is:
Interactive Constraints
By default, interactive constraints are always enabled in PHOEBE, unless explicitly disabled.  Whenever a value is changed in the bundle that affects the value of a constrained value, that constraint is immediately executed and all applicable values updated.  The ensures that all constrained values are "up-to-date".
If disabled, constraints are delayed and only executed when needed by PHOEBE (when calling run_compute, for example).  This can save significant time, as each value that needs updating only needs to have its constraint executed once, instead of multiple times.
This default behavior can be changed via phoebe.interactive_constraints_on() or phoebe.interactive_constraints_off().  The current value can be accessed via phoebe.conf.interactive_constraints.
Let's first look at the default behavior with interactive constraints on.
Can you write Python code for it?

print(phoebe.conf.interactive_constraints)

print(b.filter('mass', component='primary'))

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

print(b.filter('mass', component='primary'))


I am working on the file "2.1/tutorials/optimizing.ipynb".
The first task is:
Note that the mass has already updated, according to the constraint, when the value of the semi-major axes was changed.  If we disable interactive constraints this will not be the case.
Can you write Python code for it?

phoebe.interactive_constraints_off()

print(phoebe.conf.interactive_constraints)

print(b.filter('mass', component='primary'))

b.set_value('sma@binary', 15)

print(b.filter('mass', component='primary'))


I am working on the file "2.1/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.1/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.1/tutorials/passbands.ipynb".
The first task is:
Let us now plot a range of temperatures, to make sure that normal emergent passband intensities do what they are supposed to do. While at it, let us compare what we get for the Johnson:V passband.
Can you write Python code for it?

jV = phoebe.get_passband('Johnson:V')
teffs = np.linspace(5000, 8000, 100)
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='mypb')
plt.plot(teffs, jV.Inorm(teffs, atm='blackbody', ld_func='linear', ld_coeffs=[0.0]), label='jV')
plt.legend(loc='lower right')
plt.show()


I am working on the file "2.1/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.1/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.1/tutorials/passbands.ipynb".
The first task is:
Quite a difference. That is why using model atmospheres is superior when accuracy is of importance. Next, we need to compute direction-dependent intensities for all our limb darkening and boosting needs. This is a step that takes a long time; depending on your computer speed, it can take a few hours to complete.
Can you write Python code for it?


I am working on the file "2.1/tutorials/passbands.ipynb".
The first task is:
Registering a passband
The first step in introducing a new passband into PHOEBE is registering it with the system. We use the Passband class for that.
Can you write Python code for it?

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')


I am working on the file "2.1/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.1/tutorials/passbands.ipynb".
The first task is:
The first argument, ptf, is the passband transmission file we just created. Of course, you would provide an actual passband transmission function that comes from a respectable source rather than this silly tutorial.
The next two arguments, pbset and pbname, should be taken in unison. The way PHOEBE refers to passbands is a pbset:pbname string, for example Johnson:V, Cousins:Rc, etc. Thus, our fake passband will be Custom:mypb.
The following two arguments, effwl and wlunits, also come as a pair. PHOEBE uses effective wavelength to apply zero-level passband corrections when better options (such as model atmospheres) are unavailable. Effective wavelength is a transmission-weighted average wavelength in the units given by wlunits.
The calibrated parameter instructs PHOEBE whether to take the transmission function as calibrated, i.e. the flux through the passband is absolutely calibrated. If set to True, PHOEBE will assume that absolute intensities computed using the passband transmission function do not need further calibration. If False, the intensities are considered as scaled rather than absolute, i.e. correct to a scaling constant. Most modern passbands provided in the recent literature are calibrated.
The reference parameter holds a reference string to the literature from which the transmission function was taken from. It is common that updated transmission functions become available, which is the point of the version parameter. If there are multiple versions of the transmission function, PHOEBE will by default take the largest value, or the value that is explicitly requested in the filter string, i.e. Johnson:V:1.0 or Johnson:V:2.0.
Finally, the comments parameter is a convenience parameter to store any additional pertinent information.
Computing blackbody response
To significantly speed up calculations, passband coefficients are stored in lookup tables instead of computing the intensities over and over again on the fly. Computed passband tables are tagged in the content property of the class:
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/tutorials/pblum.ipynb".
The first task is:
Accessing Model Luminosities
NEW IN PHOEBE 2.1: Passband luminosities at t0@system per-star (including following all coupling logic) can be computed and exposed on the fly by calling compute_pblums.
Can you write Python code for it?


I am working on the file "2.1/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()

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/tutorials/pblum.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.1/tutorials/pblum.ipynb".
The first task is:
By default this exposes pblums for all component-dataset pairs in the form of a dictionary.  Alternatively, you can pass a label or list of labels to component and/or dataset.
Can you write Python code for it?


I am working on the file "2.1/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

print b.compute_pblums()

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.1/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()

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/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()

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
In most cases you will not want decoupled luminosities as they can easily break the self-consistency of your model.
Now we'll just undo our changes before we look at accessing model luminosities.
Can you write Python code for it?

b.set_value_all('teff', 6000)
b.set_value_all('pblum', 4*np.pi)
b['pblum_ref@primary'] = 'self'
b['pblum_ref@secondary'] = 'primary'


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
In this case, since our two stars are identical, the synthetic luminosity of the secondary star should be the same as the primary (and the same as pblum@primary).
Can you write Python code for it?

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.1/tutorials/pblum.ipynb".
The first task is:
Let us undo our changes before we look at decoupled luminosities.
Can you write Python code for it?

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


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
Let's see how changing the value of pblum affects the computed light curve.  By default, pblum is set to be 4 pi, giving a total flux for the primary star of ~1.
Since the secondary star in the default binary is identical to the primary star, we'd expect an out-of-eclipse flux of the binary to be ~2.
Can you write Python code for it?

b.run_compute()

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/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.1/tutorials/pblum.ipynb".
The first task is:
Note that this same logic is applied (at t0) to initialize all passband luminosities within the backend, so does not need to be called before run_compute.
In order to access passband luminosities at times other than t0, you can add a mesh dataset and request the pblum column to be exposed.  For stars that have pblum defined (as opposed to coupled to another star in the system), this value should be equivalent to the value of the parameter (at t0, and in simple circular cases will probably be equivalent at all times).
Let's create a mesh dataset at a few times and then access the synthetic luminosities.
Can you write Python code for it?

b.add_dataset('mesh', times=np.linspace(0,1,5), dataset='mesh01', columns=['areas', 'pblum@lc01', 'ldint@lc01', 'ptfarea@lc01', 'abs_normal_intensities@lc01', 'normal_intensities@lc01'])

b.run_compute()


I am working on the file "2.1/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.1/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()

afig, mplfig = b.plot(show=True)


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
Now, we'll just undo our changes before continuing
Can you write Python code for it?


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
Since the luminosities are passband-dependent, they are stored with the same dataset as the light curve (or RV), but with the mesh method, and are available at each of the times at which a mesh was stored.
Can you write Python code for it?


I am working on the file "2.1/tutorials/pblum.ipynb".
The first task is:
The 'pblum' parameter is only relevant for each component-dataset pair in which pblum_ref=='self'.  This component will then have its intensities scaled such that they match the value provided by pblum.  In general, a pblum of 4pi will result in an out-of-eclipse flux of ~1.
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/pitch_yaw.ipynb".
The first task is:
And if we set the yaw to be non-zero, we'll see the rotation axis rotate on the plane of the sky.
Can you write Python code for it?

b['pitch@secondary@component'] = 0
b['yaw@secondary@component'] = 30

b.run_compute(irrad_method='none')

afig, mplfig = b.plot(time=0.0, fc='teffs', ec='none', x='us', y='vs', show=True)

afig, mplfig = b.plot(time=0.0, fc='teffs', ec='none', x='ws', y='vs', show=True)


I am working on the file "2.1/tutorials/pitch_yaw.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.1/tutorials/pitch_yaw.ipynb".
The first task is:
Note also that the system is aligned by default, with the pitch and yaw both set to zero.
Misaligned Systems
To create a misaligned system, we must set at pitch and/or yaw to be non-zero.
But first let's create an aligned system for comparison.  In order to easily see the spin-axis, we'll plot the effective temperature and spin-up our star to exaggerate the effect.
Can you write Python code for it?

b['syncpar@secondary'] = 5.0

b['pitch@secondary'] = 0
b['yaw@secondary'] = 0

b.run_compute(irrad_method='none')


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

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


I am working on the file "2.1/tutorials/pitch_yaw.ipynb".
The first task is:
Relevant Parameters
The 'pitch' parameter defines the misalignment of a given star in the same direction as the inclination.  We can see how it is defined relative to the inclination by accessing the constraint.
Note that, by default, it is the inclination of the component that is constrained with the inclination of the orbit and the pitch as free parameters.
Can you write Python code for it?

print b['pitch@component']

print b['incl@constraint']


I am working on the file "2.1/tutorials/pitch_yaw.ipynb".
The first task is:
We'll plot the mesh as it would be seen on the plane of the sky.
Can you write Python code for it?

afig, mplfig = b.plot(time=0.0, fc='teffs', ec='none', x='us', y='vs', show=True)


I am working on the file "2.1/tutorials/pitch_yaw.ipynb".
The first task is:
and also with the line-of-sight along the x-axis.
Can you write Python code for it?

afig, mplfig = b.plot(time=0.0, fc='teffs', ec='none', x='ws', y='vs', show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Adding a Colorbar
To add a colorbar (or sizebar, etc), send draw_sidebars=True to the plot call.
Can you write Python code for it?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(x='times', c='vws', draw_sidebars=True, show=True)


I am working on the file "2.1/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.1/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.1/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.1/tutorials/plotting.ipynb".
The first task is:
Axes Limits
Axes limits are determined by the data automatically.  To set custom axes limits, either use matplotlib methods on the returned axes objects, or pass limits as a list or tuple.
Can you write Python code for it?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(xlim=(-2,2), show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Choosing colors works slightly differently for meshes (ie you can set fc for facecolor and ec for edgecolor).  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?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(x='times', c='vws', cmap='spring', show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Colors
Colors of points and lines, by default, cycle according to matplotlib's color policy.  To manually set the color, simply pass a matplotlib recognized color to the 'c' keyword.
Can you write Python code for it?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(c='r', show=True)


I am working on the file "2.1/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
LP 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?

afig, mplfig = b['lc01@dataset'].plot(x='phases', z=0, show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Labels and Legends
To add a legend, include legend=True.
For details on placement and formatting of the legend see matplotlib's documentation.
Can you write Python code for it?

afig, mplfig = b['orb@run_with_incl_80'].plot(show=True, legend=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Other Plotting Options
Valid plotting options that are directly passed to matplotlib include:
- linestyle
- marker
Note that sizes (markersize, linewidth) should be handled by passing the size to 's' and attempting to set markersize or linewidth directly will raise an error.  See also the autofig documention on size scales.
Can you write Python code for it?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(linestyle=':', s=0.1, show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
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?

afig, mplfig = b['orb01@primary@run_with_incl_80'].plot(x='times', y='vus', show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
Selecting Datasets
In addition to filtering and calling plot on the resulting ParameterSet, plot can accept a twig or filter on any of the available parameter tags.
For this reason, any of the following give identical results:
Can you write Python code for it?

afig, mplfig = b['primary@orb@run_with_incl_80'].plot(show=True)

afig, mplfig = b.plot(component='primary', kind='orb', model='run_with_incl_80', show=True)

afig, mplfig = b.plot('primary@orb@run_with_incl_80', show=True)


I am working on the file "2.1/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 b.show or b.savefig after calling plot
use the returned autofig and matplotlib figures however you'd like
pass show=True to the plot method.
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
LP 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.1/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.1/tutorials/plotting.ipynb".
The first task is:
Time (highlight and uncover)
The built-in plot method also provides convenience options to either highlight the interpolated point for a given time, or only show the dataset up to a given time.
Highlight
The higlight option is enabled by default so long as a time (or times) is passed to plot.  It simply adds an extra marker at the sent time - interpolating in the synthetic model if necessary.
Can you write Python code for it?

afig, mplfig = b['orb@run_with_incl_80'].plot(time=1.0, show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
To change the style of the "highlighted" points, you can pass matplotlib recognized markers, colors, and markersizes to the highlight_marker, highlight_color, and highlight_ms keywords, respectively.
Can you write Python code for it?

afig, mplfig = b['orb@run_with_incl_80'].plot(time=1.0, highlight_marker='s', highlight_color='g', highlight_ms=20, show=True)


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

afig, mplfig = b['lc01@dataset'].plot(yerror=None, show=True)


I am working on the file "2.1/tutorials/plotting.ipynb".
The first task is:
To override the position or styling of the legend, you can pass valid options to legend_kwargs which will be passed on to plt.legend
Can you write Python code for it?

afig, mplfig = b['orb@run_with_incl_80'].plot(show=True, legend=True, legend_kwargs={'loc': 'center', 'facecolor': 'r'})


I am working on the file "2.1/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.1/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.1/tutorials/reflection_heating.ipynb".
The first task is:
In order to see the effect of reflection, let's set "irrad_frac_refl_bol" of both of our stars to 0.3 - that is 30% of the incident flux will go towards reflection and 70% will be ignored.
Can you write Python code for it?


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

b.add_dataset('mesh', times=[0.2], columns=['intensities@lc01'])

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

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

afig, mplfig = b.plot(kind='mesh', model='refl_false', fc='intensities', ec='none', show=True)

afig, mplfig = b.plot(kind='mesh', model='refl_true', fc='intensities', ec='none', show=True)


I am working on the file "2.1/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')

afig, mplfig = b.plot(show=True, legend=True)

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.1/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.1/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.1/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.1/tutorials/requiv.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.1/tutorials/requiv.ipynb".
The first task is:
Critical Potentials and System Checks
Additionally, for each detached component, there is an requiv_max Parameter which shows the critical value at which the Roche surface will overflow.  Setting requiv to a larger value will fail system checks and raise a warning.
Can you write Python code for it?

print b['requiv_max@primary@component']

print b['requiv_max@primary@constraint']

b.set_value('requiv@primary@component', 3)


I am working on the file "2.1/tutorials/requiv.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.1/tutorials/requiv_crit_contact.ipynb".
The first task is:
Changing Parameterization
It is possible to change this parameterization to allow any one of the four parameters (requiv@primary, requiv@secondary, pot@contact_envelope, fillout_factor@contact_envelope) to be adjustable and the other two to be constrained.  Doing so requires flipping one or two constraints via b.flip_constraint().
Let's first flip the  constraints so that we can provide the potential of the envelope.
Can you write Python code for it?

b.flip_constraint('pot', solve_for='requiv@primary')

print b.filter(qualifier=['requiv', 'pot', 'fillout_factor'])


I am working on the file "2.1/tutorials/requiv_crit_contact.ipynb".
The first task is:
Contact Systems
Contact systems are created by passing contact_binary=True to phoebe.default_binary() or by manually adding an envelope and setting the hierarchy correctly.
By default, requiv@primary is the free Parameter, with requiv@secondary, pot@contact_envelope, and fillout_factor@contact_envelope constrained such that there is one single surface defining the envelope.
Can you write Python code for it?

print b.filter(qualifier=['requiv', 'pot', 'fillout_factor'])


I am working on the file "2.1/tutorials/requiv_crit_contact.ipynb".
The first task is:
In order to pass the system checks, these values must be between their minimum and maximum value ensuring the system is not underflowing (in which case it should be detached or semi-detached) or overflowing and losing mass.
These limiting values are constrained parameters, allowing us to see the allowed range for any parameterization.
Can you write Python code for it?

print b.filter(qualifier=['requiv_max', 'requiv_min', 'pot_max', 'pot_min'])


I am working on the file "2.1/tutorials/requiv_crit_contact.ipynb".
The first task is:
Or we could instead flip two constraints to have fillout factor of the envelope as the adjustable parameter (we'll start with a fresh bundle just to avoid confusion with the flipping we just did):
Can you write Python code for it?

b = phoebe.default_binary(contact_binary=True)
b.flip_constraint('pot', solve_for='requiv@primary')
b.flip_constraint('fillout_factor', solve_for='pot')

print b.filter(qualifier=['requiv', 'pot', 'fillout_factor'])


I am working on the file "2.1/tutorials/requiv_crit_detached.ipynb".
The first task is:
Detached Systems
Detached systems are the default case for default_binary.  The requiv_max parameter is constrained to show the maximum value for requiv before the system will begin overflowing at periastron.
Can you write Python code for it?


I am working on the file "2.1/tutorials/requiv_crit_detached.ipynb".
The first task is:
If we increase 'requiv' past the critical point, we'll receive a warning from the logger and would get an error if attempting to call b.run_compute().
Can you write Python code for it?

b['requiv@primary'] = 2.2

print(b.run_checks())


I am working on the file "2.1/tutorials/requiv_crit_detached.ipynb".
The first task is:
We can see that the default system is well within this critical value by printing all radii and critical radii.
Can you write Python code for it?


I am working on the file "2.1/tutorials/requiv_crit_semidetached.ipynb".
The first task is:
We can view the constraint on requiv by accessing the constraint:
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/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.1/tutorials/settings.ipynb".
The first task is:
In our default binary there are temperatures ('teff') parameters for each of the components ('primary' and 'secondary').  If we were to do:
b['teff@component'] = 6000
this would raise an error.  Under-the-hood, this is simply calling:
b.set_value('teff@component', 6000)
which of course would also raise an error.
In order to set both temperatures to 6000, you would either have to loop over the components or call the set_value_all method:
Can you write Python code for it?

b.set_value_all('teff@component', 4000)
print b['value@teff@primary@component'], b['value@teff@secondary@component']


I am working on the file "2.1/tutorials/settings.ipynb".
The first task is:
In our default binary, there are several inclination parameters - one for each component ('primary', 'secondary', 'binary') and one with the constraint context (to keep the inclinations aligned).
This can be inconvenient... if you want to set the value of the binary's inclination, you must always provide extra information (like '@component').
Instead, we can always have the dictionary access search in the component context by doing the following
Can you write Python code for it?

b['dict_filter@setting'] = {'context': 'component'}

b['incl']


I am working on the file "2.1/tutorials/settings.ipynb".
The first task is:
Now let's disable this so it doesn't confuse us while looking at the other options
Can you write Python code for it?


I am working on the file "2.1/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.1/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.1/tutorials/settings.ipynb".
The first task is:
and can be set as any other Parameter in the Bundle
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.1/tutorials/settings.ipynb".
The first task is:
dict_filter
dict_filter is a Parameter that accepts a dictionary.  This dictionary will then always be sent to the filter call which is done under-the-hood during dictionary access.
Can you write Python code for it?


I am working on the file "2.1/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.1/tutorials/spots.ipynb".
The first task is:
Adding Spots
Let's add one spot to each of our stars in the binary.
A spot is a feature, and needs to be attached directly to a component upon creation.  Providing a tag for 'feature' is entirely optional - if one is not provided it will be created automatically.
Can you write Python code for it?


I am working on the file "2.1/tutorials/spots.ipynb".
The first task is:
As a shortcut, we can also call add_spot directly.
Can you write Python code for it?


I am working on the file "2.1/tutorials/spots.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.1/tutorials/spots.ipynb".
The first task is:
At a later time, the spot is still technically at the same coordinates, but longitude of 0 no longer corresponds to pointing to the companion star.  The coordinate system has rotated along with the asyncronous rotation of the star.
Can you write Python code for it?

afig, mplfig = b.plot(time=0.25, y='ws', fc='teffs', facecmap='YlOrRd', ec='None', show=True)

afig, mplfig = b.plot(time=0.5, y='ws', fc='teffs', facecmap='YlOrRd', ec='None', show=True)

ax, artists = b.plot(time=0.75, y='ws', fc='teffs', facecmap='YlOrRd', ec='None', show=True)


I am working on the file "2.1/tutorials/spots.ipynb".
The first task is:
Relevant Parameters
A spot is defined by the colatitude (where 0 is defined as the North (spin) Pole) and longitude (where 0 is defined as pointing towards the other star for a binary, or to the observer for a single star) of its center, its angular radius, and the ratio of temperature of the spot to the local intrinsic value.
Can you write Python code for it?

print b['spot01']

b.set_value(qualifier='relteff', feature='spot01', value=0.9)

b.set_value(qualifier='radius', feature='spot01', value=30)

b.set_value(qualifier='colat', feature='spot01', value=45)

b.set_value(qualifier='long', feature='spot01', value=90)


I am working on the file "2.1/tutorials/spots.ipynb".
The first task is:
Since the syncpar was set to 1.5, one full orbit later the star (and the spot) has made an extra half-rotation.
Can you write Python code for it?

ax, artists = b.plot(time=1.0, y='ws', fc='teffs', facecmap='YlOrRd', ec='None', show=True)


I am working on the file "2.1/tutorials/spots.ipynb".
The first task is:
Spot Corotation
The positions (colat, long) of a spot are defined at t0 (note: t0@system, not necessarily t0_perpass or t0_supconj).  If the stars are not synchronous, then the spots will corotate with the star.  To illustrate this, let's set the syncpar > 1 and plot the mesh at three different phases from above.
Can you write Python code for it?

b.set_value('syncpar@primary', 1.5)

b.run_compute(irrad_method='none')


I am working on the file "2.1/tutorials/spots.ipynb".
The first task is:
To see the spot, add a mesh dataset and plot it.
Can you write Python code for it?

b.add_dataset('mesh', times=[0,0.25,0.5,0.75,1.0], columns=['teffs'])

b.run_compute()

afig, mplfig = b.filter(component='primary', time=0.75).plot(fc='teffs', show=True)


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
't0_perpass' defines the time at which both components in our orbit is at periastron passage.  By default this parameter is constrained by 't0_supconj'.  For more details or information on how to change which parameter is editable, see the Constraints Tutorial.
Can you write Python code for it?

b.get_parameter('t0_perpass', context='component')

b.get_parameter('t0_perpass', context='constraint')


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
And let's make our system a little more interesting so that we can discriminate between the various t0s
Can you write Python code for it?

b.set_value('sma@binary', 20)
b.set_value('q', 0.8)
b.set_value('ecc', 0.8)
b.set_value('per0', 45)


I am working on the file "2.1/tutorials/t0s.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.1/tutorials/t0s.ipynb".
The first task is:
In addition, there is a single 't0' parameter that is system-wide.  This parameter simply defines the time at which all parameters are defined and therefore at which all computations start.  The value of this parameter begins to play an important role if any parameter is given a time-derivative (see apsidal motion for an example) or when using N-body instead of Keplerian dynamics (coming in a future release).
Can you write Python code for it?


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
Influence on Oribits (positions)
Can you write Python code for it?

b.add_dataset('orb', times=np.linspace(-1,1,1001))

b.run_compute(ltte=False)


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
Influence on Phasing
All computations in PHOEBE 2 are done in the time-domain.  Times can be translated to phases using any ephemeris available, as well as any of the t0s.
By default (if not passing any options), times will be phased using the outer-most orbit in the system and using 't0_supconj'.
Can you write Python code for it?

b.to_phase(0.0)

b.to_phase(0.0, component='binary', t0='t0_supconj')

b.to_phase(0.0, component='binary', t0='t0_perpass')

b.to_phase(0.0, component='binary', t0='t0_ref')


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
Similarly, if plotting phases on any axis, passing the 't0' keyword will set the zero-phase accordingly.  To see this, let's compute a light curve and phase it with the various t0s shown in the orbits above.
Can you write Python code for it?

b.add_dataset('lc', times=np.linspace(0,1,51), ld_func='linear', ld_coeffs=[0.0])

b.run_compute(ltte=False, irrad_method='none', atm='blackbody')

afig, mplfig = b['lc01@model'].plot(x='phases', t0='t0_supconj', xlim=(-0.3,0.3), show=True)

afig, mplfig = b['lc01@model'].plot(x='phases', t0='t0_perpass', xlim=(-0.3,0.3), show=True)

afig, mplfig = b['lc01@model'].plot(x='phases', t0='t0_ref', xlim=(-0.3,0.3), show=True)


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
The 't0_ref' defines the time at which the primary component in our orbit passes an arbitrary reference point.  This 't0_ref' is defined in the same way as PHOEBE legacy's 'HJD0' parameter, so is included for convenience translating between the two.
Can you write Python code for it?

b.get_parameter('t0_ref', context='component')

b.get_parameter('t0_ref', context='constraint')


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
To visualize where these times are with respect to the orbits, we can plot the model orbit and highlight the positions of each star at the times defined by these parameters.  Note here that the observer is in the positive w-direction.
NOTE: sending z=0 will override the default of ordering in z by vs (the unused coordinate in the same system), which can be expensive to draw.
Can you write Python code for it?

afig, mplfig = b.plot(x='us', y='ws', z=0, time='t0_supconj', show=True)

afig, mplfig = b.plot(x='us', y='ws', z=0, time='t0_perpass', show=True)

afig, mplfig = b.plot(x='us', y='ws', z=0, time='t0_ref', show=True)


I am working on the file "2.1/tutorials/t0s.ipynb".
The first task is:
t0 Parameters
There are three t0 parameters that are available to define an orbit (but only one of which is editable at any given time), as well as a t0 parameter for the entire system.  Let's first access the three t0 parameters for our binary orbit.
't0_supconj' defines the time at which the primary component in our orbit is at superior conjunction.  For a binary system in which there are eclipses, this is defined as the primary eclipse.  By default this parameter is editable.
Can you write Python code for it?


I am working on the file "2.1/tutorials/vgamma.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.1/tutorials/vgamma.ipynb".
The first task is:
Changing Systemic Velocity and LTTE
By default, vgamma is initially set to 0.0
Can you write Python code for it?


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
For our second model, we'll set a somewhat ridiculous value for the systemic velocity (so that the affects are exagerated and clearly visible over one orbit), but leave ltte off.
Can you write Python code for it?

b['vgamma@system'] = 100

b.run_compute(irrad_method='none', model='100_false')


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Now let's compare the various models across all our different datasets.
Let's set the colors so that all figures will have systemic velocity shown in blue, systemic velocity with ltte=False in red, and systemic velocity with ltte=True in green.
Can you write Python code for it?


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
Influence on Orbits (positions, velocities)
In the orbit, the addition of a systemic velocity affects both the positions and velocities.  So if we plot the orbits from above (u-w plane) we can see see orbit spiral in the w-direction.  Note that this actually shows the barycenter of the orbit moving - and it was only at 0,0,0 at t0.  This also stresses the importance of using a reasonable t0 - here 900 days later, the barycenter has moved significantly from the center of the coordinate system.
Can you write Python code for it?

afig, mplfig = b.filter(kind='orb', model=['0_false', '100_false']).plot(x='us', y='ws',
                             c=colors, linestyle='solid',
                             axorder={'orb1': 0, 'orb2': 1},
                             subplot_grid=(1,2), tight_layout=True, show=True)