Let's first make sure we have the latest version of PHOEBE 2.0 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 [ ]:
!pip install -I "phoebe>=2.0,<2.1"
As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details.
In [1]:
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger()
b = phoebe.default_binary()
And we'll attach some dummy datasets. See Datasets for more details.
In [2]:
b.add_dataset('orb', times=np.linspace(0,10,1000), dataset='orb01', component=['primary', 'secondary'])
Out[2]:
In [3]:
b.add_dataset('lc', times=np.linspace(0,10,1000), dataset='lc01')
Out[3]:
See the Compute Tutorial for details on adding compute options and using them to create synthetic models.
For more details, see Comparing PHOEBE 2.0 vs PHOEBE Legacy
In [4]:
b.add_compute('legacy', compute='legacybackend')
print b['legacybackend']
Adding a set of compute options 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.
In [5]:
b.add_compute('phoebe', compute='phoebebackend')
Out[5]:
In [6]:
print b['phoebebackend']
But, since the legacy backend doesn't support ck2004 atmospheres and interpolated limb-darkening, we do need to choose a limb-darkening law.
In [7]:
b.set_value_all('ld_func', 'logarithmic')
In [8]:
b.run_compute('legacybackend', model='legacyresults')
Out[8]:
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.
In [9]:
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['enabled']
In [10]:
b.run_compute(['phoebebackend', 'legacybackend'], model='mixedresults')
Out[10]:
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.
In [11]:
print b['mixedresults'].computes
In [12]:
b['mixedresults@phoebebackend'].datasets
Out[12]:
In [13]:
b['mixedresults@legacybackend'].datasets
Out[13]:
In [ ]:
In [ ]: