I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
intensities are the projected relative intensities (towards the observer) per-element.
boost_factors
Can you write Python code for it?

print(b.get_parameter(qualifier='boost_factors',
                      component='primary',
                      dataset='lc01',
                      kind='mesh',
                      context='model'))


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
l3_frac
l3_frac is only avaible if l3_mode is set to 'fraction'.  See the "Third" Light tutorial for more details.
Can you write Python code for it?

b.set_value('l3_mode', value='fraction')

print(b.get_parameter(qualifier='l3_frac'))


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
l3_mode
See the "Third" Light tutorial
Can you write Python code for it?


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
ld_func
ld_func will only be available if ld_mode is not 'interp', so let's set it to 'lookup'.  See the limb darkening tutorial for more details.
Can you write Python code for it?

b.set_value('ld_mode', component='primary', value='lookup')

print(b.get_parameter(qualifier='ld_func', component='primary'))


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
passband
See the Atmospheres & Passbands tutorial
Can you write Python code for it?


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
pblum_component
pblum_component is only available if pblum_mode is set to 'component-coupled'.  See the passband luminosity tutorial for more details.
Can you write Python code for it?

b.set_value('pblum_mode', value='component-coupled')

print(b.get_parameter(qualifier='pblum_component'))


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
pblum_dataset
pblum_dataset is only available if pblum_mode is set to 'dataset-coupled'.  In this case we'll get a warning because there is only one dataset.  See the passband luminosity tutorial for more details.
Can you write Python code for it?

b.set_value('pblum_mode', value='dataset-coupled')

print(b.get_parameter(qualifier='pblum_dataset'))


I am working on the file "2.3/tutorials/LC.ipynb".
The first task is:
pblum_ext is the extrinsic passband luminosity of the entire star/mesh - this is a single value (unlike most of the parameters in the mesh) and does not have per-element values.
abs_normal_intensities
Can you write Python code for it?

print(b.get_parameter(qualifier='abs_normal_intensities',
                      component='primary',
                      dataset='lc01',
                      kind='mesh',
                      context='model'))


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


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


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
As we can see, by default it selects all available LC datasets and bins the light curves to 500 bins. We can change any of these in the 'ebai01' object or in the call to run_solver. If there are less points that bins, the phase binning is skipped. Just in case, let's turn off the phase binning for this example, since we already have only 100 data points.
Can you write Python code for it?

b['phase_bin@ebai01'] = False
print(b.filter(solver='ebai01'))

b.run_solver('ebai01', solution='ebai_solution')


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
EBAI
Let's start with the EBAI estimator, which with the help of a trained neural network estimates of the time of superior conjunction, sum of equivalent radii, inclination,  temperature ratio, esinw and ecosw.
NOTE: EBAI currently only works if the eclipse widths are less than 0.25 in phase.  If (either) eclipse is detected to be wider than 0.25, NANs will be returned and an error will be raised when attempting to adopt the solution.
First we add the solver options via add_solver:
Can you write Python code for it?


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
If we now plot the light curves, we'll see only the eclipses have been "masked out" of the data.
Can you write Python code for it?

_ = b.plot(x='phases', ls='-', legend=True, show=True)


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
Initialize the bundle
To showcase the estimators, we'll start with a fresh default bundle and set the pblum_mode to 'dataset-scaled' to simplify the comparison between the light curves.  Fore more information, see the pblum tutorial.
Can you write Python code for it?

b = phoebe.default_binary()
b.add_dataset('lc', times=times, fluxes=fluxes, sigmas=sigmas_lc)
b.set_value_all('ld_mode', 'manual')
b.set_value_all('ld_mode_bol', 'manual')
b.set_value_all('atm', 'blackbody')
b.set_value('pblum_mode', 'dataset-scaled')

b.run_compute(model='default')
_ = b.plot(x='phase', show=True)


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
Some of the parameters that the EBAI estimator returns are constrained, so to properly set their values through adopt_solution, we need to flip the relevant constraints first. Note that simply running b.adopt_solution() without this step will result in an error.
Can you write Python code for it?

try:
    b.adopt_solution('ebai_solution')
except Exception as e:
    print(e)

b.flip_constraint('requivsumfrac', solve_for='requiv@secondary')

b.flip_constraint('teffratio', solve_for='teff@secondary')
b.flip_constraint('esinw', solve_for='ecc')
b.flip_constraint('ecosw', solve_for='per0')


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
The resulting solution returns our values of interest: eccentricity and argument of periastron, as well as the analytical fluxes of all two-Gaussian models (since expose_model = True) and the eclipse parameters determined from the best fit:
Can you write Python code for it?


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
Therefore, we can set them in the bundle by either adding mask_phases the to the adopt_parameters list before calling adopt_solution(), or after, as:
Can you write Python code for it?


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
To update the values in the bundle, we need to reverse-flip the constraints for esinw and ecosw and adopt the solution.
Can you write Python code for it?

b.flip_constraint('per0', solve_for='ecosw')
b.flip_constraint('ecc', solve_for='esinw')

print(b.adopt_solution('lcgeom_solution'))

b.run_compute(model='lcgeom_model')
_ = b.plot(x='phases', ls='-', legend=True, show=True)


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
lc_geometry
The EBAI estimator is known to have deficiencies in correctly estimating the eccentricity and argument of periastron, which can be seen in our solution too. To improve this, we can use the lc_geometry estimator, which is specifically tailored to estimating eccentricty and argument of periastron by determining the eclipse separation and widths.
Can you write Python code for it?

b.add_solver('estimator.lc_geometry', solver='lcgeom')

print(b.filter(solver='lcgeom'))


I am working on the file "2.3/tutorials/LC_estimators.ipynb".
The first task is:
phase masking
For more details on phase-masking see Advanced: Phase Masking.
lc_geometry also returns suggested mask_phases computed from the eclipse widths, which we can notice in the list of fitted_twigs. However, by default it is excluded from the adopt_parameters list:
Can you write Python code for it?


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
Dataset Parameters
Line profiles have an extra dimension than LC and RV datasets which have times as their independent variable.  For that reason, the parameters in the LP dataset are tagged with individual times instead of having a separate times array.  This allows the flux_densities and sigmas to be per-time.  Because of this, times is not a parameter, but instead must be passed when you call b.add_dataset if you want to attach actual line-profile data (flux_densities) to your dataset.  At that point, in order to change the times you would need to remove and re-add the dataset.  If you only want to compute synthetic line profiles, use compute_times or compute_phases instead.
Let's add a line profile dataset to the Bundle (see also the lp API docs).  Some parameters are only visible based on the values of other parameters, so we'll pass check_visible=False (see the filter API docs for more details).  These visibility rules will be explained below.
Can you write Python code for it?

b.add_dataset('lp', times=[0,1,2], wavelengths=phoebe.linspace(549, 551, 101))
print(b.get_dataset(kind='lp', check_visible=False))


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
Mesh Fields
Let's add a single mesh and see which columns from the line profile dataset are available to expose as a column in the mesh.
Can you write Python code for it?

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

print(b.get_parameter(qualifier='columns').choices)


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
Plotting
By default, LP datasets plot as 'flux_densities' vs 'wavelengths' for a single time.
Can you write Python code for it?

afig, mplfig = b.filter(dataset='lp01', context='model', time=0).plot(show=True)


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
The model for a line profile dataset will expose flux-densities at each time and for each component where the corresponding wavelengths Parameter was not empty.  Here since we used the default and exposed line-profiles for the entire system, we have a single entry per-time.
Can you write Python code for it?

print(b.filter(qualifier='flux_densities', context='model'))

