'mesh' Datasets and Options

Setup

Let's first make sure we have the latest version of PHOEBE 2.1 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.1,<2.2"

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


In [1]:
%matplotlib inline

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

Dataset Parameters

Let's create and add a mesh dataset to the Bundle.


In [3]:
b.add_dataset('mesh')
print b.filter(kind='mesh')


ParameterSet: 3 parameters
            times@mesh01@dataset: [] d
    include_times@mesh01@dataset: []
          columns@mesh01@dataset: []

times


In [4]:
print b['times']


Parameter: times@mesh01@dataset
                       Qualifier: times
                     Description: Observed times
                           Value: [] d
                  Constrained by: 
                      Constrains: None
                      Related to: None

include_times


In [5]:
print b['include_times']


Parameter: include_times@mesh01@dataset
                       Qualifier: include_times
                     Description: append to times from the following datasets/time standards
                           Value: []
                         Choices: t0_perpass@binary, t0_supconj@binary, t0_ref@binary, t0@system

columns


In [6]:
print b['columns']


Parameter: columns@mesh01@dataset
                       Qualifier: columns
                     Description: columns to expose within the mesh
                           Value: []
                         Choices: volume, xs, ys, zs, vxs, vys, vzs, nxs, nys, nzs, us, vs, ws, vus, vvs, vws, nus, nvs, nws, areas, loggs, teffs, rprojs, mus, visibilities, visible_centroids, rs

Compute Options

Let's look at the compute options (for the default PHOEBE 2 backend) that relate to meshes


In [7]:
print b['compute']


ParameterSet: 15 parameters
  dynamics_method@phoebe01@co...: keplerian
           ltte@phoebe01@compute: False
   irrad_method@phoebe01@compute: wilson
  boosting_method@phoebe01@co...: none
  eclipse_method@phoebe01@com...: native
  horizon_method@phoebe01@com...: boolean
  mesh_method@primary@phoebe0...: marching
  mesh_method@secondary@phoeb...: marching
  ntriangles@primary@phoebe01...: 1500
  ntriangles@secondary@phoebe...: 1500
  distortion_method@primary@p...: roche
  distortion_method@secondary...: roche
    atm@primary@phoebe01@compute: ck2004
  atm@secondary@phoebe01@compute: ck2004
  enabled@mesh01@phoebe01@com...: True

mesh_method


In [8]:
print b['mesh_method@primary']


Parameter: mesh_method@primary@phoebe01@compute
                       Qualifier: mesh_method
                     Description: Which method to use for discretizing the surface
                           Value: marching
                         Choices: marching

The 'mesh_method' parameter determines how each component in the system is discretized into its mesh, and has several options:

  • marching (default): this is the new method introduced in PHOEBE 2. The star is discretized into triangles, with the attempt to make them each of equal-area and nearly equilateral. Although not as fast as 'wd', this method is more robust and will always form a closed surface (when possible).
  • wd: this is a re-implementation of the Wilson-Devinney style meshing used in PHOEBE 1.0 (legacy), with the stars discretized into trapezoids in strips of latitude (we then split each trapezoid into two triangles). This is faster, but suffers from gaps between the surface elements, and is mainly meant for testing and comparison with legacy. See the WD-Style Meshing Example Script for more details.

ntriangles

The 'ntriangles' parameter is only relevenat if mesh_method=='marching' (so will not be available unless that is the case).


In [9]:
print b['ntriangles@primary']


Parameter: ntriangles@primary@phoebe01@compute
                       Qualifier: ntriangles
                     Description: Requested number of triangles (won't be exact).
                           Value: 1500
                 Only visible if: mesh_method:marching

gridsize

The 'gridsize' parameter is only relevant if mesh_method=='wd' (so will not be available unless that is the case).


In [10]:
print b['gridsize@primary']


ParameterSet: 0 parameters
NO PARAMETERS

Synthetics


In [11]:
b.set_value('times', [0])

In [12]:
b['columns'] = '*'

In [13]:
b.run_compute()


Out[13]:
<ParameterSet: 60 parameters | components: primary, secondary>

In [14]:
b['mesh@model'].twigs


Out[14]:
['times@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@uvw_elements@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@xyz_elements@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@volume@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@xs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@ys@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@zs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vxs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vys@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vzs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nxs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nys@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nzs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@us@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@ws@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vus@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vvs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vws@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nus@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nvs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nws@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@areas@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@rs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@loggs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@teffs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@rprojs@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@mus@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@visible_centroids@primary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@visibilities@primary@mesh01@phoebe01@latest@mesh@model',
 'times@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@uvw_elements@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@xyz_elements@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@volume@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@xs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@ys@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@zs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vxs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vys@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vzs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nxs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nys@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nzs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@us@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@ws@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vus@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vvs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@vws@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nus@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nvs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@nws@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@areas@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@rs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@loggs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@teffs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@rprojs@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@mus@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@visible_centroids@secondary@mesh01@phoebe01@latest@mesh@model',
 '00.000000@visibilities@secondary@mesh01@phoebe01@latest@mesh@model']

Per-Mesh Parameters


In [15]:
print b['times@primary@mesh01@model']


Parameter: times@primary@latest@model
                       Qualifier: times
                     Description: Synthetic times
                           Value: [0.] d
                  Constrained by: 
                      Constrains: None
                      Related to: None

Per-Time Parameters


In [16]:
print b['volume@primary@mesh01@model']


Parameter: 00.000000@volume@primary@latest@model
                       Qualifier: volume
                     Description: Volume of the stellar surface
                           Value: 4.18879020479 solRad3
                  Constrained by: 
                      Constrains: None
                      Related to: None

Per-Element Parameters


In [17]:
print b['uvw_elements@primary@mesh01@model']


Parameter: 00.000000@uvw_elements@primary@latest@model
                       Qualifier: uvw_elements
                     Description: Vertices of triangles in the plane-of-sky
                           Value: [[[ 1.00235109e-16  1.00235109e-16 -1.63696356e+00]
  [-1.38927560e-01  1.00842067e-16 -1.64687593e+00]
  [-6.94589659e-02 -1.20310044e-01 -1.64697718e+00]]

 [[ 1.00235109e-16  1.00235109e-16 -1.63696356e+00]
  [-6.94589659e-02 -1.20310044e-01 -1.64697718e+00]
  [ 6.94578498e-02 -1.20308085e-01 -1.64699279e+00]]

 [[ 1.00235109e-16  1.00235109e-16 -1.63696356e+00]
  [ 6.94578498e-02 -1.20308085e-01 -1.64699279e+00]
  [ 1.38923748e-01  1.55940817e-16 -1.64690258e+00]]

 ...

 [[ 8.02647345e-01 -1.34867788e-01 -3.23812373e+00]
  [ 7.05300042e-01 -6.64578804e-02 -3.36424509e+00]
  [ 7.69595991e-01  4.46209716e-02 -3.29568376e+00]]

 [[ 8.02647345e-01 -1.34867788e-01 -3.23812373e+00]
  [ 7.02529405e-01 -1.80187653e-01 -3.34650497e+00]
  [ 7.05300042e-01 -6.64578804e-02 -3.36424509e+00]]

 [[ 7.02529405e-01 -1.80187653e-01 -3.34650497e+00]
  [ 8.02647345e-01 -1.34867788e-01 -3.23812373e+00]
  [ 7.77428997e-01 -1.91184860e-01 -3.25508541e+00]]] solRad
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [18]:
print b['xyz_elements@primary@mesh01@model']


Parameter: 00.000000@xyz_elements@primary@latest@model
                       Qualifier: xyz_elements
                     Description: Vertices of triangles in Roche coordinates
                           Value: [[[ 1.91138952e-01  0.00000000e+00  0.00000000e+00]
  [ 1.89268693e-01 -2.62127472e-02  0.00000000e+00]
  [ 1.89249588e-01 -1.31054653e-02 -2.27000084e-02]]

 [[ 1.91138952e-01  0.00000000e+00  0.00000000e+00]
  [ 1.89249588e-01 -1.31054653e-02 -2.27000084e-02]
  [ 1.89246644e-01  1.31052547e-02 -2.26996386e-02]]

 [[ 1.91138952e-01  0.00000000e+00  0.00000000e+00]
  [ 1.89246644e-01  1.31052547e-02 -2.26996386e-02]
  [ 1.89263664e-01  2.62120279e-02  1.03956827e-17]]

 ...

 [[-1.10966742e-01  1.51442895e-01 -2.54467525e-02]
  [-1.34763225e-01  1.33075480e-01 -1.25392227e-02]
  [-1.21827124e-01  1.45206791e-01  8.41905125e-03]]

 [[-1.10966742e-01  1.51442895e-01 -2.54467525e-02]
  [-1.31416032e-01  1.32552718e-01 -3.39976703e-02]
  [-1.34763225e-01  1.33075480e-01 -1.25392227e-02]]

 [[-1.31416032e-01  1.32552718e-01 -3.39976703e-02]
  [-1.10966742e-01  1.51442895e-01 -2.54467525e-02]
  [-1.14167058e-01  1.46684716e-01 -3.60726151e-02]]]
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [19]:
print b['us@primary@mesh01@model']


Parameter: 00.000000@us@primary@latest@model
                       Qualifier: us
                     Description: U coordinate of center of triangles in the plane-of-sky
                           Value: [-6.95482180e-02  1.19020929e-16  6.95482180e-02 ...
  7.61477837e-01  7.38277630e-01  7.61548025e-01] solRad
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [20]:
print b['rs@primary@mesh01@model']


Parameter: 00.000000@rs@primary@latest@model
                       Qualifier: rs
                     Description: Distance of each triangle from center of mass (of the half-envelope for contacts)
                           Value: [1.01066273 1.01062868 1.01066273 ... 1.00331297 1.00343833
 1.00295669] solRad
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [21]:
print b['rprojs@primary@mesh01@model']


Parameter: 00.000000@rprojs@primary@latest@model
                       Qualifier: rprojs
                     Description: Projected distance (on plane of sky) of each triangle from center of mass (of the half-envelope for contacts)
                           Value: [0.09241618 0.09241295 0.09241618 ... 0.76293453 0.74785824
 0.77879218] solRad
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [22]:
print b['nxs@primary@mesh01@model']


Parameter: 00.000000@nxs@primary@latest@model
                       Qualifier: nxs
                     Description: X component of normals
                           Value: [ 0.99658852  0.99654872  0.99657402 ... -0.62993257 -0.64636472
 -0.63739524]
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [23]:
print b['mus@primary@mesh01@model']


Parameter: 00.000000@mus@primary@latest@model
                       Qualifier: mus
                     Description: Mu
                           Value: [ 0.99658852  0.99654872  0.99657402 ... -0.62993257 -0.64636472
 -0.63739524]
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [24]:
print b['vxs@primary@mesh01@model']


Parameter: 00.000000@vxs@primary@latest@model
                       Qualifier: vxs
                     Description: X velocity of center of triangles
                           Value: [0. 0. 0. ... 0. 0. 0.] km / s
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [25]:
print b['areas@primary@mesh01@model']


Parameter: 00.000000@areas@primary@latest@model
                       Qualifier: areas
                     Description: Area of triangles
                           Value: [0.0083858  0.00838542 0.00838555 ... 0.01207408 0.00871089
 0.00352643] solRad2
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [26]:
print b['loggs@primary@mesh01@model']


Parameter: 00.000000@loggs@primary@latest@model
                       Qualifier: loggs
                     Description: Local surface gravity
                           Value: [4.41401467 4.41407592 4.41401467 ... 4.42770477 4.42750134
 4.4283148 ]
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [27]:
print b['teffs@primary@mesh01@model']


Parameter: 00.000000@teffs@primary@latest@model
                       Qualifier: teffs
                     Description: Local effective temperature
                           Value: [6026.91748731 6026.97665997 6026.91260356 ... 5993.51016065
 5993.2855728  5994.18366387] K
                  Constrained by: 
                      Constrains: None
                      Related to: None


In [28]:
print b['visibilities@primary@mesh01@model']


Parameter: 00.000000@visibilities@primary@latest@model
                       Qualifier: visibilities
                     Description: Visiblity of triangles (1=visible, 0.5=partial, 0=hidden)
                           Value: [0. 0. 0. ... 0. 0. 0.]
                  Constrained by: 
                      Constrains: None
                      Related to: None

Plotting

By default, MESH datasets plot as 'vs' vx 'us' (plane of sky coordinates) of just the surface elements, taken from the uvw_elements vectors.


In [29]:
afig, mplfig = b['mesh@model'].plot(show=True)


Any of the 1-D fields (ie not vertices or normals) or matplotlib-recognized colornames can be used to color either the faces or edges of the triangles. Passing none for edgecolor or facecolor turns off the coloring (you may want to set edgecolor=None if setting facecolor to disable the black outline).


In [30]:
afig, mplfig = b['mesh@model'].plot(fc='teffs', ec='None', show=True)


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.


In [31]:
afig, mplfig = b['mesh@model'].plot(x='mus', y='teffs', z=0, show=True)


The exception to needing to provide a time is for the per-time parameters mentioned above. For these, time can be the x-array (not very exciting in this case with only a single time).

For more examples see the following:


In [32]:
afig, mplfig = b['mesh@model'].plot(x='times', y='volume', marker='s', show=True)


/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py:2961: UserWarning: Attempting to set identical left==right results
in singular transformations; automatically expanding.
left=0.0, right=0.0
  'left=%s, right=%s') % (left, right))
/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py:3285: UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=4.188790204786394, top=4.188790204786394
  'bottom=%s, top=%s') % (bottom, top))

In [ ]: