PHOEBE 2.0 Documentation

2.0 Docs

  • 1.0
  • 2.0a
  • ver: 2.0


Prev: 2. Building a System Next: 4. Constraints
.

IPython Notebook | Python Script

3. Saving and Loading

3.1. 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: 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)

3.2. Saving a Bundle

b['incl@orbit'] = 56.789
Tue, 14 Feb 2017 12:59 PARAMETERS   WARNING misaligned orbits are not currently supported.
Tue, 14 Feb 2017 12:59 PARAMETERS   WARNING misaligned orbits are not currently supported.

To save the Bundle to a file, we can call the save method of the Bundle and pass a filename.

print b.save('test.phoebe')
test.phoebe

We can now inspect the contents of the created file.

This file is in the JSON-format and is simply a list of dictionaries - where each dictionary represents the attributes of a single Parameter.

You could edit this file in a text-editor - but do be careful if changing any of the tags. For example: if you want to change the component tag of one of your stars, make sure to change ALL instances of the component tag to match (as well as the hierarchy Parameter).

!head -n 30 test.phoebe
[
{
"Class": "FloatParameter",
"context": "system",
"copy_for": false,
"default_unit": "d",
"description": "Time at which all values are provided",
"limits": [
null,
null
],
"qualifier": "t0",
"value": 0.0
},
{
"Class": "FloatParameter",
"context": "system",
"copy_for": false,
"default_unit": "deg",
"description": "Right ascension",
"limits": [
null,
null
],
"qualifier": "ra",
"value": 0.0
},
{
"Class": "FloatParameter",
"context": "system",

3.3. Loading a Bundle

To open an existing Bundle from the file we just created, call Bundle.open and pass the filename.

b2 = phoebe.Bundle.open('test.phoebe')

Just to prove this worked, we can check to make sure we retained the changed value of inclination.

print b2.get_value('incl@orbit')
56.789

3.4. Support for Other Codes

3.4.1. Legacy

Importing from a PHOEBE Legacy file is as simple as passing the filename to from_legacy:

b = phoebe.Bundle.from_legacy('legacy.phoebe')
Tue, 14 Feb 2017 12:59 PHOEBE       WARNING constraints will not be run until 'run_delayed_constraints' or 'run_compute' is called.  This may result in inconsistent parameters if printing values before calling either of these methods.
Tue, 14 Feb 2017 13:00 IO           WARNING Phoebe Legacy reflection effect switch is set to false so refl_num is being set to 0.
Tue, 14 Feb 2017 13:00 IO           WARNING If you would like to use phoebe 1 atmospheres, you must add this manually
Tue, 14 Feb 2017 13:00 IO           WARNING If you would like to use phoebe 1 atmospheres, you must add this manually

Exporting to a PHOEBE Legacy file is also possible (although note that some parameters don’t translate exactly or are not supported in PHOEBE Legacy).

b.export_legacy('legacy_export.phoebe')
Tue, 14 Feb 2017 13:00 IO           WARNING rpole has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING freq has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING ld_func_bol has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING mass has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rpole has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING freq has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING ld_func_bol has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING mass has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING fti_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING lc_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING pblum_ref has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING pblum_ref has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING intens_weighting has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Tue, 14 Feb 2017 13:00 IO           WARNING lc_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING pblum_ref has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING intens_weighting has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Tue, 14 Feb 2017 13:00 IO           WARNING pblum_ref has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING fti_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_grav has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_grav has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING intens_weighting has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_grav has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_grav has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING intens_weighting has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING rv_method has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING freq has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING t0_perpass has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING mean_anom has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING long_an has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING asini has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING ecosw has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING esinw has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING t0 has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING ra has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING dec has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING epoch has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING distance has no phoebe 1 corollary
Tue, 14 Feb 2017 13:00 IO           WARNING hierarchy has no phoebe 1 corollary

For the parameters that could not be directly translated, you should see a warning message (if you have warning messages enabled in your logger).

We can now look at the beginning of the saved file and see that it matches the PHOEBE Legacy file-format.

!head -n 30 legacy_export.phoebe
# Phoebe 1 file created from phoebe 2 bundle
phoebe_rvno = 2
phoebe_spots_no = 0
phoebe_lcno = 2
phoebe_indep = "Time (HJD)"
phoebe_usecla_switch = 0
phoebe_model = "Detached binary"
phoebe_pot1.VAL = 10.0
phoebe_teff1.VAL = 6000.0
phoebe_met1.VAL = 0.0
phoebe_f1.VAL = 1.0
phoebe_grb1.VAL = 0.0
phoebe_alb1.VAL = 0.0
phoebe_ld_xbol1 = 0.0
phoebe_ld_ybol1 = 0.0
phoebe_pot2.VAL = 10.0
phoebe_teff2.VAL = 6000.0
phoebe_met2.VAL = 0.0
phoebe_f2.VAL = 1.0
phoebe_grb2.VAL = 0.32
phoebe_alb2.VAL = 0.0
phoebe_ld_xbol2 = 0.0
phoebe_ld_ybol2 = 0.0
phoebe_lc_indep[1] = Time (HJD)
phoebe_lc_dep[1] = Flux
phoebe_lc_id[1] = lc02
phoebe_ld_lcx1[1].VAL = 0.5
phoebe_ld_lcy1[1].VAL = 0.5
phoebe_lc_active[1] = 1
phoebe_ld_lcx2[1].VAL = 0.5
Prev: 2. Building a System Next: 4. Constraints
.
Last update: 06/07/2017 11:30 a.m. (CET)