PHOEBE 2.0 Documentation

2.0 Docs

  • 1.0
  • 2.0a
  • ver: 2.0


IPython Notebook | Python Script

Advanced: Animations

NOTE: this example script may take a while to load in a browser as there are many embedded animations.

Setup

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

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

logger = phoebe.logger()

b = phoebe.default_binary()
WARNING: Constant u'Gravitational constant' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Gravitational constant' is already has a definition in the u'si' system
WARNING: Constant u'Solar mass' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar mass' is already has a definition in the u'si' system
WARNING: Constant u'Solar radius' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar radius' is already has a definition in the u'si' system
WARNING: Constant u'Solar luminosity' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING:astropy:Constant u'Solar luminosity' is already has a definition in the u'si' system
WARNING: developer mode enabled, to disable 'rm ~/.phoebe_devel_enabled' and restart phoebe
/usr/local/lib/python2.7/dist-packages/astropy/units/quantity.py:732: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
  return super(Quantity, self).__eq__(other)
times = np.linspace(0,1,51)
b.add_dataset('lc', times=times, dataset='lc01')
<ParameterSet: 15 parameters | contexts: compute, dataset>
b.add_dataset('orb', times=times, dataset='orb01')
<ParameterSet: 3 parameters | contexts: compute, dataset>
b.run_compute(irrad_method='none', pbmesh=True)
<ParameterSet: 3690 parameters | kinds: mesh, orb, lc>

Showing and Saving

NOTE: in IPython notebooks calling animate will display directly below the call to animate (by exporting to html). If you have JSAnimation installed, you’ll see a display with sliders, if not you’ll see an embedded mp4 file. When not in IPython you have several options for viewing the animation:

  • call plt.show() after calling animate
  • call the save method on the returned mpl anim object
  • pass show=True to the animate method (same as calling plt.show())
  • pass save=’myfilename.gif’ to the animate method (same as calling anim.save(‘myfilename.gif’))

Default Animations

By calling b.animate(), a subplot will be created for each dataset/method and will loop over each of the synthetic times.

To create a similar animation in real-time while creating the model, pass True to the animation keyword: - b.run_compute(animation=True).

Note that whenever animating directly from run_compute some features aren’t available, including the ability to save the animation.

b.animate()
/usr/local/lib/python2.7/dist-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):


Once Loop Reflect