PHOEBE 2.0 Documentation

2.0 Docs

  • 1.0
  • 2.0a
  • ver: 2.0


IPython Notebook | Python Script

Advanced: Settings

The Bundle also contains a few Parameters that provide settings for that Bundle. Note that these are not system-wide and only apply to the current Bundle. They are however maintained when saving and loading a Bundle.

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

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)

Accessing Settings

Settings are found with their own context in the Bundle and can be accessed through the get_setting method

b.get_setting()
<ParameterSet: 5 parameters | qualifiers: log_history, dict_set_all, phoebe_version, dict_filter, plotting_backend>

or via filtering/twig access

b['setting']
<ParameterSet: 5 parameters | qualifiers: log_history, dict_set_all, phoebe_version, dict_filter, plotting_backend>

and can be set as any other Parameter in the Bundle

b['plotting_backend@setting']
<Parameter: plotting_backend=mpl | keys: description, choices, value, visible_if, copy_for>
b['plotting_backend@setting'].choices
['mpl']

Available Settings

Now let’s look at each of the available settings and what they do

log_history

log_history is a BooleanParameter (defaults to False) that controls whether undo/redo ability is enabled.

b['log_history@setting'].description
'Whether to log history (undo/redo)'

This parameter can also be set by calling b.enable_history() or b.disable_history() and can be accessed with b.history_enabled.

b['log_history@setting']
<Parameter: log_history=False | keys: description, value, visible_if, copy_for>
b.history_enabled
False
b.enable_history()
b['log_history@setting']
<Parameter: log_history=True | keys: description, value, visible_if, copy_for>
b.history_enabled
True

dict_set_all

dict_set_all is a BooleanParameter (defaults to False) that controls whether attempting to set a value to a ParameterSet via dictionary access will set all the values in that ParameterSet (if True) or raise an error (if False)

b['dict_set_all@setting']
<Parameter: dict_set_all=False | keys: description, value, visible_if, copy_for>
b['teff@component']
<ParameterSet: 2 parameters | components: primary, secondary>

In our default binary there are temperatures (‘teff’) parameters for each of the components (‘primary’ and ‘secondary’). If we were to do:

b['teff@component‘] = 6000

this would raise an error. Under-the-hood, this is simply calling:

b.set_value('teff@component‘, 6000)

which of course would also raise an error.

In order to set both temperatures to 6000, you would either have to loop over the components or call the set_value_all method:

b.set_value_all('teff@component', 4000)
print b['value@teff@primary@component'], b['value@teff@secondary@component']
4000.0 4000.0

If you want dictionary access to use set_value_all instead of set_value, you can enable this parameter

b['dict_set_all@setting'] = True
b['teff@component'] = 8000
print b['value@teff@primary@component'], b['value@teff@secondary@component']
Fri, 10 Feb 2017 13:14 PARAMETERS   WARNING 'primary' probably has a radiative atm (teff=8000K>8000K), for which gravb_bol=1.00 might be a better approx than gravb_bol=0.32
Fri, 10 Feb 2017 13:14 PARAMETERS   WARNING 'primary' probably has a radiative atm (teff=8000K>8000K), for which gravb_bol=1.00 might be a better approx than gravb_bol=0.32
8000.0 8000.0

Now let’s disable this so it doesn’t confuse us while looking at the other options

b['dict_set_all@setting'] = False

dict_filter

dict_filter is a Parameter that accepts a dictionary. This dictionary will then always be sent to the filter call which is done under-the-hood during dictionary access.

b['incl']
<ParameterSet: 5 parameters | contexts: component, constraint>

In our default binary, there are several inclination parameters - one for each component (‘primary’, ‘secondary’, ‘binary’) and one with the constraint context (to keep the inclinations aligned).

This can be inconvenient... if you want to set the value of the binary’s inclination, you must always provide extra information (like '@component‘).

Instead, we can always have the dictionary access search in the component context by doing the following

b['dict_filter@setting'] = {'context': 'component'}
b['incl']
<ParameterSet: 3 parameters | kinds: star, orbit>

Now we no longer see the constraint parameters.

All parameters are always accessible with method access:

b.filter(qualifier='incl')
<ParameterSet: 5 parameters | contexts: component, constraint>

Now let’s reset this option... keeping in mind that we no longer have access to the ‘setting’ context through twig access, we’ll have to use methods to clear the dict_filter

b.set_value('dict_filter@setting', {})

plotting_backend

plotting_backend sets the default backend to use in all plotting calls. See the Plotting tutorial for more details.

b['plotting_backend@setting']
<Parameter: plotting_backend=mpl | keys: description, choices, value, visible_if, copy_for>
b['plotting_backend@setting'].choices
['mpl']
Prev: 8. Accessing and Plotting Meshes Next: Advanced: Animations
.
Last update: 06/07/2017 11:30 a.m. (CET)