print(b.get_parameter(qualifier='flux_densities', context='model', time=0))


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
components
Line profiles will be computed for each component in which the wavelengths are provided.  If we wanted to expose the line profile for the binary as a whole, we'd set the wavelenghts for wavelengths@binary.  If instead we wanted to expose per-star line profiles, we could set the wavelengths for both wavelengths@primary and wavelengths@secondary.
If you're passing wavelengths to the b.add_dataset call, it will default to filling the wavelengths at the system-level.  To override this, pass components=['primary', 'secondary'], as well.  For example: b.add_dataset('lp', wavelengths=np.linspace(549,551,101), components=['primary', 'secondary']).
flux_densities
Note that observation flux_densities parameters are exposed per-time, according to the value of times passed to add_dataset.
flux_densities parameters will be exposed in the model based on compute_times/compute_phases if not empty, otherwise according to times.  For more information, see the Compute Times & Phases tutorial.
Can you write Python code for it?

print(b.filter(qualifier='flux_densities'))

print(b.get_parameter(qualifier='flux_densities',
                      component='binary',
                      time=0.0))


I am working on the file "2.3/tutorials/LP.ipynb".
The first task is:
compute_times / compute_phases
See the Compute Times & Phases tutorial.
Can you write Python code for it?

print(b.get_parameter(qualifier='compute_times'))

print(b.get_parameter(qualifier='compute_phases', context='dataset'))

print(b.get_parameter(qualifier='phases_t0'))


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


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


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

print(b.filter(qualifier='wavelengths'))

print(b.get_parameter(qualifier='wavelengths', component='binary'))


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
Alternatively, if you provide simple 1-D fields to plot, a 2D x-y plot will be created using the values from each element (always for a single time - if meshes exist for multiple times in the model, you should provide a single time either in the twig or as a filter).
NOTE: providing z=0 will override the default of z-ordering the points by there "w" (line-of-sight distance) value, which can be expensive and take a while to draw.
Can you write Python code for it?

afig, mplfig = b.plot(x='mus', y='teffs', z=0, show=True)


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
Any of the 1-D fields (ie not vertices or normals) or matplotlib-recognized colornames can be used to color either the faces or edges of the triangles.  Passing none for edgecolor or facecolor turns off the coloring (you may want to set edgecolor=None if setting facecolor to disable the black outline).
Can you write Python code for it?

afig, mplfig = b.plot(fc='teffs', ec='None', show=True)


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

import phoebe

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
Dataset Parameters
Let's add a mesh dataset to the Bundle (see also the mesh API docs).
Can you write Python code for it?


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
Per-Element Parameters
uvw_elements and uvw_normals (plane-of-sky vertices positions and triangle normals) are used internally when plotting meshes and are only exposed if 'uvw' is in the coordinates parameter defined in the dataset (before calling run_compute).
Can you write Python code for it?

