Complete Binary Animation

NOTE: animating within Jupyter notebooks can be very resource intensive. This script will likely run much quicker as a Python script.

Setup

Let's first make sure we have the latest version of PHOEBE 2.2 installed. (You can comment out this line if you don't use pip for your installation or don't want to update to the latest release).


In [1]:
!pip install -I "phoebe>=2.2,<2.3"


Traceback (most recent call last):
  File "/home/kyle/.local/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/lib/python3/dist-packages/pip/__init__.py)

As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details.


In [2]:
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

b = phoebe.default_binary()

Adding Datasets


In [3]:
times = np.linspace(0,1,21)

In [4]:
b.add_dataset('lc', times=times, dataset='lc01')


Out[4]:
<ParameterSet: 43 parameters | contexts: dataset, constraint, figure, compute>

In [5]:
b.add_dataset('rv', times=times, dataset='rv01')


Out[5]:
<ParameterSet: 39 parameters | contexts: dataset, constraint, figure, compute>

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


Wed, 11 Dec 2019 14:38 BUNDLE       WARNING mesh dataset uses 'compute_times' instead of 'times', applying value sent as 'times' to 'compute_times'.
Out[6]:
<ParameterSet: 8 parameters | contexts: dataset, constraint, compute>

Running Compute


In [7]:
b.run_compute(irrad_method='none')


Out[7]:
<ParameterSet: 304 parameters | contexts: figure, model>

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


In [8]:
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'})


WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
WARNING: pad_aspect not supported for animations, ignoring
Out[8]:
(<autofig.figure.Figure | 5 axes | 129 call(s)>,
 <matplotlib.animation.FuncAnimation at 0x7f4665c4a828>)


In [ ]: