I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
Influence on Radial Velocities
Radial velocities are perhaps the most logical observable in the case of systemic velocities.  Introducing a non-zero value for vgamma simply offsets the observed values.
Light-time will have a similar affect on RVs as it does on LCs - it simply changes the observed period.
Can you write Python code for it?

afig, mplfig = b['rv'].plot(c=colors, linestyle='solid',
                            axorder={'rv1': 0, 'rv2': 1},
                            subplot_grid=(1,2), tight_layout=True, show=True)


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
Lastly, let's leave this value of vgamma, but enable light-time effects.
Can you write Python code for it?


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
Now let's look at the effect that enabling ltte has on these same plots.
Can you write Python code for it?

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

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


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
The option to enable or disable LTTE are in the compute options, we can either set ltte or we can just temporarily pass a value when we call run_compute.
Can you write Python code for it?


I am working on the file "2.1/tutorials/vgamma.ipynb".
The first task is:
We'll leave it set at 0.0 for now, and then change vgamma to see how that affects the observables.
The other relevant parameter here is t0 - that is the time at which all quantities are provided, the time at which nbody integration would start (if applicable), and the time at which the center-of-mass of the system is defined to be at (0,0,0).  Unless you have a reason to do otherwise, it makes sense to have this value near the start of your time data... so if we don't have any other changing quantities defined in our system and are using BJDs, we would want to set this to be non-zero.  In this case, our times all start at 0, so we'll leave t0 at 0 as well.
Can you write Python code for it?


I am working on the file "2.2 CNN HandsOn - MNIST Dataset.ipynb".
The first task is:
Basic data analysis on the dataset
Can you write Python code for it?

# What is the type of X_train?

# What is the type of y_train?

# Find number of observations in training data

# Find number of observations in test data

# Display first 2 records of X_train

# Display the first 10 records of y_train

# Find the number of observations for each digit in the y_train dataset

# Find the number of observations for each digit in the y_test dataset

# What is the dimension of X_train?. What does that mean?


I am working on the file "2.2 CNN HandsOn - MNIST Dataset.ipynb".
The first task is:
Display Images
Let's now display some of the images and see how they look
We will be using matplotlib library for displaying the image
Can you write Python code for it?

from matplotlib import pyplot
import matplotlib as mpl
%matplotlib inline

# Displaying the first training data

fig = pyplot.figure()
ax = fig.add_subplot(1,1,1)
imgplot = ax.imshow(X_train[20], cmap=mpl.cm.Greys)
imgplot.set_interpolation('nearest')
ax.xaxis.set_ticks_position('top')
ax.yaxis.set_ticks_position('left')
pyplot.show()

# Let's now display the 11th record


I am working on the file "2.2.1 CNN HandsOn - MNIST & FC Nets.ipynb".
The first task is:
Plotting Network Performance Trend
The return value of the fit function is a keras.callbacks.History object which contains the entire history of training/validation loss and accuracy, for each epoch. We can therefore plot the behaviour of loss and accuracy during the training phase.
Can you write Python code for it?

import matplotlib.pyplot as plt
%matplotlib inline

plt.figure()
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.plot(network_history.history['loss'])
plt.plot(network_history.history['val_loss'])
plt.legend(['Training', 'Validation'])

plt.figure()
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.plot(network_history.history['acc'])
plt.plot(network_history.history['val_acc'])
plt.legend(['Training', 'Validation'], loc='lower right')

import numpy as np
print(np.argmax(model.predict(X_test[5:10]),1))
print(y_test[5:10])

# Can you write a snippet that finds a misclassified sample in X_train and
# displays the image, correct classification and your prediction


I am working on the file "2.2.1 CNN HandsOn - MNIST & FC Nets.ipynb".
The first task is:
Training
Having defined and compiled the model, it can be trained using the fit function. We also specify a validation dataset to monitor validation loss and accuracy.
Can you write Python code for it?

# You can train the network yourself or simply load a saved model :P, for now!!
#network_history = model.fit(X_train, Y_train, batch_size=1000,
#                            nb_epoch=100, verbose=1, validation_data=(X_test, Y_test))
#model.save('example_MNIST_FC.h5')

model=load_model('example_MNIST_FC.h5')
model.summary()


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Adding more Convolution Layers
Can you write Python code for it?

model = Sequential()
model.add(Conv2D(nb_filters, nb_conv, nb_conv, input_shape=shape_ord))
model.add(Activation('relu'))
model.add(Conv2D(nb_filters, nb_conv, nb_conv))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(128))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(nb_classes))
model.add(Activation('softmax'))

model.compile(loss='categorical_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])

'''
hist = model.fit(X_train, y_train, batch_size=batch_size/2,
                 nb_epoch=nb_epoch, verbose=1,
                 validation_data=(X_test, y_test))
model.save('example_MNIST_CNN_more_conv.h5')
'''
model=load_model('example_MNIST_CNN_more_conv.h5')
model.summary()

#Evaluating the model on the test data
score, accuracy = model.evaluate(X_test, y_test, verbose=0)
print('Test score:', score)
print('Test accuracy:', accuracy)


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Adding more Dense Layers
Can you write Python code for it?

model = Sequential()
model.add(Conv2D(nb_filters, nb_conv, nb_conv, input_shape=shape_ord))
model.add(Activation('relu'))

model.add(Flatten())
model.add(Dense(128))
model.add(Activation('relu'))

model.add(Dense(nb_classes))
model.add(Activation('softmax'))

model.compile(loss='categorical_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])

# Ah, another path to choose, Train or load!!
'''
hist = model.fit(X_train, y_train, batch_size=batch_size,
                 nb_epoch=nb_epoch, verbose=1,
                 validation_data=(X_test, y_test))
model.save('example_MNIST_CNN_more_dense.h5')
'''
model=load_model('example_MNIST_CNN_more_dense.h5')
model.summary()

#Evaluating the model on the test data
score, accuracy = model.evaluate(X_test, y_test, verbose=0)
print('Test score:', score)
print('Test accuracy:', accuracy)


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Data Preparation
Very Important:
When dealing with images & convolutions, it is paramount to handle image_data_format properly
Can you write Python code for it?

img_rows, img_cols = 28, 28
'''
if K.image_data_format() == 'channels_first':
    shape_ord = (1, img_rows, img_cols)
else:  # channel_last
    shape_ord = (img_rows, img_cols, 1)
'''
shape_ord = (1, img_rows, img_cols)


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Exercise
The above code has been written as a function.
Change some of the hyperparameters and see what happens.
Can you write Python code for it?

# Function for constructing the convolution neural network
# Feel free to add parameters, if you want

def build_model():
    """"""
    model = Sequential()
    model.add(Conv2D(nb_filters, nb_conv, nb_conv,
                     padding='valid',
                     input_shape=shape_ord))
    model.add(Activation('relu'))
    model.add(Conv2D(nb_filters, nb_conv, nb_conv))
    model.add(Activation('relu'))
    model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
    model.add(Dropout(0.25))

    model.add(Flatten())
    model.add(Dense(128))
    model.add(Activation('relu'))
    model.add(Dropout(0.5))
    model.add(Dense(nb_classes))
    model.add(Activation('softmax'))

    model.compile(loss='categorical_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])

    model.fit(X_train, y_train, batch_size=batch_size,
              epochs=nb_epoch,verbose=1,
              validation_data=(X_test, y_test))

    #Evaluating the model on the test data
    score, accuracy = model.evaluate(X_test, y_test, verbose=0)
    print('Test score:', score)
    print('Test accuracy:', accuracy)


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Let's plot our model Predictions!
Can you write Python code for it?

import matplotlib.pyplot as plt

%matplotlib inline

slice = 15
predicted = model.predict(X_test[:slice]).argmax(-1)

plt.figure(figsize=(16,8))
for i in range(slice):
    plt.subplot(1, slice, i+1)
    plt.imshow(X_test[i,0], interpolation='nearest')
    plt.text(0, 0, predicted[i], color='black',
             bbox=dict(facecolor='white', alpha=1))
    plt.axis('off')


I am working on the file "2.2.2 CNN HandsOn - MNIST & CN Nets.ipynb".
The first task is:
Loading Data
Can you write Python code for it?

#Load the training and testing data
(X_train, y_train), (X_test, y_test) = mnist.load_data()


I am working on the file "2.2.scattering.ipynb".
The first task is:
First, execute the cell below as-is.  A round quantum dot is constructed and one x-directed lead attached to it.  Note how attach_lead added new sites to the scattering region to create a clean interface for the lead.  The Hamiltonian of these sites is taken from the lead that is being attached, such that the physics is unchanged.
Can you write Python code for it?

_dot = make_dot((3, 7), 13)
_dot.attach_lead(make_lead_x(10))
kwant.plot(_dot);
#### Attach the y-directed lead here.


I am working on the file "2.2.scattering.ipynb".
The first task is:
Observe how providing a symmetry parameter when creating the kwant.Builder object allows to create a translationally invariant system.  A builder with a symmetry will always preserve it.  That's why it is sufficient to add only a single transverse row of sites to create the full infinite system.
Can you write Python code for it?

def make_lead_x(W=10, t=1):
    syst = kwant.Builder(kwant.TranslationalSymmetry([-1, 0]))
    syst[(lat(0, y) for y in range(W))] = 4 * t
    syst[lat.neighbors()] = -t
    return syst


I am working on the file "2.2.scattering.ipynb".
The first task is:
We see cosine-shaped bands that for low energies match the parabolic bands of the continuum model.  As expected (see previous notebook) the tight-binding approximation breaks down at high energies.
Your turn!
The next two cells are almost an identical copy of the previous two (The two changes are that the function got a different name and the lead is no longer plotted.) Your task is now to add one hopping that connects the first with the last site in y-direction, making the lead thus periodic in y-direction.
So far, we only used lat.neighbors() to add hoppings to all lattice sites. We can also modify individual hoppings using
sys[lat(x1, y1), lat(x2, y2)] = something

to set the hopping from $(x_2, y_2)$ to $(x_1, y_1)$ to something.
Observe how the bands become degenerate.  Where does this degeneracy come from?
To see the degeneracy clearly, you may want to reduce the value of the “wrapped” hopping by a factor of, say, 0.8.
Can you write Python code for it?

def make_periodic_lead(W=10, t=1):
    syst = make_lead_x(W, t)
    #### Add periodic boundary conditions here.
    return syst

_lead = make_periodic_lead()
kwant.plotter.bands(_lead.finalized());


I am working on the file "2.2.scattering.ipynb".
The first task is:
Your turn!
Copy the previous cell below this one and modify _wire in some way, e.g. by removing one site.  Compare the transmission/reflection plot.
Beyond the wire geometry
We are, of course, not restricted to a simplistic wire geometry.  Let's build a system that is a bit more complicated: a round quantum dot.
Can you write Python code for it?

def make_dot(center, radius, t=1):
    def is_inside(pos):
        x, y = pos - center
        return x**2 + y**2 < rr

    rr = radius**2
    syst = kwant.Builder()
    syst[lat.shape(is_inside, center)] = 4 * t
    syst[lat.neighbors()] = -t

    return syst


I am working on the file "2.2/examples/animation_binary_complete.ipynb".
The first task is:
Adding Datasets
Can you write Python code for it?

times = np.linspace(0,1,21)

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

b.add_dataset('rv', times=times, dataset='rv01')

b.add_dataset('mesh', times=times, columns=['visibilities', 'intensities@lc01', 'rvs@rv01'], dataset='mesh01')


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

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/examples/animation_binary_complete.ipynb".
The first task is:
Plotting
See the Animations Tutorial for more examples and details.
Here we'll create a figure with multiple subplots.  The top row will be the light curve and RV curve.  The bottom three subplots will be various representations of the mesh (intensities, rvs, and visibilities).
We'll do this by making separate calls to plot, passing the matplotlib subplot location for each axes we want to create.  We can then call b.show(animate=True) or b.save('anim.gif', animate=True).
Can you write Python code for it?

b['lc01@model'].plot(axpos=221)
b['rv01@model'].plot(c={'primary': 'blue', 'secondary': 'red'}, linestyle='solid', axpos=222)
b['mesh@model'].plot(fc='intensities@lc01', ec='None', axpos=425)
b['mesh@model'].plot(fc='rvs@rv01', ec='None', axpos=427)
b['mesh@model'].plot(fc='visibilities', ec='None', y='ws', axpos=224)

fig = plt.figure(figsize=(11,4))
afig, mplanim = b.savefig('animation_binary_complete.gif', fig=fig, tight_layouot=True, draw_sidebars=False, animate=True, save_kwargs={'writer': 'imagemagick'})


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


I am working on the file "2.2/examples/binary_misaligned_spots.ipynb".
The first task is:
Adding Spots
Let's add a spot to the primary component in our binary, which we have already misaligned by 30 degrees in pitch.
The 'colat' parameter defines the colatitude on the star measured from its North (spin) Pole.  The 'long' parameter measures the longitude of the spot - with longitude = 0 being defined as pointing towards the other star at t0.  See the spots tutorial for more details.
We'll place this spot at the South Pole, which should be pointing towards the observer because we pitched the north pole away from the observer.
Can you write Python code for it?

b.add_feature('spot', component='primary', feature='spot01', relteff=0.9, radius=15, colat=180, long=0)


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()

b.set_value(qualifier='pitch', component='primary', value=30)


I am working on the file "2.2/examples/binary_misaligned_spots.ipynb".
The first task is:
Comparing Light Curves
Note that the pitch means the polar spot is always facing towards the observer slightly, and so is always visible (unless eclipsed).
Can you write Python code for it?

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


I am working on the file "2.2/examples/binary_misaligned_spots.ipynb".
The first task is:
Location of Spot
Can you write Python code for it?

afig, mplfig = b.plot(kind='mesh', fc='teffs', fcmap='plasma', ec='face', show=True)


I am working on the file "2.2/examples/binary_misaligned_spots.ipynb".
The first task is:
Model without Spots
Can you write Python code for it?

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

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


I am working on the file "2.2/examples/binary_misaligned_spots.ipynb".
The first task is:
We'll also add a mesh dataset so that we can see the positioning of the spot with respect to the misaligned component.
Can you write Python code for it?

b.add_dataset('mesh', compute_times=[0.75], columns=['teffs'])

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


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/examples/binary_spots.ipynb".
The first task is:
Comparing Light Curves
Can you write Python code for it?

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


I am working on the file "2.2/examples/binary_spots.ipynb".
The first task is:
Model without Spots
Can you write Python code for it?


I am working on the file "2.2/examples/contact_spots.ipynb".
The first task is:
Adding Spots
Let's add a spot to the primary component in our binary.  Note that if you attempt to attach to the 'contact_envelope' component, an error will be raised.  Spots can only be attached to star components.
The 'colat' parameter defines the latitude on the star measured from its North (spin) Pole.  The 'long' parameter measures the longitude of the spot - with longitude = 0 being defined as pointing towards the other star at t0.  See to spots tutorial for more details.
Can you write Python code for it?

b.add_feature('spot', component='primary', feature='spot01', relteff=0.9, radius=20, colat=90, long=-45)

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


I am working on the file "2.2/examples/contact_spots.ipynb".
The first task is:
But if we increase the radius large enough, we'll get a ring.
Can you write Python code for it?

b.set_value('radius', value=40)

b.run_compute(irrad_method='none')

afig, mplfig = b.plot(fc='teffs', ec='face', fcmap='plasma', show=True)


I am working on the file "2.2/examples/contact_spots.ipynb".
The first task is:
Now if we set the long closer to the neck, we'll see it get cropped by the boundary between the two components.  If we need a spot that crosses between the two "halves" of the contact, we'd have to add separate spots to each component, with each getting cropped at the boundary.
Can you write Python code for it?

b.set_value('long', value=-30)

b.run_compute(irrad_method='none')

afig, mplfig = b.plot(fc='teffs', ec='face', fcmap='plasma', show=True)


I am working on the file "2.2/examples/detached_rotstar.ipynb".
The first task is:
Adding Datasets
Now we'll create an empty mesh dataset at quarter-phase so we can compare the difference between using roche and rotstar for deformation potentials:
Can you write Python code for it?


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


I am working on the file "2.2/examples/detached_rotstar.ipynb".
The first task is:
Now we'll compute synthetics at the times provided using the default options
Can you write Python code for it?

b.run_compute(irrad_method='none', distortion_method='roche', model='rochemodel')

b.run_compute(irrad_method='none', distortion_method='rotstar', model='rotstarmodel')


I am working on the file "2.2/examples/diher_misaligned.ipynb".
The first task is:
Plotting
Can you write Python code for it?

afig, mplfig = b.plot(kind='lc', show=True)

afig, mplfig = b.plot(kind='rv', show=True)


I am working on the file "2.2/examples/diher_misaligned.ipynb".
The first task is:
System Parameters
We'll adopt and set parameters from the following sources:
   * Albrecht et al. (2009), Nature: https://arxiv.org/pdf/0909.2861
   * https://en.wikipedia.org/wiki/DI_Herculis
   * Claret et al (2010) https://arxiv.org/pdf/1002.2949.pdf
Can you write Python code for it?

Nt = 2000

b.set_value('t0_supconj@orbit', 2442233.3481)
b.set_value('vgamma@system', 9.1)    # [km/s] (Albrecht et al. 2009)
b.set_value('ntriangles@primary', Nt)
b.set_value('ntriangles@secondary', Nt)

mass1 = 5.1                           # [M_sun] (Albrecht et al. 2009)
mass2 = 4.4                           # [M_sun] (Albrecht et al. 2009)

P = 10.550164                         # [d] (Albrecht et al. 2009)
mu_sun = 1.32712440018e20             # = G M_sun [m3 s^-2], Wiki Standard_gravitational_parameter
R_sun = 695700000                     # [m] Wiki Sun

sma = (mu_sun*(mass1 + mass2)*(P*86400/(2*np.pi))**2)**(1./3)/R_sun   # Kepler equation

incl = 89.3                           # deg (Albrecht et al. 2009)
vp_sini = 109                         # [km/s] (Albrecht et al. 2009)
vs_sini = 117                         # [km/s] (Albrecht et al. 2009)

Rp = 2.68                             # [R_sun] (Albrecht et al. 2009)
Rs = 2.48                             # [R_sun] (Albrecht et al. 2009)

sini = np.sin(np.pi*incl/180)

vp = vp_sini*86400/sini               # [km/s]
vs = vs_sini*86400/sini               # [km/s]

Pp = 2*np.pi*Rp*R_sun/1000/vp
Ps = 2*np.pi*Rs*R_sun/1000/vs

Fp = P/Pp
Fs = P/Ps

b.set_value('q', mass2/mass1)
b.set_value('incl@binary', incl)      # (Albrecht et al. 2009)
b.set_value('sma@binary', sma)        # calculated
b.set_value('ecc@binary', 0.489)      # (Albrecht et al. 2009)

b.set_value('per0@binary', 330.2)     # (Albrecht et al. 2009)
b.set_value('period@binary', P)       # calculated

b.set_value('syncpar@primary', Fp)    # calculated
b.set_value('syncpar@secondary', Fs)  # calculated

b.set_value('requiv@primary', Rp)      # !!! requiv (Albrecht et al. 2009)
b.set_value('requiv@secondary', Rs)    # !!! requiv (Albrecht et al. 2009)

b.set_value('teff@primary', 17300)    # Wiki DI_Herculis
b.set_value('teff@secondary', 15400)  # Wiki DI_Herculis

b.set_value('gravb_bol@primary', 1.)
b.set_value('gravb_bol@secondary', 1.)

# beta = 72 deg (Albrecht et al. 2009)
dOmega_p =...


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

import phoebe
import numpy as np

b = phoebe.default_binary()


I am working on the file "2.2/examples/eccentric_ellipsoidal.ipynb".
The first task is:
Now let's animate the same figure in time.  We'll use the same arguments as the static plot above, with the following exceptions:

times: pass our array of times that we want the animation to loop over.
pad_aspect: pad_aspect doesn't work with animations, so we'll disable to avoid the warning messages.
animate: self-explanatory.
save: we could use show=True, but that doesn't always play nice with jupyter notebooks
save_kwargs: may need to change these for your setup, to create a gif, passing {'writer': 'imagemagick'} is often useful.
Can you write Python code for it?

afig, mplfig = b.plot(times=anim_times,
                      z={'orb': 'ws'},
                      c={'primary': 'blue', 'secondary': 'red'},
                      fc={'primary': 'blue', 'secondary': 'red'},
                      ec='face',
                      uncover={'orb': True},
                      trail={'orb': 0.1},
                      highlight={'orb': False},
                      tight_layout=True, pad_aspect=False,
                      animate=True,
                      save='eccentric_ellipsoidal.gif',
                      save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/eccentric_ellipsoidal.ipynb".
The first task is:
Now let's make a nice figure.
Let's go through these options:
* time: make the plot at this single time
* z: by default, orbits plot in 2d, but since we're overplotting with a mesh, we want the z-ordering to be correct, so we'll have them plot with w-coordinates in the z-direction.
* c: (will be ignored by the mesh): set the color to blue for the primary and red for the secondary (will only affect the orbits as the light curve is not tagged with any component).
* fc: (will be ignored by everything but the mesh): set the facecolor to be blue for the primary and red for the secondary.
* ec: disable drawing the edges of the triangles in a separate color.  We could also set this to 'none', but then we'd be able to "see-through" the triangle edges.
* uncover: for the orbit, uncover based on the current time.
* trail: for the orbit, let's show a "trail" behind the current position.
* highlight: disable highlighting for the orbit, since the mesh will be in the same position.
* tight_layout: use matplotlib's tight layout to ensure we have enough padding between axes to see the labels.
Can you write Python code for it?

afig, mplfig = b.plot(time=0.0,
                      z={'orb': 'ws'},
                      c={'primary': 'blue', 'secondary': 'red'},
                      fc={'primary': 'blue', 'secondary': 'red'},
                      ec='face',
                      uncover={'orb': True},
                      trail={'orb': 0.1},
                      highlight={'orb': False},
                      tight_layout=True,
                      show=True)


I am working on the file "2.2/examples/eccentric_ellipsoidal.ipynb".
The first task is:
Now we need a highly eccentric system that nearly overflows at periastron and is slightly eclipsing.
Can you write Python code for it?

b.set_value('q', value=0.7)
b.set_value('period', component='binary', value=10)
b.set_value('sma', component='binary', value=25)
b.set_value('incl', component='binary', value=0)
b.set_value('ecc', component='binary', value=0.9)

print(b.filter(qualifier='requiv*', context='component'))

b.set_value('requiv', component='primary', value=1.1)
b.set_value('requiv', component='secondary', value=0.9)


I am working on the file "2.2/examples/eccentric_ellipsoidal.ipynb".
The first task is:
Plotting
Can you write Python code for it?

afig, mplfig = b.plot(kind='lc', x='phases', t0='t0_perpass', show=True)


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


I am working on the file "2.2/examples/extinction_BK_binary.ipynb".
The first task is:
And flip all extinction constraints so we can provide E(B-V) values.
Can you write Python code for it?


I am working on the file "2.2/examples/extinction_BK_binary.ipynb".
The first task is:
Lastly, we'll convert the model fluxes into magnitudes and format the figures.
Can you write Python code for it?

Bextmags=-2.5*np.log10(b['value@fluxes@B@ext@model'])
Bnoextmags=-2.5*np.log10(b['value@fluxes@B@noext@model'])
Bextmags_norm=Bextmags-Bextmags.min()+1
Bnoextmags_norm=Bnoextmags-Bnoextmags.min()+1
Bresid=Bextmags_norm-Bnoextmags_norm

Rextmags=-2.5*np.log10(b['value@fluxes@R@ext@model'])
Rnoextmags=-2.5*np.log10(b['value@fluxes@R@noext@model'])
Rextmags_norm=Rextmags-Rextmags.min()+1
Rnoextmags_norm=Rnoextmags-Rnoextmags.min()+1
Rresid=Rextmags_norm-Rnoextmags_norm

fig=plt.figure(figsize=(12,6))
gs=gridspec.GridSpec(2,2,height_ratios=[4,1],width_ratios=[1,1])

ax=plt.subplot(gs[0,0])
ax.plot(b['value@times@B@noext@model']/1000,Bnoextmags_norm,color='k',linestyle="--")
ax.plot(b['value@times@B@ext@model']/1000,Bextmags_norm,color='k',linestyle="-")
ax.set_ylabel('Magnitude')
ax.set_xticklabels([])
ax.set_xlim([-0.02,0.02])
ax.set_ylim([3.5,0.8])
ax.set_title('(a) Johnson B')

ax2=plt.subplot(gs[0,1])
ax2.plot(b['value@times@R@noext@model']/1000,Rnoextmags_norm,color='k',linestyle="--")
ax2.plot(b['value@times@R@ext@model']/1000,Rextmags_norm,color='k',linestyle="-")
ax2.set_ylabel('Magnitude')
ax2.set_xticklabels([])
ax2.set_xlim([-0.02,0.02])
ax2.set_ylim([3.5,0.8])
ax2.set_title('(b) Cousins Rc')

ax_1=plt.subplot(gs[1,0])
ax_1.plot(b['value@times@B@noext@model']/1000,Bresid,color='k',linestyle='-')
ax_1.set_ylabel(r'$\Delta m$')
ax_1.set_xlabel('Phase')
ax_1.set_xlim([-0.02,0.02])
ax_1.set_ylim([0.05,-0.3])
ax_1.axhline(y=0., linestyle='dashed',color='k',linewidth=0.5)

ax2_1=plt.subplot(gs[1,1])
ax2_1.plot(b['value@times@R@noext@model']/1000,Rresid,color='k',linestyle='-')
ax2_1.set_ylabel(r'$\Delta m$')
ax2_1.set_xlabel('Phase')
ax2_1.set_xlim([-0.02,0.02])
ax2_1.set_ylim([0.05,-0.3])
ax2_1.axhline(y=0.,...


I am working on the file "2.2/examples/extinction_BK_binary.ipynb".
The first task is:
and then another model with extinction
Can you write Python code for it?

b.set_value_all('ebv', 1.0)
b.run_compute(distortion_method='rotstar', irrad_method='none', model='ext')


I am working on the file "2.2/examples/extinction_eclipse_depth_v_teff.ipynb".
The first task is:
And flip all extinction constraints so we can provide E(B-V) values.
Can you write Python code for it?


I am working on the file "2.2/examples/extinction_eclipse_depth_v_teff.ipynb".
The first task is:
And then create three light curve datasets at the same times, but in different passbands
Can you write Python code for it?

times = phoebe.linspace(0, 10, 301)
b.add_dataset('lc', times=times, dataset='B', passband="Johnson:B")
b.add_dataset('lc', times=times, dataset='R', passband="Cousins:R")


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

import matplotlib
matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'
from matplotlib import gridspec

%matplotlib inline

from astropy.table import Table

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

logger = phoebe.logger('error')

b = phoebe.default_binary()


I am working on the file "2.2/examples/extinction_eclipse_depth_v_teff.ipynb".
The first task is:
First we'll define the system parameters
Can you write Python code for it?

b['period@orbit']=10*u.d
b['teff@secondary']=5780.*u.K
b['requiv@secondary']=1.0*u.solRad
b.flip_constraint('mass@primary', solve_for='sma@binary')
b.flip_constraint('mass@secondary', solve_for='q')


I am working on the file "2.2/examples/extinction_eclipse_depth_v_teff.ipynb".
The first task is:
Now we'll set some atmosphere and limb-darkening options
Can you write Python code for it?

b.set_value_all('gravb_bol', 0.0)
b.set_value_all('ld_mode', 'manual')
b.set_value_all('ld_func', 'linear')
b.set_value_all('ld_coeffs', [0.0])


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
Adopt system parameters from Rebassa-Mansergas+ 2019.
Can you write Python code for it?

b.set_value('period', component='binary', value=0.0897780065*u.d)
b.set_value('teff', component='primary', value=13247*u.K)
b.set_value('teff', component='secondary', value=3650*u.K)
b.set_value('requiv', component='primary', value=0.0160*u.solRad)
b.set_value('requiv', component='secondary', value=0.1669*u.solRad)
b.flip_constraint('mass@primary', solve_for='sma@binary')
b.set_value('mass', component='primary', value=0.4477*u.solMass)
b.flip_constraint('mass@secondary', solve_for='q')
b.set_value('mass', component='secondary', value=0.1501*u.solMass)


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
And set options for the atmospheres and limb-darkening.
Can you write Python code for it?

b.set_value_all('atm', component='primary', value='blackbody')
b.set_value_all('ld_mode', component='primary', value='manual')
b.set_value_all('ld_func', component='primary', value='quadratic')
b.set_value('ld_coeffs', component='primary', dataset='u', value=[0.2665,0.2544])
b.set_value('ld_coeffs', component='primary', dataset='g', value=[0.1421,0.3693])
b.set_value('ld_coeffs', component='primary', dataset='r', value=[0.1225,0.3086])
b.set_value('ld_coeffs', component='primary', dataset='i', value=[0.1063,0.2584])
b.set_value_all('ld_mode_bol@primary','manual')
b.set_value_all('ld_func_bol@primary','quadratic')
b.set_value('ld_coeffs_bol', component='primary', value=[0.1421,0.3693])

b.set_value_all('atm', component='secondary', value='phoenix')
b.set_value('abun', component='secondary', value=-1.55)


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
And then a second model with extinction.
Can you write Python code for it?


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
Finally we'll convert the output fluxes to magnitudes and format the figure.
Can you write Python code for it?

uextmags=-2.5*np.log10(b['value@fluxes@u@ext@model'])
unoextmags=-2.5*np.log10(b['value@fluxes@u@noext@model'])
uextmags_norm=uextmags-uextmags.min()+1
unoextmags_norm=unoextmags-unoextmags.min()+1
uresid=uextmags_norm-unoextmags_norm

gextmags=-2.5*np.log10(b['value@fluxes@g@ext@model'])
gnoextmags=-2.5*np.log10(b['value@fluxes@g@noext@model'])
gextmags_norm=gextmags-gextmags.min()+1
gnoextmags_norm=gnoextmags-gnoextmags.min()+1
gresid=gextmags_norm-gnoextmags_norm

rextmags=-2.5*np.log10(b['value@fluxes@r@ext@model'])
rnoextmags=-2.5*np.log10(b['value@fluxes@r@noext@model'])
rextmags_norm=rextmags-rextmags.min()+1
rnoextmags_norm=rnoextmags-rnoextmags.min()+1
rresid=rextmags_norm-rnoextmags_norm

iextmags=-2.5*np.log10(b['value@fluxes@i@ext@model'])
inoextmags=-2.5*np.log10(b['value@fluxes@i@noext@model'])
iextmags_norm=iextmags-iextmags.min()+1
inoextmags_norm=inoextmags-inoextmags.min()+1
iresid=iextmags_norm-inoextmags_norm

fig=plt.figure(figsize=(12,12))
gs=gridspec.GridSpec(4,2,height_ratios=[4,1,4,1],width_ratios=[1,1])

ax=plt.subplot(gs[0,0])
ax.plot(b['value@times@u@noext@model']/7.,unoextmags_norm,color='k',linestyle="--")
ax.plot(b['value@times@u@ext@model']/7.,uextmags_norm,color='k',linestyle="-")
ax.set_ylabel('Magnitude')
ax.set_xticklabels([])
ax.set_ylim([6.2,0.95])
ax.set_title('(a) LSST u')

ax2=plt.subplot(gs[0,1])
ax2.plot(b['value@times@g@noext@model']/b['period@orbit'].quantity,gnoextmags_norm,color='k',linestyle="--")
ax2.plot(b['value@times@g@ext@model']/b['period@orbit'].quantity,gextmags_norm,color='k',linestyle="-")
ax2.set_ylabel('Magnitude')
ax2.set_xticklabels([])
ax2.set_ylim([3.2,0.95])
ax2.set_title('(b) LSST g')

ax_1=plt.subplot(gs[1,0])
ax_1.plot(b['value@times@u@noext@model']/b['period@orbit'].quantity,uresid,color='k',linestyle='-')
ax_1.set_ylabel(r'$\Delta m$')
ax_1.set_xlabel('Phase')
ax_1.set_ylim([0.05,-0.3])
ax_1.axhline(y=0.,...


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
For comparison, we'll first compute a model with zero extinction.
Can you write Python code for it?


I am working on the file "2.2/examples/extinction_wd_subdwarf.ipynb".
The first task is:
We'll set the inclination to 90 degrees and set some compute options.
Can you write Python code for it?

b.set_value('incl', component='binary', value=90.0*u.deg)
b.set_value_all('ntriangles', value=10000)
b.set_value_all('intens_weighting', value='photon')

b.set_value_all('Rv', value=2.5)


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
And also plot the residuals of both the primary and secondary RVs (notice the scale on the y-axis)
Can you write Python code for it?

artist, = plt.plot(b.get_value('rvs@rvdyn@primary@phoebe2wdmodel') - b.get_value('rvs@rvdyn@primary@phoebe1model'), color='b', ls=':')
artist, = plt.plot(b.get_value('rvs@rvdyn@secondary@phoebe2wdmodel') - b.get_value('rvs@rvdyn@secondary@phoebe1model'), color='b', ls='-.')
artist = plt.axhline(0.0, linestyle='dashed', color='k')
ylim = plt.ylim(-1.5e-12, 1.5e-12)


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

%matplotlib inline

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

phoebe.devel_on()  # needed to use WD-style meshing, which isn't fully supported yet

logger = phoebe.logger()

b = phoebe.default_binary()
b['q'] = 0.7
b['requiv@secondary'] = 0.7


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
Dynamical RVs
Since the dynamical RVs don't depend on the mesh, there should be no difference between the 'phoebe2marching' and 'phoebe2wd' synthetic models.  Here we'll just choose one to plot.
Can you write Python code for it?

afig, mplfig = b.filter(dataset='rvdyn', model=['phoebe2wdmodel', 'phoebe1model']).plot(c=colors, legend=True, show=True)


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
Finally, let's compute all of our models
Can you write Python code for it?

b.run_compute(compute='phoebe2marching', model='phoebe2marchingmodel')

b.run_compute(compute='phoebe2wd', model='phoebe2wdmodel')

b.run_compute(compute='phoebe1', model='phoebe1model')


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
Let's add compute options for phoebe using both the new (marching) method for creating meshes as well as the WD method which imitates the format of the mesh used within legacy.
Can you write Python code for it?

b.add_compute(compute='phoebe2marching', irrad_method='none', mesh_method='marching')

b.add_compute(compute='phoebe2wd', irrad_method='none', mesh_method='wd', eclipse_method='graham')


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
Let's also disable other special effect such as heating, gravity, and light-time effects.
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_all('rv_grav', False)

b.set_value_all('ltte', False)


I am working on the file "2.2/examples/legacy.ipynb".
The first task is:
Plotting
Light Curve
Can you write Python code for it?

colors = {'phoebe2marchingmodel': 'g', 'phoebe2wdmodel': 'b', 'phoebe1model': 'r'}
afig, mplfig = b['lc01'].plot(c=colors, legend=True, show=True)


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary(contact_binary=True)
b['q'] = 0.7


I am working on the file "2.2/examples/legacy_contact_binary.ipynb".
The first task is:
Let's also disable other special effect such as heating, gravity, and light-time effects.
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, 0.0])

b.set_value_all('rv_grav', False)
b.set_value_all('ltte', False)


I am working on the file "2.2/examples/legacy_contact_binary.ipynb".
The first task is:
Let's use the external atmospheres available for both phoebe1 and phoebe2
Can you write Python code for it?


I am working on the file "2.2/examples/legacy_contact_binary.ipynb".
The first task is:
Now let's plot the residuals between these two models
Can you write Python code for it?

artist, = plt.plot(b.get_value('fluxes@lc01@phoebe2model') - b.get_value('fluxes@lc01@phoebe1model'), 'g-')
artist = plt.axhline(0.0, linestyle='dashed', color='k')


I am working on the file "2.2/examples/legacy_contact_binary.ipynb".
The first task is:
Set value of gridsize for the trapezoidal (WD) mesh.
Can you write Python code for it?


I am working on the file "2.2/examples/legacy_spots.ipynb".
The first task is:
Adding Spots and Compute Options
Can you write Python code for it?

b.add_spot(component='primary', relteff=0.8, radius=20, colat=45, colon=90, feature='spot01')

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

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

b.add_compute('legacy', irrad_method='none', compute='phoebe1')


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/examples/legacy_spots.ipynb".
The first task is:
Let's use the external atmospheres available for both phoebe1 and phoebe2
Can you write Python code for it?

b.set_value_all('atm', 'extern_planckint')

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

b.run_compute('phoebe2', model='phoebe2model')

b.run_compute('phoebe1', model='phoebe1model')


I am working on the file "2.2/examples/legacy_spots.ipynb".
The first task is:
Plotting
Can you write Python code for it?

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


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
Adding Datasets
Next let's add a mesh dataset so that we can plot our Wilson-Devinney style meshes
Can you write Python code for it?

b.add_dataset('mesh', compute_times=[0, 0.5], dataset='mesh01', columns=['visibilities'])


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
And now looking down from above.  Here you can see the gaps between the surface elements (and you can also see some of the subdivision that's taking place along the limb).
Can you write Python code for it?

afig, mplfig = b['primary@mesh01@model'].plot(time=0.0, x='us', y='ws',
                                              ec='blue', fc='gray',
                                              xlim=(-0.1,0.1), ylim=(-2.75,-2.55),
                                              show=True)


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
And see which elements are visible at the current time.  This defaults to use the 'RdYlGn' colormap which will make visible elements green, partially hidden elements yellow, and hidden elements red.  Note that the observer is in the positive w-direction.
Can you write Python code for it?

afig, mplfig = b['secondary@mesh01@model'].plot(time=0.0, x='us', y='ws',
                                                ec='face', fc='visibilities',
                                                show=True)


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

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

phoebe.devel_on() # CURRENTLY REQUIRED FOR WD-STYLE MESHING (WHICH IS EXPERIMENTAL)

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
Changing Meshing Options
Next we need to add compute options and change the mesh_style for all stars from 'marching' to 'wd'
Can you write Python code for it?

b.set_value_all('mesh_method', 'wd')
b.set_value_all('eclipse_method', 'graham')


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
Now let's zoom in so we can see the layout of the triangles.  Note that Wilson-Devinney uses trapezoids, but since PHOEBE uses triangles, we take each of the trapezoids and split it into two triangles.
Can you write Python code for it?

afig, mplfig = b['primary@mesh01@model'].plot(time=0.0,  x='us', y='vs',
                                              ec='blue', fc='gray',
                                              xlim=(-0.2,0.2), ylim=(-0.2,0.2),
                                              show=True)


I am working on the file "2.2/examples/mesh_wd.ipynb".
The first task is:
Plotting
Can you write Python code for it?

afig, mplfig = b['mesh01@model'].plot(time=0.5, x='us', y='vs',
                                      show=True)


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


I am working on the file "2.2/examples/minimal_contact_binary.ipynb".
The first task is:
Adding Datasets
Can you write Python code for it?

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

b.add_dataset('orb', compute_times=np.linspace(0,1,201), dataset='orb01')

b.add_dataset('lc', times=np.linspace(0,1,21), dataset='lc01')

b.add_dataset('rv', times=np.linspace(0,1,21), dataset='rv01')


I am working on the file "2.2/examples/minimal_contact_binary.ipynb".
The first task is:
Here we'll initialize a default binary, but ask for it to be created as a contact system.
For more details see the contact binary hierarchy tutorial.
Can you write Python code for it?


I am working on the file "2.2/examples/minimal_contact_binary.ipynb".
The first task is:
Light Curves
Can you write Python code for it?

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


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

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


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

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


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

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/examples/minimal_synthetic.ipynb".
The first task is:
Plotting
Now we can simply plot the resulting synthetic light curve.
Can you write Python code for it?

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

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


I am working on the file "2.2/examples/minimal_synthetic.ipynb".
The first task is:
Running Compute
Now we'll compute synthetics at the times provided using the default options
Can you write Python code for it?


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
Adding Datasets
We'll add radial velocity, line profile, and mesh datasets.  We'll compute the rvs through the whole orbit, but the mesh and line profiles right around the eclipse - just at the times that we want to plot for an animation.
Can you write Python code for it?

anim_times = phoebe.arange(0.44, 0.56, 0.002)


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
And for the line-profile, we'll expose the line-profile for both of our stars separately, instead of for the entire system.
Can you write Python code for it?

b.add_dataset('lp',
              compute_times=anim_times,
              component=['primary', 'secondary'],
              wavelengths=phoebe.linspace(549.5,550.5,101),
              profile_rest=550)


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

import phoebe
import numpy as np

b = phoebe.default_binary()


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
For the mesh, we'll save some time by only exposing plane-of-sky coordinates and the 'rvs' column.
Can you write Python code for it?

b.add_dataset('mesh',
              compute_times=anim_times,
              coordinates='uvw',
              columns=['rvs@numericalrvs'],
              dataset='mesh01')


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
Here we can see that star in front (green) is eclipsing more of the blue-shifted part of the back star (magenta), distorting the line profile, causing the apparent center of the line profile to be shifted to the right/red, and therefore the radial velocities to be articially increased as compared to the dynamical RVs.
Now let's animate the same figure in time.  We'll use the same arguments as the static plot above, with the following exceptions:

times: pass our array of times that we want the animation to loop over.
pad_aspect: pad_aspect doesn't work with animations, so we'll disable to avoid the warning messages.
animate: self-explanatory.
save: we could use show=True, but that doesn't always play nice with jupyter notebooks
save_kwargs: may need to change these for your setup, to create a gif, passing {'writer': 'imagemagick'} is often useful.
Can you write Python code for it?

afig, mplanim = b.plot(times=anim_times,
                       fc='rvs@numericalrvs', ec='face',
                       c=colors,
                       ls={'numericalrvs': 'solid', 'dynamicalrvs': 'dotted'},
                       highlight={'numericalrvs': True, 'dynamicalrvs': False},
                       tight_layout=True, pad_aspect=False,
                       axpos={'mesh': 211, 'rv': 223, 'lp': 224},
                       xlim={'rv': (0.4, 0.6)}, ylim={'rv': (-80, 80)},
                       animate=True,
                       save='rossiter_mclaughlin.gif',
                       save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
Now we'll try to exaggerate the effect by spinning up the secondary component.
Can you write Python code for it?

b.set_value('q', value=0.7)
b.set_value('incl', component='binary', value=87)
b.set_value('requiv', component='primary', value=0.8)
b.set_value('teff', component='secondary', value=6500)
b.set_value('syncpar', component='secondary', value=1.5)


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


I am working on the file "2.2/examples/rossiter_mclaughlin.ipynb".
The first task is:
We'll add two identical datasets, one where we compute only dynamical RVs (won't include Rossiter-McLaughlin) and another where we compute flux-weighted RVs (will include Rossiter-McLaughlin).
Can you write Python code for it?

b.add_dataset('rv',
              times=phoebe.linspace(0,1,201),
              dataset='dynamicalrvs')

b.set_value_all('rv_method', dataset='dynamicalrvs', value='dynamical')

b.add_dataset('rv',
              times=phoebe.linspace(0,1,201),
              dataset='numericalrvs')

b.set_value_all('rv_method', dataset='numericalrvs', value='flux-weighted')


I am working on the file "2.2/examples/single_spots.ipynb".
The first task is:
And if we change the inclination to 0, we'll be looking at the north pole of the star.  This clearly illustrates the right-handed rotation of the star.  At time=t0=5 the spot will now be pointing in the negative y-direction.
Can you write Python code for it?

b.set_value('incl', 0)

b.run_compute(distortion_method='rotstar', irrad_method='none')

afig, mplfig = b.plot(x='us', y='vs', fc='teffs',
                     animate=True, save='single_spots_3.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/single_spots.ipynb".
The first task is:
If we set t0 to 5 instead of zero, then the spot will cross the line-of-sight at t=5 (since the spot's longitude is 0).
Can you write Python code for it?

b.set_value('t0', 5)

b.run_compute(distortion_method='rotstar', irrad_method='none')

afig, mplfig = b.plot(x='us', y='vs', fc='teffs',
                     animate=True, save='single_spots_2.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/single_spots.ipynb".
The first task is:
Spot Parameters
A spot is defined by the colatitude and longitude of its center, its angular radius, and the ratio of temperature of the spot to the local intrinsic value.
Can you write Python code for it?


I am working on the file "2.2/examples/single_spots.ipynb".
The first task is:
The 'colat' parameter defines the colatitude on the star measured from its North (spin) Pole.  The 'long' parameter measures the longitude of the spot - with longitude = 0 being defined as pointing towards the observer at t0 for a single star.  See the spots tutorial for more details.
Can you write Python code for it?

times = np.linspace(0, 10, 11)
b.set_value('period', 10)
b.add_dataset('mesh', times=times, columns=['teffs'])

b.run_compute(distortion_method='rotstar', irrad_method='none')

afig, mplfig = b.plot(x='us', y='vs', fc='teffs',
                      animate=True, save='single_spots_1.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
Adding Datasets
Can you write Python code for it?

b.add_dataset('lc', compute_times=phoebe.linspace(-0.1, 0.1, 201))


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
Let's go through these options (see also the plot API docs):
* time: make the plot at this single time
* fc: (will be ignored by everything but the mesh): set the facecolor to the teffs column.
* fcmap: use 'plasma' colormap instead of the default to avoid whites.
* fclim: set the limits on facecolor so that the much cooler transiting object doesn't drive the entire range.
* ec: disable drawing the edges of the triangles in a separate color.  We could also set this to 'none', but then we'd be able to "see-through" the triangle edges.
* tight_layout: use matplotlib's tight layout to ensure we have enough padding between axes to see the labels.
Can you write Python code for it?

afig, mplfig = b.plot(time=0.0,
                      fc='teffs', fcmap='plasma', fclim=(5000, 6000),
                      ec='face',
                      tight_layout=True,
                      show=True)


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
Let's set reasonable (although not necessarily physical) values for the secondary component.
Can you write Python code for it?

b.flip_constraint('mass@secondary', solve_for='q')
b.set_value(qualifier='mass', component='secondary', value=0.2)
b.set_value(qualifier='requiv', component='secondary', value=0.2)
b.set_value(qualifier='teff', component='secondary', value=300)


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
Now let's animate the same figure in time.  We'll use the same arguments as the static plot above, with the following exceptions:

times: pass our array of times that we want the animation to loop over.
consider_for_limits: for the mesh panel, keep the primary star centered and allow the transiting object to move in and out of the frame.
pad_aspect: pad_aspect doesn't work with animations, so we'll disable to avoid the warning messages.
animate: self-explanatory.
save: we could use show=True, but that doesn't always play nice with jupyter notebooks
save_kwargs: may need to change these for your setup, to create a gif, passing {'writer': 'imagemagick'} is often useful.
Can you write Python code for it?

afig, mplfig = b.plot(times=anim_times,
                      fc='teffs', fcmap='plasma', fclim=(5000, 6000),
                      ec='face',
                      consider_for_limits={'primary': True, 'secondary': False},
                      tight_layout=True, pad_aspect=False,
                      animate=True,
                      save='spot_transit.gif',
                      save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
Plotting
Can you write Python code for it?

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


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


I am working on the file "2.2/examples/spot_transit.ipynb".
The first task is:
We'll add a spot to the primary component.
Can you write Python code for it?

b.add_spot(component='primary',
           relteff=0.90,
           long=0,
           colat=90,
           radius=20,
           feature='spot01')


I am working on the file "2.2/examples/sun.ipynb".
The first task is:
And so that we can compare with measured/expected values, we'll observe the sun from the earth - with an inclination of 23.5 degrees and at a distance of 1 AU.
Can you write Python code for it?

b.set_value('incl', 23.5*u.deg)
b.set_value('distance', 1.0*u.AU)


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_star(starA='sun')


I am working on the file "2.2/examples/sun.ipynb".
The first task is:
Checking on the set values, we can see the values were converted correctly to PHOEBE's internal units.
Can you write Python code for it?

print(b.get_quantity('teff'))
print(b.get_quantity('requiv'))
print(b.get_quantity('mass'))
print(b.get_quantity('period'))
print(b.get_quantity('incl'))
print(b.get_quantity('distance'))


I am working on the file "2.2/examples/sun.ipynb".
The first task is:
Comparing to Expected Values
Can you write Python code for it?

afig, mplfig = b['mesh'].plot(fc='teffs', x='xs', y='ys', show=True)

afig, mplfig = b['mesh'].plot(fc='teffs', x='us', y='vs', show=True)

print("teff: {} ({})".format(b.get_value('teffs').mean(),
                             b.get_value('teff', context='component')))


I am working on the file "2.2/examples/sun.ipynb".
The first task is:
Running Compute
Let's add a light curve so that we can compute the flux at a single time and compare it to the expected value.  We'll set the passband luminosity to be the nominal value for the sun. We'll also add a mesh dataset so that we can plot the temperature distributions and test the size of the sun verse known values.
Can you write Python code for it?

b.add_dataset('lc', times=[0.], pblum=1*u.solLum)
b.add_dataset('mesh', compute_times=[0.], columns=['teffs', 'loggs', 'rs'])

b.run_compute(irrad_method='none', distortion_method='rotstar')


I am working on the file "2.2/examples/sun.ipynb".
The first task is:
Setting Parameters
Can you write Python code for it?


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary(starA='sun', starB='earth', orbit='earthorbit')


I am working on the file "2.2/examples/sun_earth.ipynb".
The first task is:
Setting Parameters
Can you write Python code for it?

b.set_value('teff@sun', 1.0*u.solTeff)
b.set_value('requiv@sun', 1.0*u.solRad)

b.flip_constraint('period@sun', solve_for='syncpar')
b.set_value('period@sun', 24.47*u.d)
#b.set_value('incl', 23.5*u.deg)

b.set_value('teff@earth', 252*u.K)
b.set_value('requiv@earth', 1.0*c.R_earth)

b.flip_constraint('period@earth', solve_for='syncpar')
b.set_value('period@earth', 1*u.d)

b.set_value('sma@earthorbit', 1*u.AU)
b.set_value('period@earthorbit', 1*u.yr)
b.set_value('q@earthorbit', c.M_earth/c.M_sun)

#b.set_value('ecc@earthorbit')

print("Msun: {}".format(b.get_quantity('mass@sun@component', unit=u.solMass)))
print("Mearth: {}".format(b.get_quantity('mass@earth@component', unit=u.solMass)))


I am working on the file "2.2/examples/sun_earth.ipynb".
The first task is:
We'll have the sun follow a roche potential and the earth follow a rotating sphere (rotstar).
NOTE: this doesn't work yet because the rpole<->potential is still being defined by roche, giving the earth a polar radius way too small.
Can you write Python code for it?


I am working on the file "2.2/tutorials/ETV.ipynb".
The first task is:
Alternatively, especially when overplotting with a light curve, its sometimes handy to just plot ticks at each of the eclipse times.  This can easily be done by passing a single value for 'y'.
For other examples with light curves as well see:
* Apsidal Motion
* LTTE ETVs in a Hierarchical Triple
Can you write Python code for it?

axs, artists = b['etv@model'].plot(x='time_ecls', y=2)


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

%matplotlib inline

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

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/tutorials/ETV.ipynb".
The first task is:
Compute Options
Let's look at the compute options (for the default PHOEBE 2 backend) that relate to the ETV dataset.
Other compute options are covered elsewhere:
* parameters related to dynamics are explained in the section on the orb dataset
Can you write Python code for it?

ps_compute = phoebe.compute.phoebe()
print ps_compute


I am working on the file "2.2/tutorials/ETV.ipynb".
The first task is:
Dataset Parameters
Let's create the ParameterSet which would be added to the Bundle when calling add_dataset. Later we'll call add_dataset, which will create and attach this ParameterSet for us.
Can you write Python code for it?

ps, constraints = phoebe.dataset.etv(component='mycomponent')
print ps


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

b.add_dataset('etv', Ns=np.linspace(0,10,11), dataset='etv01')

b.add_compute()

b.run_compute()

b['etv@model'].twigs

print b['time_ephems@primary@etv@model']

print b['time_ecls@primary@etv@model']

print b['etvs@primary@etv@model']


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


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


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


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


I am working on the file "2.2/tutorials/ETV.ipynb".
The first task is:
time_ephems
NOTE: this parameter will be constrained when added through add_dataset
Can you write Python code for it?


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
Dataset Parameters
Let's add a lightcurve dataset to the Bundle (see also the lc 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.2/tutorials/LC.ipynb".
The first task is:
For more details on atmospheres, see the Atmospheres & Passbands tutorial
Synthetics
Can you write Python code for it?

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

b.run_compute()

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

print(b.get_parameter(qualifier='times', kind='lc', context='model'))

print(b.get_parameter(qualifier='fluxes', kind='lc', context='model'))


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
For more details on boosting, see the Beaming and Boosting example script
atm
Can you write Python code for it?


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
For more details on irradiation, see the Irradiation tutorial
boosting_method
Can you write Python code for it?


I am working on the file "2.2/tutorials/LC.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.2/tutorials/LC.ipynb".
The first task is:
Mesh Fields
By adding a mesh dataset and setting the columns parameter, light-curve (i.e. passband-dependent) per-element quantities can be exposed and plotted.
Let's add a single mesh at the first time of the light-curve 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=['intensities@lc01',
                              'abs_intensities@lc01',
                              'normal_intensities@lc01',
                              'abs_normal_intensities@lc01',
                              'pblum_ext@lc01',
                              'boost_factors@lc01'])

b.run_compute()

print(b.get_model().datasets)


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
Now let's look at each of the available fields.
pblum
For more details, see the tutorial on Passband Luminosities
Can you write Python code for it?

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


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
Since these are the only two columns available in the synthetic model, the only other option is to plot in phase instead of time.
Can you write Python code for it?

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


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

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


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
abs_normal_intensities are the absolute normal intensities per-element.
normal_intensities
Can you write Python code for it?

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


I am working on the file "2.2/tutorials/LC.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='compute_phases_t0'))


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
intens_weighting
See the Intensity Weighting tutorial
Can you write Python code for it?


I am working on the file "2.2/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.2/tutorials/LC.ipynb".
The first task is:
l3
l3 is only avaible if l3_mode is set to 'flux'.  See the "Third" Light tutorial for more details.
Can you write Python code for it?

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

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


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


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
ld_coeffs
ld_coeffs will only be available if ld_mode is set to 'manual'.  See the limb darkening tutorial for more details.
Can you write Python code for it?

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

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


I am working on the file "2.2/tutorials/LC.ipynb".
The first task is:
ld_coeffs_source
ld_coeffs_source will only be available if ld_mode is 'lookup'.  See the limb darkening tutorial for more details.
Can you write Python code for it?


I am working on the file "2.2/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.2/tutorials/LC.ipynb".
The first task is:
normal_intensities are the relative normal intensities per-element.
abs_intensities
Can you write Python code for it?

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


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


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


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

%matplotlib inline

import phoebe

logger = phoebe.logger()

b = phoebe.default_binary()


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


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


I am working on the file "2.2/tutorials/LP.ipynb".
The first task is:
sigmas
Note that, like flux_densities, sigmas parameters are exposed per-time, according to the value of times passed to add_dataset.
Can you write Python code for it?

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

print(b.get_parameter(qualifier='sigmas',
                      component='binary',
                      time=0))


I am working on the file "2.2/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.2/tutorials/MESH.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?


I am working on the file "2.2/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.2/tutorials/MESH.ipynb".
The first task is:
Per-Mesh Parameters
Can you write Python code for it?

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


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


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


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


I am working on the file "2.2/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.2/tutorials/ORB.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

%matplotlib inline

import phoebe
from phoebe import u # units

logger = phoebe.logger()

b = phoebe.default_binary()


I am working on the file "2.2/tutorials/ORB.ipynb".
The first task is:
As always, you have access to any of the arrays for either axes, so if you want to plot 'vus' vs 'times'
Can you write Python code for it?

afig, mplfig = b.plot(x='times', y='vus', show=True)


I am working on the file "2.2/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.2/tutorials/ORB.ipynb".
The first task is:
Dataset Parameters
Let's add an orbit dataset to the Bundle (see also the orb API docs).
Can you write Python code for it?


I am working on the file "2.2/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.2/tutorials/ORB.ipynb".
The first task is:
We can also plot the orbit in 3D.
Can you write Python code for it?

afig, mplfig = b.plot(projection='3d', xlim=(-4,4), ylim=(-4,4), zlim=(-4,4), show=True)


I am working on the file "2.2/tutorials/ORB.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='compute_phases_t0'))


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


I am working on the file "2.2/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.2/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.2/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.2/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.2/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.2/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.2/tutorials/RV.ipynb".
The first task is:
These new columns are stored with the rv's dataset tag, but with the mesh model-kind.
Can you write Python code for it?


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


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

b.set_value('times', component='primary', value=[0])

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


I am working on the file "2.2/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.2/tutorials/alternate_backends.ipynb".
The first task is:
And we'll attach some dummy datasets.  See Datasets for more details.
Can you write Python code for it?

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

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


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

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

logger = phoebe.logger()

b = phoebe.default_binary()


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

b.set_value_all('ld_mode', 'manual')

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

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


I am working on the file "2.2/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('enabled@lc01@phoebebackend', False)
#b.set_value_all('enabled@orb01@legacybackend', 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.2/tutorials/alternate_backends.ipynb".
The first task is:
The parameters inside the returned model even remember which set of compute options (and therefore, in this case, which backend) were used to compute them.
Can you write Python code for it?

print(b['mixedresults'].computes)

b['mixedresults@phoebebackend'].datasets

b['mixedresults@legacybackend'].datasets


I am working on the file "2.2/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.2/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.2/tutorials/animations.ipynb".
The first task is:
As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Can you write Python code for it?

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

logger = phoebe.logger()

b = phoebe.default_binary()

times = np.linspace(0,1,51)

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

b.add_dataset('orb', compute_times=times, dataset='orb01')

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

b.run_compute(irrad_method='none')


I am working on the file "2.2/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.2/tutorials/animations.ipynb".
The first task is:
Plotting Options
By default, time highlighting is turned on.  See the plotting tutorial for details on 'highlight' and 'uncover' options.
Any additional arguments (colors, linestyle, etc) are passed to the plot call for EACH frame and for EVERY plotting call.
Can you write Python code for it?

afig, mplanim = b['lc01@model'].plot(times=times[:-1], uncover=True,\
                                     c='r', linestyle=':',\
                                     highlight_marker='s', highlight_color='g',
                                     animate=True, save='animations_3.gif', save_kwargs={'writer': 'imagemagick'})


I am working on the file "2.2/tutorials/apsidal_motion.ipynb".
The first task is:
In order for apsidal motion to be apparent, we need an eccentric system that is precessing.
Can you write Python code for it?


I am working on the file "2.2/tutorials/apsidal_motion.ipynb".
The first task is:
Influence on Light Curves (fluxes)
Now looking at the light curve, we can see that this is resulting in the eclipses moving in phase-space.
Can you write Python code for it?

afig, mplfig = b['lc01@model'].plot()
afig, mplfig = b['lc02@model'].plot(time=[0,1,4,5], show=True)

afig, mplfig = b['lc01@model'].plot(x='phases')
afig, mplfig = b['lc02@model'].plot(x='phases', show=True)


I am working on the file "2.2/tutorials/apsidal_motion.ipynb".
The first task is:
Influence on Orbits (positions)
Let's plot the orbit from above and highlight the positions of each star at each cycle (times that are multiples of the period).
Can you write Python code for it?

afig, mplfig = b['orb01@model'].plot(y='ws', time=[0,1,2,3,4,5], show=True)


I am working on the file "2.2/tutorials/apsidal_motion.ipynb".
The first task is:
We'll add lc and orb datasets to see how the apsidal motion affects each.  We'll need to sample over several orbits of the binary (which has a period of 3 days, by default).
Can you write Python code for it?

b.add_dataset('lc', times=np.linspace(0,1,101), dataset='lc01')
b.add_dataset('lc', times=np.linspace(4,5,101), dataset='lc02')

b.add_dataset('orb', compute_times=np.linspace(0,5,401), dataset='orb01')

b.run_compute(irrad_method='none')


I am working on the file "2.2/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.2/tutorials/atm_passbands.ipynb".
The first task is:
And we'll add a single light curve dataset to expose all the passband-dependent options.
Can you write Python code for it?


I am working on the file "2.2/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.2/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.2/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.2/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.2/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.2/tutorials/beaming_boosting.ipynb".
The first task is:
Calculate $S(\lambda) P(\lambda)$ and plot it, to make sure everything so far makes sense:
Can you write Python code for it?

plt.plot(wl, Inorm*pb.ptf(wl), 'b-')
plt.show()


I am working on the file "2.2/tutorials/beaming_boosting.ipynb".
The first task is:
Grab only the normal component for testing purposes:
Can you write Python code for it?


I am working on the file "2.2/tutorials/beaming_boosting.ipynb".
The first task is:
Now let's compute the term $\mathrm{d}(\mathrm{ln}\, I_\lambda) / \mathrm{d}(\mathrm{ln}\, \lambda)$. First we will compute $\mathrm{ln}\,\lambda$ and $\mathrm{ln}\,I_\lambda$ and plot them:
Can you write Python code for it?

lnwl = np.log(wl)
lnI = np.log(Inorm)

plt.xlabel(r'$\mathrm{ln}\,\lambda$')
plt.ylabel(r'$\mathrm{ln}\,I_\lambda$')
plt.plot(lnwl, lnI, 'b-')
plt.show()


I am working on the file "2.2/tutorials/beaming_boosting.ipynb".
The first task is:
Per equation above, $B(\lambda)$ is then the slope of this curve (plus 5). Herein lies the problem: what part of this graph do we fit a line to? In versions 2 and 2.1, PHOEBE used a 5th order Legendre polynomial to fit the spectrum and then sigma-clipping to get to the continuum. Finally, it computed an average derivative of that Legendrian and proclaimed that $B(\lambda)$. The order of the Legendre polynomial and the values of sigma for sigma-clipping have been set ad-hoc and kept fixed for every single spectrum.
Can you write Python code for it?

envelope = np.polynomial.legendre.legfit(lnwl, lnI, 5)
continuum = np.polynomial.legendre.legval(lnwl, envelope)
diff = lnI-continuum
sigma = np.std(diff)
clipped = (diff > -sigma)
while True:
    Npts = clipped.sum()
    envelope = np.polynomial.legendre.legfit(lnwl[clipped], lnI[clipped], 5)
    continuum = np.polynomial.legendre.legval(lnwl, envelope)
    diff = lnI-continuum
    clipped = clipped & (diff > -sigma)
    if clipped.sum() == Npts:
        break

plt.xlabel(r'$\mathrm{ln}\,\lambda$')
plt.ylabel(r'$\mathrm{ln}\,I_\lambda$')
plt.plot(lnwl, lnI, 'b-')
plt.plot(lnwl, continuum, 'r-')
plt.show()


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