PHOEBE 2.0 Documentation

2.0 Docs

  • 1.0
  • 2.0a
  • ver: 2.0


Prev: 7. Plotting Next: Advanced: Settings
.

IPython Notebook | Python Script

8. Accessing and Plotting Meshes

8.1. Setup

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

%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()
WARNING: Constant u'Gravitational constant' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar mass' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar radius' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar luminosity' is already has a definition in the u'si' system [astropy.constants.constant]
/usr/local/lib/python2.7/dist-packages/astropy/units/quantity.py:782: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
  return super(Quantity, self).__eq__(other)

8.2. The ‘protomesh’

The ‘protomesh’ is the mesh of each star in its own reference frame at periastron. The coordinates are defined such that the x-axis points towards the other component in the parent orbit.

To build the protomesh, set ‘protomesh’ to be True, either in the compute options or directly as a keyword argument when calling run_compute.

b.run_compute(protomesh=True)
<ParameterSet: 30 parameters | components: primary, secondary>

You’ll see that the resulting model has a single dataset kind (‘mesh’) and with a dataset tag of ‘protomesh’.

print b['model'].kinds
['mesh']
print b['model'].datasets
['protomesh']

Now let’s look at the parameters in the protomesh

b.filter(dataset='protomesh', context='model')
<ParameterSet: 30 parameters | components: primary, secondary>
b.filter(dataset='protomesh', context='model', component='primary')
<ParameterSet: 15 parameters | qualifiers: nzs, cosbetas, nxs, rs, tareas, nys, normals, vertices, teffs, loggs, xs, ys, areas, visible_centroids, zs>
b.get_value(dataset='protomesh', context='model', component='primary', qualifier='teffs')
array([ 5978.07718064,  5978.1783501 ,  5978.07718064, ...,  5993.84913948,
        5991.5661137 ,  5990.59166869])
axs, artists = b.filter(dataset='protomesh', context='model', component='secondary').plot(facecolor='teffs', edgecolor=None)
/home/kyle/.local/lib/python2.7/site-packages/phoebe/frontend/plotting.py:257: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if pckwargs['edgecolors'] in ['none', 'None', None] and pckwargs['facecolors'] not in ['none', 'None', None]:
/home/kyle/.local/lib/python2.7/site-packages/phoebe/frontend/plotting.py:257: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
  if pckwargs['edgecolors'] in ['none', 'None', None] and pckwargs['facecolors'] not in ['none', 'None', None]:
../../_images/meshes_14_1.png

8.3. The ‘pbmesh’

‘pbmesh’ is an automatically-created dataset in the returned model which stores the mesh at every time-point at which it was required to be built by other existing datasets.

Again, these will only be stored in the returned model if pbmesh=True is passed during run_compute or is True in the passed compute options.

b.add_dataset('lc', times=[0,1,2], dataset='lc01')
<ParameterSet: 15 parameters | contexts: compute, dataset>
b.run_compute(pbmesh=True)
Fri, 10 Feb 2017 12:58 BUNDLE       WARNING overwriting model: latest
<ParameterSet: 220 parameters | kinds: mesh, lc>

Our model now has dataset kinds for both the ‘mesh’ and ‘lc’ and has dataset tags for our newly-created ‘lc01’ dataset as well as the ‘pbmesh’ datasets in the model created only because pbmesh=True.

print b['model'].kinds
['mesh', 'lc']
print b['model'].datasets
['lc01', 'pbmesh']

This time let’s look at the parameters in the ‘pbmesh’ dataset of the model.

b.filter(dataset='pbmesh', context='model')
<ParameterSet: 182 parameters | components: primary, secondary>
b.filter(dataset='pbmesh', context='model', component='primary')
<ParameterSet: 91 parameters | qualifiers: loggs, pot, xs, zs, horizon_zs, mus, rs, nys, r_projs, horizon_xs, teffs, vzs, vxs, horizon_analytic_xs, volume, rpole, horizon_analytic_ys, ys, areas, nzs, vys, cosbetas, nxs, horizon_analytic_zs, tareas, vertices, horizon_ys, times, visibilities, normals, visible_centroids>