print(b.get_parameter(qualifier='uvw_elements',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='uvw_normals',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
Plotting
By default, MESH datasets plot as 'vs' vx 'us' (plane of sky coordinates) of just the surface elements, taken from the uvw_elements vectors.  If coordinates includes 'xyz' but not 'uvw', then the plots default to 'ys' vs 'xs'.  If coordinates is empty, then plotting defaults to a scatter plot based on the available parameters based on the value of columns.
Can you write Python code for it?


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

b.set_value('compute_times', [0])

b.set_value('columns', value='*')

print(b.get_value('columns'))

print(b.get_value('columns', expand=True))

b.run_compute()

print(b.filter(context='model').twigs)


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
The mesh_method parameter determines how each component in the system is discretized into its mesh, and has several options:
 * marching (default): this is the new method introduced in PHOEBE 2.  The star is discretized into triangles, with the attempt to make them each of equal-area and nearly equilateral.  Although not as fast as 'wd', this method is more robust and will always form a closed surface (when possible).
 * wd: this is a re-implementation of the Wilson-Devinney style meshing used in PHOEBE 1.0 (legacy), with the stars discretized into trapezoids in strips of latitude (we then split each trapezoid into two triangles).  This is faster, but suffers from gaps between the surface elements, and is mainly meant for testing and comparison with legacy.  See the WD-Style Meshing Example Script for more details.
ntriangles
The ntriangles parameter is only relevenat if mesh_method is 'marching' (so will not be available unless that is the case).
Can you write Python code for it?


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


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
compute_times / compute_phases
Note that as of PHOEBE 2.2, the mesh dataset no longer has a times parameter, as observations cannot be attached to the mesh dataset.
See the Compute Times & Phases tutorial.
Can you write Python code for it?


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


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


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


I am working on the file "2.3/tutorials/MESH.ipynb".
The first task is:
xyz_elements and xyz_normals (roche vertices positions and triangle normals) are used internally when plotting meshes and are only exposed if 'xyz' is in the coordinates parameter defined in the dataset (before calling run_compute).
Can you write Python code for it?

print(b.get_parameter(qualifier='xyz_elements',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='xyz_normals',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='us',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='rs',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='rprojs',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='nxs',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='mus',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='vxs',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='areas',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                      context='model'))

print(b.get_parameter(qualifier='loggs',
                      component='primary',
                      dataset='mesh01',
                      kind='mesh',
                     ...


I am working on the file "2.3/tutorials/ORB.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.
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.3/tutorials/ORB.ipynb".
The first task is:
Compute Options
Let's look at the compute options (for the default PHOEBE 2 backend) that relate to dynamics and the ORB dataset
Can you write Python code for it?


I am working on the file "2.3/tutorials/ORB.ipynb".
The first task is:
The dynamics_method parameter controls how stars and components are placed in the coordinate system as a function of time and has several choices:
 * keplerian (default): Use Kepler's laws to determine positions.  If the system has more than two components, then each orbit is treated independently and nested (ie there are no dynamical/tidal effects - the inner orbit is treated as a single point mass in the outer orbit).
 * nbody: Use an n-body integrator to determine positions.  Here the initial conditions (positions and velocities) are still defined by the orbit's Keplerian parameters at 't0@system'.  Closed orbits and orbital stability are not guaranteed and ejections can occur.
ltte
Can you write Python code for it?


I am working on the file "2.3/tutorials/ORB.ipynb".
The first task is:
The ltte parameter sets whether light travel time effects (Roemer delay) are included.  If set to False, the positions and velocities are returned as they actually are for that given object at that given time.  If set to True, they are instead returned as they were or will be when their light reaches the origin of the coordinate system.
See the ltte tutorial as well as the Systemic Velocity Example Script for an example of how 'ltte' and 'vgamma' (systemic velocity) interplay.
Synthetics
Can you write Python code for it?

b.set_value_all('compute_times', phoebe.linspace(0,3,201))

b.run_compute()

print(b.filter(context='model').twigs)

print(b.get_parameter(qualifier='times', component='primary', kind='orb', context='model'))

print(b.get_parameter(qualifier='us', component='primary', kind='orb', context='model'))

print(b.get_parameter(qualifier='vus', component='primary', kind='orb', context='model'))


I am working on the file "2.3/tutorials/ORB.ipynb".
The first task is:
compute_times / compute_phases
See the Compute Times & Phases tutorial.
Can you write Python code for it?


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


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
Any of these columns are then available to use as edge or facecolors when plotting the mesh (see the section on the MESH dataset).
Can you write Python code for it?

afig, mplfig = b.filter(kind='mesh').plot(fc='rvs', ec='None', show=True)


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


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
Compute Options
Let's look at the compute options (for the default PHOEBE 2 backend) that relate to the RV dataset.
Other compute options are covered elsewhere:
* parameters related to dynamics are explained in the section on the orb dataset
* parameters related to meshing, eclipse detection, and subdivision (used if rv_method=='flux-weighted') are explained in the section on the mesh dataset
* parameters related to computing fluxes (used if rv_method=='flux-weighted') are explained in the section on the lc dataset
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
Dataset Parameters
Let's add an RV dataset to the Bundle (see also the rv API docs).  Some parameters are only visible based on the values of other parameters, so we'll pass check_visible=False (see the filter API docs for more details).  These visibility rules will be explained below.
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
If rv_method is set to 'dynamical' then the computed radial velocities are simply the z-velocities of the centers of mass of each component.  In this case, only the dynamical options are relevant.  For more details on these, see the section on the orb dataset.
If rv_method is set to 'flux-weighted' then radial velocities are determined by the z-velocity of each visible surface element of the mesh, weighted by their respective intensities.  Since the stars are placed in their orbits by the dynamic options, the section on the orb dataset is still applicable.  So are the meshing options described in mesh dataset and the options for computing fluxes in lc dataset.  See also the Rossiter-McLaughlin example.
rv_grav
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
In system hierarchies where there may be multiple periods, it is also possible to determine whose period to use for phasing.
Can you write Python code for it?

print(b.filter(qualifier='period').components)

afig, mplfig = b.plot(x='phases:binary', show=True)


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
Mesh Fields
By adding a mesh dataset and setting the columns parameter, radial velocities per-element quantities can be exposed and plotted.  Since the radial velocities are flux-weighted, the flux-related quantities are also included (except relative intensities/luminosities that would require pblum scaling).  For a description of these, see the section on the lc dataset.
Let's add a mesh at the first time of the rv dataset and re-call run_compute
Can you write Python code for it?

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

print(b.get_parameter(qualifier='columns').choices)

b.set_value('columns', value=['rvs@rv01'])

b.run_compute(irrad_method='none')

print(b.get_model().datasets)


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
Plotting
By default, RV datasets plot as 'rvs' vs 'times'.
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
See the Gravitational Redshift example for more details on the influence this parameter has on radial velocities.
Synthetics
Can you write Python code for it?

b.set_value_all('times', phoebe.linspace(0,1,101))

b.run_compute(irrad_method='none')

print(b.filter(context='model').twigs)

print(b.get_parameter(qualifier='times', component='primary', kind='rv', context='model'))

print(b.get_parameter(qualifier='rvs', component='primary', kind='rv', context='model'))


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
compute_times / compute_phases
See the Compute Times & Phases tutorial.
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV.ipynb".
The first task is:
sigmas
The sigmas parameter is also only visible if the respective times parameter is not empty.
Can you write Python code for it?


I am working on the file "2.3/tutorials/RV_estimators.ipynb".
The first task is:
As we can see all values look okay, and we have asini@binary in the twigs, which means we'll need to flip the asini constraint to be able to set it with adopt_solution:
Can you write Python code for it?

b.flip_constraint('asini@binary', solve_for='sma@binary')
b.adopt_solution('rvgeom_solution')

b.run_compute()
_ = b.plot(x='phases', show=True)


I am working on the file "2.3/tutorials/RV_estimators.ipynb".
The first task is:
Generate data
Let's first initialize a bundle and change some of the parameter values. We'll then export the computed models as "observables" to use with the rv_geometry estimator.
Can you write Python code for it?

b = phoebe.default_binary()
# set parameter values
b.set_value('q', value = 0.6)
b.set_value('incl', component='binary', value = 84.5)
b.set_value('ecc', 0.2)
b.set_value('per0', 63.7)
b.set_value('sma', component='binary', value= 7.3)
b.set_value('vgamma', value= -32.84)

# add an rv dataset
b.add_dataset('rv', compute_phases=phoebe.linspace(0,1,101))

#compute the model
b.run_compute()

# extract the arrays from the model that we'll use as observables in the next step and add noise to the rvs
times = b.get_value('times', context='model', component='primary', dataset='rv01')
np.random.seed(0) # to ensure reproducibility with added noise
rvs1 = b.get_value('rvs', component='primary', context='model', dataset='rv01') + np.random.normal(size=times.shape)
rvs2 = b.get_value('rvs', component='secondary', context='model', dataset='rv01') + np.random.normal(size=times.shape)
sigmas_rv = np.ones_like(times) * 2


I am working on the file "2.3/tutorials/RV_estimators.ipynb".
The first task is:
If we compare the fitted_twigs from this solution with our two-RV solution, we'll notice two things:
- q is missing from the list
- We have asini@primary instead of asini@binary.
This is because with only one RV we cannot get a reliable estimate of the mass ratio and semi-major axis of the system and instead we revert to what can be estimated from just the one available RV, or in this case the semi-major axis of the primary orbit around the center of mass.
We still need to flip the asini@primary before adopting the solution, with flip_constraint:
Can you write Python code for it?

b.flip_constraint('asini@primary', solve_for='sma@binary')
b.adopt_solution('rvgeom_solution')

b.run_compute()
_ = b.plot(x='phases', show=True)


I am working on the file "2.3/tutorials/RV_estimators.ipynb".
The first task is:
single-lined RVs
In some cases, only one RV is available, in which case not all parameters can be estimated with rv_geometry. Let's recreate the above example with only providing the primary RV and see how the solution differs.
Can you write Python code for it?

b = phoebe.default_binary()
b.add_dataset('rv', component='primary', times=times, rvs = rvs1, sigmas=sigmas_rv)

b.run_compute()
_ = b.plot(legend=True, show=True)

b.add_solver('estimator.rv_geometry', solver='rvgeom')
b.run_solver('rvgeom', solution='rvgeom_solution')

print(b.get_value('fitted_twigs', solution='rvgeom_solution'))
print(b.get_value('fitted_values', solution='rvgeom_solution'))


I am working on the file "2.3/tutorials/alternate_backends.ipynb".
The first task is:
Available Backends
See the Compute Tutorial for details on adding compute options and using them to create synthetic models.
The following list in any version of PHOEBE can always be accessed via phoebe.list_available_computes.
Note also that all of these are listed on the backends page and their available functionality is compared in the compute backend comparison table.
Can you write Python code for it?


I am working on the file "2.3/tutorials/alternate_backends.ipynb".
The first task is:
Running Compute
Nothing changes when calling b.run_compute - simply provide the compute tag for those options.  Do note, however, that not all backends support all dataset types.
But, since the legacy backend doesn't support ck2004 atmospheres and interpolated limb-darkening, we do need to choose a limb-darkening law.  We can do this for all passband-component combinations by using set_value_all.
For more information on limb-darkening options, see the limb-darkening tutorial.
Can you write Python code for it?

b.set_value_all(qualifier='ld_mode', value='manual')

b.set_value_all(qualifier='ld_func', value='logarithmic')

b.run_compute('legacybackend', model='legacyresults')


I am working on the file "2.3/tutorials/alternate_backends.ipynb".
The first task is:
Running Multiple Backends Simultaneously
Running multiple backends simultaneously is just as simple as running the PHOEBE backend with multiple sets of compute options (see Compute).
We just need to make sure that each dataset is only enabled for one (or none) of the backends that we want to use, and then send a list of the compute tags to run_compute.  Here we'll use the PHOEBE backend to compute orbits and the legacy backend to compute light curves.
Can you write Python code for it?

b.set_value_all(qualifier='enabled', dataset='lc01', compute='phoebebackend', value=False)
#b.set_value_all(qualifier='enabled', dataset='orb01', compute='legacybackend', value=False)  # don't need this since legacy NEVER computes orbits
print(b.filter(qualifier='enabled'))

b.run_compute(['phoebebackend', 'legacybackend'], model='mixedresults')


I am working on the file "2.3/tutorials/alternate_backends.ipynb".
The first task is:
Using Alternate Backends
Adding Compute Options
Adding a set of compute options, via b.add_compute for an alternate backend is just as easy as for the PHOEBE backend.  Simply provide the function or name of the function in phoebe.parameters.compute that points to the parameters for that backend.
Here we'll add the default PHOEBE backend as well as the PHOEBE 1.0 (legacy) backend.  Note that in order to use an alternate backend, that backend must be installed on your machine.
Can you write Python code for it?

b.add_compute('phoebe', compute='phoebebackend')

print(b.get_compute('phoebebackend'))


I am working on the file "2.3/tutorials/alternate_backends.ipynb".
The first task is:
jktebop
For more details, see the the jktebop compute API docs.
Can you write Python code for it?


I am working on the file "2.3/tutorials/animations.ipynb".
The first task is:

Can you write Python code for it?

afig, mplanim = b['mesh01@model'].plot(times=times[:-1], fc='teffs', ec='None',
                       animate=True, save='animations_4.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.3/tutorials/animations.ipynb".
The first task is:
3D axes
Plotting to 3D axes are supported.  In addition to the options for static plots, animations also support passing a list for the range of elevation/azimuth (in degrees) throughout the animation.
Can you write Python code for it?

afig, mplanim = b['orb01@model'].plot(times=times[:-1], projection='3d', azim=[0, 360], elev=[-20,20],
                           animate=True, save='animations_6.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.3/tutorials/animations.ipynb".
The first task is:
Default Animations
By passing animate=True to b.show(), b.savefig(), or the final call to b.plot() along with save=filename or show=True will create an animation instead of a static plot.
Alternatively, you can call afig.animate() on the returned afig object returned by b.plot().
Can you write Python code for it?

afig, mplanim = b.plot(y={'orb': 'ws'},
                       animate=True, save='animations_1.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.3/tutorials/animations.ipynb".
The first task is:
Disabling Fixed Limits
By default, as can be seen above in the mesh animation, the limits of the axes are automatically set so that they are fixed throughout the animation.
Sometimes this may not be desired.  By setting xlim='frame' (and/or ylim='frame'), the axes limits are determined automatically per-frame instead of fixed throughout the animation.
For more information and other options see the autofig tutorial on limits
Can you write Python code for it?

afig, mplanim = b['lc01@model'].plot(times=times[:-1], uncover=True, xlim='frame',
                         animate=True, save='animations_5.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.3/tutorials/animations.ipynb".
The first task is:
Note that like the rest of the examples below, this is simply the animated version of the exact same call to plot
Providing Times
To override the default times explained above, pass a list or array to the times keyword.  For synthetic models, highlight mode will be enabled by default and the provided time does not need to be one that is computed - the value will be interpolated if it is not.  However, for plotting meshes, the exact time must be stored in the synthetic meshes or they will not be drawn.
This is especially usefully in cases where you may not want to repeat the first and last frame for a looping gif, or where you want a smoother animation by interpolation.  In this example we'll plot all but the last time so that the loop doesn't have a repeated frame.
In this example, times[:-1:2] means skip the last time and only use every-other time.
This option is not available from run_compute - a frame will be drawn for each computed time.
Can you write Python code for it?

afig, mplanim = b.plot(y={'orb': 'ws'},
                       times=times[:-1:2], animate=True, save='animations_2.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
A 'passband' parameter exists for each passband-dependent-dataset (i.e. not meshes or orbits, but light curves and radial velocities).  This parameter dictates which passband should be used for the computation of all intensities.
Can you write Python code for it?


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
Lastly, to manually download and install one of these online passbands, you can do so explicitly via phoebe.download_passband or by visiting tables.phoebe-project.org.  See also the tutorial on updating passbands.
Note that this isn't necessary unless you want to explicitly download passbands before needed by run_compute (perhaps if you're expecting to have unreliable network connection in the future and want to ensure you have all needed passbands).
Can you write Python code for it?


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
Note that if you change the value of 'atm' to anything other than 'ck2004', the corresponding 'ld_func' will need to be changed to something other than 'interp' (warnings and errors will be raised to remind you of this).
Can you write Python code for it?

b['ld_func@primary']

b['atm@primary'] = 'blackbody'

print(b.run_checks())

b['ld_mode@primary'] = 'manual'
b['ld_func@primary'] = 'logarithmic'

print(b.run_checks())


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
Relevant Parameters
An 'atm' parameter exists for each of the components in the system (for each set of compute options) and defines which atmosphere table should be used.
By default, these are set to 'ck2004' (Castelli-Kurucz) but can be set to 'blackbody' as well as 'extern_atmx' and 'extern_planckint' (which are included primarily for direct comparison with PHOEBE legacy).
Can you write Python code for it?

b['atm']

b['atm@primary']

b['atm@primary'].description

b['atm@primary'].choices


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
The available choices will include both locally installed passbands as well as passbands currently available from the online PHOEBE repository.  If you choose an online-passband, it will be downloaded and installed locally as soon as required by b.run_compute.
Can you write Python code for it?


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
These installed passbands can be in any of a number of directories, which can be accessed via phoebe.list_passband_directories().
The first entry is the global location - this is where passbands can be stored by a server-admin to be available to all PHOEBE-users on that machine.
The second entry is the local location - this is where individual users can store passbands and where PHOEBE will download and install passbands (by default).
Can you write Python code for it?


I am working on the file "2.3/tutorials/atm_passbands.ipynb".
The first task is:
To see your current locally-installed passbands, call phoebe.list_installed_passbands().
Can you write Python code for it?


I am working on the file "2.3/tutorials/beaming_boosting.ipynb".
The first task is:
Import all python modules that we'll need:
Can you write Python code for it?

import phoebe
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits


I am working on the file "2.3/tutorials/beaming_boosting.ipynb".
The first task is:
Now let's load a Johnson V passband and the transmission function $P(\lambda)$ contained within:
Can you write Python code for it?


I am working on the file "2.3/tutorials/beaming_boosting.ipynb".
The first task is:
Pull a set of Sun-like emergent intensities as a function of $\mu = \cos \theta$ from the Castelli and Kurucz database of model atmospheres (the necessary file can be downloaded from here):
Can you write Python code for it?


I am working on the file "2.3/tutorials/beaming_boosting.ipynb".
The first task is:
Tesselate the wavelength interval to the range covered by the passband:
Can you write Python code for it?

keep = (wl >= pb.ptf_table['wl'][0]) & (wl <= pb.ptf_table['wl'][-1])
Inorm = Inorm[keep]
wl = wl[keep]


I am working on the file "2.3/tutorials/building_a_system.ipynb".
The first task is:
And request the parent, children, child, or sibling of any item in the hierarchy via get_parent_of, get_children_of, or get_sibling_of.
Can you write Python code for it?

print(b.hierarchy.get_parent_of('primary'))

print(b.hierarchy.get_children_of('binary'))

print(b.hierarchy.get_child_of('binary', 0))  # here 0 means primary component, 1 means secondary

print(b.hierarchy.get_sibling_of('primary'))


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


I am working on the file "2.3/tutorials/building_a_system.ipynb".
The first task is:
For more details on dealing with contact binary systems, see the Contact Binary Hierarchy Tutorial and the Contact Binary Example Script.
Adding Components Manually
IMPORTANT: in the vast majority of cases, starting with one of the default systems is sufficient.  Below we will discuss the alternative method of building a system from scratch.
By default, an empty Bundle does not contain any information about our system.
So, let's first start by adding a few stars.  Here we'll call the generic add_component method.  This method works for any type of component in the system - stars, orbits, planets, disks, rings, spots, etc.  The first argument needs to be a callable or the name of a callable in phoebe.parameters.component which include the following options:

orbit
star
envelope

add_component also takes a keyword argument for the 'component' tag.  Here we'll give them component tags 'primary' and 'secondary' - but note that these are merely convenience labels and do not hold any special roles.  Some tags, however, are forbidden if they clash with other tags or reserved values - so if you get error stating the component tag is forbidden, try using a different string.
Can you write Python code for it?

b = phoebe.Bundle()

b.add_component(phoebe.component.star, component='primary')
b.add_component('star', component='secondary')


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

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

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


I am working on the file "2.3/tutorials/building_a_system.ipynb".
The first task is:
If at any point we want to flip the primary and secondary components or make
this binary a triple, its seriously as easy as changing this hierarchy and
everything else will adjust as needed (including cross-ParameterSet constraints,
and datasets)
The Hierarchy Parameter
Setting the hierarchy just sets the value of a single parameter (although it may take some time because it also does a lot of paperwork and manages constraints between components in the system).  You can access that parameter as usual:
Can you write Python code for it?


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


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


I am working on the file "2.3/tutorials/building_a_system.ipynb".
The first task is:
To build the same binary but as a contact system, you would call:
Can you write Python code for it?

b = phoebe.default_binary(contact_binary=True)

print(b.hierarchy)


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

b = phoebe.default_binary()

print(b.hierarchy)


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


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

b.add_dataset('orb',
              compute_times=phoebe.linspace(0,10,10),
              dataset='orb01')

b.add_dataset('lc',
              compute_times=phoebe.linspace(0,1,101),
              dataset='lc01')


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

print(b.computes)

print(b.filter(context='compute'))

b.set_value(qualifier='irrad_method', value='none')


I am working on the file "2.3/tutorials/compute.ipynb".
The first task is:
If the enabled parameter is missing for a set of compute options - it is likely that that particular backend does not support that dataset type.
Running Compute
run_compute takes arguments for the compute tag as well as the model tag for the resulting synthetic model(s).
You do not need to provide the compute tag if only 0 or 1 set of compute options exist in the Bundle.  If there are no compute options, the default PHOEBE 2 options will be added on your behalf and used.  If there is a single set of compute options, those will be assumed.  In our case, we have two compute options in the Bundle (with tags 'preview' and 'detailed') so we must provide an argument for compute.
If you do not provide a tag for the model, one will be created for you called 'latest'.  Note that the 'latest' model will be overwritten without throwing any errors, whereas other named models can only be overwritten if you pass overwrite=True (see the run_compute API docs for details).  In general, though, if you want to maintain the results from previous calls to run_compute, you must provide a NEW model tag.
Can you write Python code for it?


I am working on the file "2.3/tutorials/compute.ipynb".
The first task is:
Now we'll import our packages and initialize the default PHOEBE bundle.
Can you write Python code for it?

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

logger = phoebe.logger()

b = phoebe.default_binary()


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

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

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

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


I am working on the file "2.3/tutorials/compute.ipynb".
The first task is:
To remove a model, call remove_model.
Can you write Python code for it?


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


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

b.set_value(qualifier='enabled', dataset='lc01', compute='preview', value=False)
print(b.filter(qualifier='enabled', dataset='lc01'))


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

b.set_value_all('enabled@lc01', True)
print(b.filter(qualifier='enabled', dataset='lc01'))


I am working on the file "2.3/tutorials/compute_multiple.ipynb".
The first task is:
Running Compute with Multiple Sets of Options
So far we've seen how setting up different sets of compute options can be handy - 'preview' vs 'detailed', for example.  But there could also be situations where you want to use different sets of options per dataset.  Perhaps you have a high-precision follow-up light curve of an eclipse along with a lower-precision light curve over a longer time baseline.  So here you'd want to run 'detailed' on the high-precision light curve, but 'preview' on the lower-precision light curve.
You could of course call run_compute twice and create two separate models - but that isn't always convenient and will be a problem in the future when we want to fit data.
Instead we can send a list of compute options to run_compute.
A given dataset can only be enabled in up to 1 of the compute options we're sending to run_compute.  So let's take care of that first (if we don't, we'd get an error when trying to call run_compute):
Can you write Python code for it?

print(b.filter(qualifier='enabled', dataset='orb01'))

b.set_value_all(qualifier='enabled', dataset='orb01', compute='detailed', value=False)
b.set_value_all(qualifier='enabled', dataset='orb01', compute='preview', value=True)
print(b.filter(qualifier='enabled', dataset='orb01'))


I am working on the file "2.3/tutorials/compute_multiple.ipynb".
The first task is:
We probably have the same problem with 'lc01', but just didn't get far enough to raise the error.  So let's fix that as well
Can you write Python code for it?

print(b.filter(qualifier='enabled', dataset='lc01'))

b.set_value_all(qualifier='enabled', dataset='lc01', compute='detailed', value=True)
b.set_value_all(qualifier='enabled', dataset='lc01', compute='preview', value=False)
print(b.filter(qualifier='enabled', dataset='lc01'))


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
But we can also plot the residuals.  Here, calculate_residuals is called internally, interpolating in phase-space, and then plotted in time-space.  See the options for y in the plot API docs for more details.
Can you write Python code for it?

afig, mplfig = b.plot(y='residuals', show=True)


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
Determining & Plotting Residuals
One particularly useful case for interpolating is to compare a model (perhaps computed in phase-space) to a dataset with a large number of datapoints.  We can do this directly by calling compute_residuals, which will handle any necessary interpolation and compare the dependent variable between the dataset and models.
Note that if there are more than one dataset or model attached to the bundle, it may be necessary to pass dataset and/or model (or filter in advanced and call compute_residuals on the filtered ParameterSet.
To see this in action, we'll first create a "fake" observational dataset, add some noise, recompute the model using compute_phases, and then calculate the residuals.
Can you write Python code for it?

b.add_dataset('lc',
              times=phoebe.linspace(0,10,1000),
              dataset='lc01',
              overwrite=True)

b.run_compute(irrad_method='none')

fluxes = b.get_value('fluxes', context='model')
b.set_value('fluxes', context='dataset', value=fluxes)

b.flip_constraint('compute_phases', solve_for='compute_times')

b.set_value('compute_phases', phoebe.linspace(0,1,101))

b.set_value('teff', component='primary', value=5950)

b.run_compute(irrad_method='none')

print(len(b.get_value('fluxes', context='dataset')), len(b.get_value('fluxes', context='model')))

b.calculate_residuals()


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
Essentially, this constraint does the same thing as b.to_phase or b.to_time, using the appropriate t0 according to phases_t0 from the top-level orbit in the hierarchy.
Note that in the case of time-dependent systems, this mapping will also adhere to phases_dpdt (in the case of dpdt and/or phases_period (in the case of apsidal motion (dperdt).
Can you write Python code for it?


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
If we plot the dataset and model, we see that the model was only computed for one cycle, whereas the dataset extends further in time.
Can you write Python code for it?


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
In the case of times, this will automatically interpolate in phase-space if the provided time is outside the range of the referenced times array.  If you have a logger enabled with at least the 'warning' level, this will raise a warning and state the phases at which the interpolation will be completed.
Can you write Python code for it?


I am working on the file "2.3/tutorials/compute_times_phases.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

b = phoebe.default_binary()

b.add_dataset('lc', times=phoebe.linspace(0,10,101), dataset='lc01')


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
Note that under the hood, PHOEBE always works in time-space, meaning it is the constrained value of compute_times that is being passed under-the-hood.
Also note that if directly passing compute_phases to b.add_dataset, the constraint will be flipped on our behalf.  We would then need to flip the constraint in order to provide compute_times instead.
Finally, it is important to make the distinction that this is not adding support for observations in phases.  If we have an old light curve that is only available in phase, we still must convert these to times manually (or via b.to_time).  This restriction is intentional: we do not want the mapping between phase and time to change as the ephemeris is changed or fitted, rather we want to try to map from phase to time using the ephemeris that was originally used when the dataset was recorded (if possible, or the best possible guess).
Interpolating the Model
Whether or not we used compute_times/compute_phases or not, it is sometimes useful to be able to interpolate on the resulting model.  In the case where we provided compute_times/compute_phases to "down-sample" from a large dataset, this can be particularly useful.
We can call interp_value on any FloatArrayParameter.
Can you write Python code for it?

b.get_parameter('fluxes', context='model').get_value()

b.get_parameter('fluxes', context='model').interp_value(times=1.0)

b.get_parameter('fluxes', context='model').interp_value(times=phoebe.linspace(0,3,101))


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
Phase-Time Conversion
In addition to the ability to provide compute_times, we can alternatively provide compute_phases.  These two parameters are linked via a constraint (see the constraints tutorial), with compute_phases constrained by default.
Can you write Python code for it?

print(b.filter(qualifier=['times', 'compute_times', 'compute_phases', 'compute_phases_t0'], context='dataset'))


I am working on the file "2.3/tutorials/compute_times_phases.ipynb".
The first task is:
compute_times (when not empty) overrides the value of times when computing the model.  However, passing times as a keyword argument to run_compute will take precedence over either - and override the computed times across all enabled datasets.
Can you write Python code for it?

b.run_compute(times=[0,0.2])

print("dataset times: {}\ndataset compute_times: {}\nmodel times: {}".format(
    b.get_value('times', context='dataset'),
    b.get_value('compute_times', context='dataset'),
    b.get_value('times', context='model')
    ))

b.run_compute()

print("dataset times: {}\ndataset compute_times: {}\nmodel times: {}".format(
    b.get_value('times', context='dataset'),
    b.get_value('compute_times', context='dataset'),
    b.get_value('times', context='model')
    ))


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


I am working on the file "2.3/tutorials/constraints.ipynb".
The first task is:
If you change the hierarchy, built-in cross-object constraints (like mass
that depends on its parent orbit), will be adjusted to reflect the new hierarchy.  See Advanced: Constraints and Changing Hierarchices for more details.
Re-Parameterizing or "Flipping" Constraints
NOTE: when re-parameterizing, please be careful and make sure all results and parameters make sense.
As we've just seen, the mass is a constrained (ie. derived) parameter.  But
let's say that we would rather provide masses for some reason (perhaps
that was what was provided in a paper).  We can choose to provide mass
and instead have one of its related parameters constrained by calling b.flip_constraint.
Can you write Python code for it?

print(b.get_parameter(qualifier='mass', component='primary', context='component').constrained_by)

print("mass@primary: {}, mass@secondary: {}, period: {}".format(
        b.get_value(qualifier='mass', component='primary', context='component'),
        b.get_value(qualifier='mass', component='secondary', context='component'),
        b.get_value(qualifier='period', component='binary', context='component')))

b.flip_constraint('mass@primary', solve_for='period')

b.set_value(qualifier='mass', component='primary', context='component', value=1.0)

print("mass@primary: {}, mass@secondary: {}, period: {}".format(
        b.get_value(qualifier='mass', component='primary', context='component'),
        b.get_value(qualifier='mass', component='secondary', context='component'),
        b.get_value(qualifier='period', component='binary', context='component')))


I am working on the file "2.3/tutorials/constraints.ipynb".
The first task is:
The parameter is aware that it's being constrained and has references to all the relevant linking parameters.
Can you write Python code for it?


I am working on the file "2.3/tutorials/constraints.ipynb".
The first task is:
To see what all of these constraints do, see Advanced: Built-In Constraints or look at the constraint API docs.
For now let's look at a single constraint by accessing a ConstraintParameter.
Can you write Python code for it?


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


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


I am working on the file "2.3/tutorials/constraints_builtin.ipynb".
The first task is:
Built-in Constraints
There are a number of built-in constraints that can be applied to our system.  Those added by default are listed below as well as in the API docs for b.add_constraint:
asini
These constraint handles computing the projected semi-major axis (either for an orbit or a star) along the line of sight and can be automatically inverted to solve for either 'asini', 'sma', or 'incl'.
Can you write Python code for it?

b.filter(qualifier='asini', context='constraint')

b.get_parameter(qualifier='asini', component='binary', context='constraint')


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

b.filter(qualifier='asini', context='constraint')

b.get_parameter(qualifier='asini', component='primary', context='constraint')


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

b.filter(qualifier='sma', context='constraint')

b.get_parameter(qualifier='sma', component='primary', context='constraint')


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

b.get_parameter(qualifier='esinw', context='constraint')

b.get_parameter(qualifier='ecosw', context='constraint')


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

b.filter(qualifier='freq', context='constraint')

b.get_parameter(qualifier='freq', component='binary', context='constraint')

b.get_parameter(qualifier='freq', component='primary', context='constraint')


I am working on the file "2.3/tutorials/constraints_builtin.ipynb".
The first task is:
pitch/yaw (incl/long_an)
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.filter(qualifier='incl', context='constraint')

b.get_parameter(qualifier='incl', component='primary', context='constraint')

b.filter(qualifier='long_an', context='constraint')

b.get_parameter(qualifier='long_an', component='primary', context='constraint')


I am working on the file "2.3/tutorials/constraints_builtin.ipynb".
The first task is:
requiv_max
This constraint handles solving for the maxium equivalent radius (for a detached system).
For a semi-detached system, the radius itself is constrained to be exactly this value.
Can you write Python code for it?

b.filter(qualifier='requiv_max', context='constraint')

b.get_parameter(qualifier='requiv_max', component='primary', context='constraint')


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

b.filter(qualifier='period', context='constraint')

b.get_parameter(qualifier='period', component='primary', context='constraint')


I am working on the file "2.3/tutorials/constraints_custom.ipynb".
The first task is:
First we need to create all the parameters that we need that do not already exist, and attach them to the bundle with appropriate tags.  Ultimately the choice of tags is inconsequential, but here it makes some sense to apply our new teffratio to the parent orbit that contains both stars.
Almost always (since we're creating constraints), we'll need to define a new FloatParameter.  Note that the default_unit is quite important here, as the constraint expressions will propagate units.
Can you write Python code for it?

teffratio_def = phoebe.parameters.FloatParameter(qualifier='teffratio',
                                                 default_unit=u.dimensionless_unscaled,
                                                 value=1,
                                                 description='effective temperature ratio')


I am working on the file "2.3/tutorials/constraints_custom.ipynb".
The first task is:
In this case, the two positional arguments to b.add_constraint must be the left-hand side of the expression (which will become the constrained parameter) and the right-hand side of the expression (either another parameter or a ConstraintParameter).
Simple Case
The easiest way to create a constraint parameter is via math operations on existing parameters.  For example, let's say we wanted the secondary temperature to always be half the primary temperature:
Can you write Python code for it?

print(b.filter(qualifier='teff'))

lhs = b.get_parameter(qualifier='teff', component='secondary')
rhs = 0.5 * b.get_parameter(qualifier='teff', component='primary')

rhs

b.add_constraint(lhs, rhs)

print(b.filter(qualifier='teff'))


I am working on the file "2.3/tutorials/constraints_custom.ipynb".
The first task is:
Now, as with any other constraint, if we change the value of a parameter in the constraint, the constrained value will automatically adjust.
Can you write Python code for it?

b.set_value(qualifier='teff', component='primary', value=7000)

print(b.filter(qualifier='teff'))


I am working on the file "2.3/tutorials/constraints_custom.ipynb".
The first task is:
Our new parameter is available through filtering as is any other parameter.
Can you write Python code for it?


I am working on the file "2.3/tutorials/constraints_custom.ipynb".
The first task is:
We'll attach the new parameter by calling b.get_or_create.  The first argument here is the qualifier, the second is the parameter object itself, and additional keyword arguments are tags to be applied.  If a parameter already exists that matches the filter (including the qualifier) then that parameter will be returned (and the new parameter will be ignored), otherwise the new parameter will be attached to the bundle and returned.
The first returned argument is the matching parameter, and the second is a boolean which tells whether the new parameter was added or if an existing on was retrieved.
Can you write Python code for it?

teffratio_param, created = b.get_or_create('teffratio', teffratio_def, context='component', component='binary')


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

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

logger = phoebe.logger()

b = phoebe.default_binary()


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


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

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

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

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

b.set_value(qualifier='mass', component='secondary', context='component', value=1.0)

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


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

b['mass@primary']

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

b['mass@primary@star@component']

print(b.get_value('q'))

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


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Although the constraints have been removed, PHOEBE has lost the original value of the secondary radius (because of the failed contact constraints), so we'll have to reset that here as well.
Can you write Python code for it?


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
And because of this, the potential and requiv@secondary constraints cannot be updated from the constraints.
Can you write Python code for it?


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
As you can see, the overcontact system has an additional "component" with method "envelope" and component label "contact_envelope".
Next let's look at the parameters in the envelope and star components. You can see that most of parameters in the envelope class are constrained, while the equivalent radius of the primary is unconstrained. The value of primary equivalent radius constrains the potential and fillout factor of the envelope, as well as the equivalent radius of the secondary.
Can you write Python code for it?

print(b_cb.filter(component='contact_envelope', kind='envelope', context='component'))

print(b_cb.filter(component='primary', kind='star', context='component'))

b_cb['requiv@primary'] = 1.5

b_cb['pot@contact_envelope@component']

b_cb['fillout_factor@contact_envelope@component']

b_cb['requiv@secondary@component']


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Here we'll initialize a default binary, but ask for it to be created as a contact system.
Can you write Python code for it?


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Likewise, we can make a contact system detached again simply by removing the envelope from the hierarchy.  The parameters themselves will still exist (unless you remove them), so you can always just change the hierarchy again to change back to an overcontact system.
Can you write Python code for it?

hier = phoebe.hierarchy.binaryorbit(b_detached['binary'], b_detached['primary'], b_detached['secondary'])
print(hier)

b_detached.set_hierarchy(hier)

print(b_detached.hierarchy)


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Now, of course, if we didn't originally know we wanted a contact binary and built the default detached system, we could still turn it into an contact binary just by changing the hierarchy.
Can you write Python code for it?

b_detached.add_component('envelope', component='contact_envelope')

hier = phoebe.hierarchy.binaryorbit(b_detached['binary'], b_detached['primary'], b_detached['secondary'], b_detached['contact_envelope'])
print(hier)

b_detached.filter(context='constraint',constraint_func='pitch',component='primary')

b_detached.set_hierarchy(hier)

print(b_detached.hierarchy)


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

afig, mplfig = b_cb['orb01@model'].plot(x='ws',show=True)

afig, mplfig = b_detached['orb01@model'].plot(x='ws',show=True)


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

afig, mplfig = b_cb['mesh01@model'].plot(x='ws', show=True)

afig, mplfig = b_detached['mesh01@model'].plot(x='ws', show=True)


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Running Compute
Can you write Python code for it?


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
Synthetics
To ensure compatibility with computing synthetics in detached and semi-detached systems in Phoebe, the synthetic meshes for our overcontact system are attached to each component separetely, instead of the contact envelope.
Can you write Python code for it?


I am working on the file "2.3/tutorials/contact_binary_hierarchy.ipynb".
The first task is:
We'll compare this to the default detached binary
Can you write Python code for it?


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

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

which can always be listed via phoebe.list_available_datasets
Can you write Python code for it?


I am working on the file "2.3/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],
              component='primary',
              dataset='rv01',
              overwrite=True)

print(b.get_parameter(qualifier='rvs', dataset='rv01', context='dataset'))


I am working on the file "2.3/tutorials/datasets.ipynb".
The first task is:
Here we used phoebe.linspace.  This is essentially just a shortcut to np.linspace, but using nparray to allow these generated arrays to be serialized and stored easier within the Bundle.  Other nparray constructor functions available at the top-level of PHOEBE include:

phoebe.arange
phoebe.invspace
phoebe.linspace
phoebe.logspace
phoebe.geomspace

Any nparray object, list, or numpy array is acceptable as input to FloatArrayParameters.
b.add_dataset can either take a function or the name of a function in phoebe.parameters.dataset as its first argument.  The following line would do the same thing (and we'll pass overwrite=True to avoid the error of overwriting dataset='orb01').
Can you write Python code for it?

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


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

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

print(b.filter(qualifier='rvs', dataset='rv02', context='dataset'))


I am working on the file "2.3/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.get_parameter(qualifier='fluxes', dataset='lc01', context='dataset'))


I am working on the file "2.3/tutorials/datasets.ipynb".
The first task is:
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.
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.
Unlike other datasets, the mesh and orb dataset cannot accept actual observations, so there is no times parameter, only the compute_times and compute_phases parameters.  For more details on these, see the Advanced: Compute Times & Phases tutorial.
Can you write Python code for it?

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


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


I am working on the file "2.3/tutorials/datasets_advanced.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_mode='manual',
              ld_func={'primary': 'logarithmic', 'secondary': 'quadratic'},
              dataset='lc01',
             overwrite=True)

print(b.filter(qualifier='ld_func', dataset='lc01'))


I am working on the file "2.3/tutorials/datasets_advanced.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.3/tutorials/datasets_advanced.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.
Can you write Python code for it?


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

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

print(b.get_parameter(qualifier='times', dataset='lc01'))

print(b.filter(qualifier='ld_mode', dataset='lc01'))


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


I am working on the file "2.3/tutorials/datasets_advanced.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.3/tutorials/datasets_advanced.ipynb".
The first task is:
The usage of compute_phases (as well as compute_times) will be discussed in further detail in the compute tutorial and the advanced: compute times & phases tutorial.
Note also that although you can pass compute_phases directly to add_dataset, if you do not, it will be constrained by compute_times by default.  In this case, you would need to flip the constraint before setting compute_phases.  See the constraints tutorial and the flip_constraint API docs for more details on flipping constraints.
Can you write Python code for it?

b.add_dataset('lc',
              times=[0],
              dataset='lc01',
              overwrite=True)

print(b['compute_phases@lc01'])

b.flip_constraint('compute_phases', dataset='lc01', solve_for='compute_times')

b.set_value('compute_phases', dataset='lc01', value=np.linspace(0,1,101))


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


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

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

logger = phoebe.logger()

b = phoebe.default_binary()


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

b.add_dataset('mesh', times=[0], dataset='mesh01', columns=['intensities@lc01', 'abs_intensities@lc01'])

b.set_value('distance', 1.0)

b.run_compute(model='dist1', overwrite=True)

b.set_value('distance', 2.0)

b.run_compute(model='dist2', overwrite=True)

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

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


I am working on the file "2.3/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.3/tutorials/distance.ipynb".
The first task is:
To make things easier to compare, let's disable limb darkening
Can you write Python code for it?

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

b.set_value('distance', 1.0)

b.run_compute(model='dist1', overwrite=True)

b.set_value('distance', 2.0)

b.run_compute(model='dist2', overwrite=True)


I am working on the file "2.3/tutorials/distribution_propagation.ipynb".
The first task is:
Accessing Uncertainties from Distributions
Similarly, we can access the resulting uncertainties (taken from the 1-sigma percentiles by default), by calling uncertainties_from_distribution_collection.
Note that the input gaussian distributions are automatically exposed with symmetric uncertainties, whereas the propagated asini distribution will rely on asymmetric uncertainties from the sampled values.
Can you write Python code for it?

b.uncertainties_from_distribution_collection(distribution='mydist',
                                             parameters=['sma@binary', 'q@binary', 'asini@binary'],
                                             tex=True)


I am working on the file "2.3/tutorials/distribution_propagation.ipynb".
The first task is:
And to expose a machine-readable list with lower, centeral, and upper bounds represented, we just exclude the tex=True.
Can you write Python code for it?

b.uncertainties_from_distribution_collection(distribution='mydist',
                                             parameters=['sma@binary', 'q@binary', 'asini@binary'],
                                             sigma=3)


I am working on the file "2.3/tutorials/distribution_propagation.ipynb".
The first task is:
Here we'll add some distributions directly to parameters... but the concepts below apply just as well to distributions extracted from posteriors.
Can you write Python code for it?

b.add_distribution({'sma@binary': phoebe.gaussian_around(1),
                    'incl@binary': phoebe.uniform(85, 90),
                    'q@binary': phoebe.gaussian_around(0.05)},
                   distribution='mydist')


I am working on the file "2.3/tutorials/distribution_propagation.ipynb".
The first task is:
We can pass a list of parameters (as twigs) to the parameters keyword argument to only plot a subset of the available parameters.
Can you write Python code for it?

_ = b.plot_distribution_collection(distribution='mydist',
                                   parameters=['sma@binary', 'q@binary'],
                                   show=True)


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
And whenever plotting through b.plot_distribution_collection or b.plot, the latex representation of the respective parameters will be included.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
By calling dist.slice, we get a distl object which retains the covariance matrix, but represents a single dimension, which can then be passed to PHOEBE.
Can you write Python code for it?

_ = dist.slice('T1').plot()

dist.slice('T1')

b.add_distribution({'teff@primary': dist.slice('T1'),
                    'teff@secondary': dist.slice('T2'),
                     'q': dist.slice('q')},
                    distribution='mydist')


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
Multivariate distributions
Multivariate distributions allow for storing the covariance between the distributions of multiple parameters.  Although the creation functions are exposed at the top-level, these are most seen in PHOEBE after running an MCMC chain.  For more information on manipulating these multivariate posteriors, see Advanced: Convert Posterior Distributions from EMCEE.
If, however, we had an MCMC chain or wanted to import a published covariance matrix, we could use mvhistogram_from_data or mvgaussian, respectively.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
Note that since we didn't provide label or unit, those will be missing when plotting the distribution object.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
Note that, when passing a distribution object to b.add_distribution, the values of unit, label, label_latex, and wrap_at will be handled by PHOEBE itself - based on the parameter to which the distribution is attached.
To learn more about manipulating distribution objects before calling b.add_distribution, see the distl docs.
Let's create a distl gaussian distribution and then attach it to a parameter in PHOEBE.
Can you write Python code for it?

dist = phoebe.gaussian(6000, 100)

print(dist)


I am working on the file "2.3/tutorials/distribution_types.ipynb".
The first task is:
Once we create our single distl multivariate object, we then need to tell PHOEBE which "slices" of that multivariate distribution to attach to which parameters.
Here we will set labels, just to make it easier to track the dimensions of the distribution object.
Can you write Python code for it?

import numpy as np
b = phoebe.default_binary()

dist = phoebe.mvgaussian([6500, 6200, 0.9],
                         np.array([[ 2,  1, -1],
                                   [ 1,  2,  1],
                                   [-1,  1,  2]]),
                        allow_singular=True,
                        labels=['T1', 'T2', 'q'])

_ = dist.plot(show=True)


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
Accessing & Plotting Distributions
The parameters we've created and attached are DistributionParameters and live in context='distribution', with all other tags matching the parameter they're referencing.  For example, let's filter and look at the distributions we've added.
Can you write Python code for it?

print(b.filter(context='distribution'))

print(b.get_parameter(context='distribution', qualifier='incl'))

print(b.get_parameter(context='distribution', qualifier='incl').tags)


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
Adding Distributions
Distributions can be attached to most any FloatParameter in the Bundle.  To see a list of these available parameters, we can call b.get_adjustable_parameters.  Note the exclude_constrained option which defaults to True: we can set distributions on constrained parameters (for priors, for example), but those will not be able to be sampled from in the forward model or while fitting.  We'll come back to this in the next tutorial when looking at priors.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
As you probably can expect by now, we also have methods to:

get_distribution
rename_distribution
remove_distribution
Can you write Python code for it?


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
Now let's add another distribution, with the same distribution tag, to the inclination of the binary.
Can you write Python code for it?

b.add_distribution(qualifier='incl', component='binary',
                   value=phoebe.uniform(80,90),
                   distribution='mydist')

print(b.get_distribution(distribution='mydist'))


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
Propagating Distributions through Forward Model
Lastly, we can have PHOEBE automatically draw from a "distribution collection" multiple times and expose the distribution of the model itself.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
Sampling Distributions
We can also sample from these distributions - either manually by calling sample on the distl or in bulk by respecting any covariances in the "distributon collection" via:

b.sample_distribution_collection
Can you write Python code for it?


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
The "value" of the parameter, is the distl distributon object itself.
Can you write Python code for it?


I am working on the file "2.3/tutorials/distributions.ipynb".
The first task is:
add_distribution is quite flexible and accepts several different syntaxes to add multiple distributions in one line.  Here we'll just attach a distribution to a single parameter at a time.  Just like when calling add_dataset or add_compute, add_distribution optionally takes a distribution tag -- and in the cases of distributions, we can attach distributions to multiple parameters with the same distribution tag.
The values of the DistributionParameters are distl distribution objects -- the most common of which are conveniently available at the top-level of PHOEBE:

phoebe.gaussian
phoebe.gaussian_around
phoebe.uniform
phoebe.uniform_around

For an overview of the different available types as they apply in PHOEBE, see Advanced: Distribution Types.
Now let's attach a gaussian distribution on the temperature of the primary star.
Can you write Python code for it?

b.add_distribution(qualifier='teff', component='primary',
                   value=phoebe.gaussian(6000,100),
                   distribution='mydist')


I am working on the file "2.3/tutorials/dpdt.ipynb".
The first task is:
As noted in the description, the phases_dpdt parameter will also affect phase-masking.
Can you write Python code for it?


I am working on the file "2.3/tutorials/dpdt.ipynb".
The first task is:
Considerations in compute_phases and mask_phases
By default, the mapping between compute_times and compute_phases will account for dpdt.  In this case, we set compute_phases to cover successive orbits... so therefore the resulting compute_times will adjust as necessary.
Can you write Python code for it?


I am working on the file "2.3/tutorials/dpdt.ipynb".
The first task is:
Contributions to RVs
Due to the changing size of the orbit due to mass conservation (increasing the RV amplitude for a positive dpdt), as well as the changing orbital period (decreasing the RV amplitude for a positive dpdt), the RVs will also have a change in amplitude as a function of time (in addition to the phase-effects seen for the light curve above).
Can you write Python code for it?

_ = b.plot(kind='rv', x='times',
           linestyle={'primary': 'solid', 'secondary': 'dotted'},
           color={'rv01': 'blue', 'rv02': 'orange', 'rv03': 'green'},
           show=True)


I am working on the file "2.3/tutorials/dpdt.ipynb".
The first task is:
For the case of this tutorial, we would rather the compute_times be even cycles based on period alone, so that we can color by cycles of period and easily visualize the effect of dpdt.  We could have set compute_times directly instead, but then we would need to keep the period fixed and know it in advance.  Alternatively, we can set phases_dpdt = 'none' to tell this mapping to ignore dpdt.
Can you write Python code for it?

print(b.filter(qualifier='phases_dpdt'))

print(b.get_parameter(qualifier='phases_dpdt', dataset='lc01').description)


I am working on the file "2.3/tutorials/dpdt.ipynb".
The first task is:
In order to easily differentiate between the components in a light curve and in the orbits, we'll set the  secondary temperature and the mass ratio.
Can you write Python code for it?

b.set_value('q', 0.8)
b.set_value('teff', component='secondary', value=5000)