As you can see, the intensities are not available here - their dataset tags match the dataset of the light curve. Instead let’s access the mesh by dataset-kind:

b.filter(kind='mesh', context='model', component='primary')
<ParameterSet: 109 parameters | datasets: lc01, pbmesh>
b.filter(dataset='lc01', kind='mesh', context='model', component='primary')
<ParameterSet: 18 parameters | qualifiers: normal_intensities, abs_intensities, abs_normal_intensities, intensities, boost_factors, pblum>

To plot the intensities as color on the mesh, we can just plot the mesh and then reference the correct column by using twig access:

axs, artists = b.filter(kind='mesh', context='model', time=1.0).plot(facecolor='intensities@lc01', edgecolor='teffs')
../../_images/meshes_28_0.png

8.4. The ‘Mesh’ Dataset Kind

If you want to force the plot itself to build at specific times but not have any observables (necessarily) computed or filled at those times, you can create a mesh dataset.

Let’s create a mesh dataset that fills in the missing times from our lc dataset.

b.get_value('times@lc01@dataset')
array([ 0.,  1.,  2.])
b.add_dataset('mesh', times=[0.5, 1.5], dataset='mesh01')
<ParameterSet: 2 parameters | contexts: compute, dataset>

Now let’s run_compute with protomesh and pbmesh set to False (these will default to the values in the compute options - which themselves are defaulted to False).

b.run_compute(protomesh=False, pbmesh=False)
Fri, 10 Feb 2017 12:59 BUNDLE       WARNING overwriting model: latest
<ParameterSet: 148 parameters | kinds: mesh, lc>

As expected, the resulting model has dataset kinds for both mesh and lc, as well as datasets for ‘mesh01’ and ‘lc01’ - but the ‘pbmesh’ and ‘protomesh’ entries are no longer created (since protomesh and pbmesh are both False).

print b['model'].kinds
['mesh', 'lc']
print b['model'].datasets
['mesh01', 'lc01']

The meshes are only stored at the times of the mesh dataset - not at the times of the lc dataset.

b.filter(kind='mesh', context='model').times
['1.5', '0.5']

Since there was no lc requested at these times, the ‘intensities’ columns will be empty.

b.get_value(kind='mesh', context='model', dataset='lc01', time=0.5, qualifier='intensities', component='primary')
array([], dtype=float64)

But we can still plot any of the dataset-independent quantities

b.filter(dataset='mesh01', kind='mesh', context='model', component='primary', time=0.5)
<ParameterSet: 30 parameters | qualifiers: loggs, pot, xs, zs, horizon_zs, mus, rs, nys, r_projs, horizon_xs, teffs, vzs, vxs, horizon_analytic_xs, volume, rpole, horizon_analytic_ys, ys, areas, nzs, vys, cosbetas, nxs, horizon_analytic_zs, tareas, vertices, horizon_ys, visibilities, normals, visible_centroids>
axs, artists = b.filter(dataset='mesh01', kind='mesh', context='model', time=0.5).plot(facecolor='teffs', edgecolor=None)
../../_images/meshes_43_0.png

If you want the meshes stored at both the times in the ‘mesh’ dataset and all other datasets, simply set pbmesh to True.

b.run_compute(pbmesh=True)
Fri, 10 Feb 2017 12:59 BUNDLE       WARNING overwriting model: latest
<ParameterSet: 366 parameters | kinds: mesh, lc>
b.filter(kind='mesh', context='model').times
['1.5', '0.5', '2.0', '1.0', '0.0']
Prev: 7. Plotting Next: Advanced: Settings
.
Last update: 06/07/2017 11:30 a.m. (CET)