Saving and Loading

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]:
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger(clevel='INFO')

b = phoebe.default_binary()


Thu, 04 Oct 2018 12:50 BUNDLE       INFO    adding phoebe 'phoebe01' compute to bundle

Saving a Bundle


In [2]:
b['incl@orbit'] = 56.789

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


In [3]:
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).


In [4]:
!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",

Loading a Bundle

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


In [5]:
b2 = phoebe.Bundle.open('test.phoebe')

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


In [6]:
print b2.get_value('incl@orbit')


56.789

Support for Other Codes

Legacy

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


In [7]:
b = phoebe.Bundle.from_legacy('legacy.phoebe')


Thu, 04 Oct 2018 12:50 BUNDLE       INFO    adding phoebe 'phoebe01' compute to bundle
Thu, 04 Oct 2018 12:50 BUNDLE       INFO    adding legacy 'legacy01' compute to bundle
Thu, 04 Oct 2018 12:50 IO           WARNING Phoebe Legacy reflection effect switch is set to false so refl_num is being set to 0.
Thu, 04 Oct 2018 12:50 IO           WARNING l3 as a percentage of total light is currently not supported in phoebe 2
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_indweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_levweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_rate has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_filename has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_sigma has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_dep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_timestamp has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_indep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           WARNING l3 as a percentage of total light is currently not supported in phoebe 2
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_indweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_levweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_rate has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_filename has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_sigma has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_dep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_cadence_timestamp has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_lc_indep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_cadence_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_filename has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_sigma has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_dep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_indweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_cadence_timestamp has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_indep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_cadence_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_filename has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_sigma has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_dep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_indweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_cadence_timestamp has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_rv_indep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_spno has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_opsf[1] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_opsf[2] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_name has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_reffect_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_logg1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_logg2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_compute_hla_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_bins_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_compute_logg_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_spot2id has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_el3_units has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_ie_factor has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_nms_accuracy has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_indep has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_grid_coarsesize1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_grid_coarsesize2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           WARNING If you would like to use phoebe 1 atmospheres, you must add this manually
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_model has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_bins has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           WARNING If you would like to use phoebe 1 atmospheres, you must add this manually
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_nms_iters_max has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 BUNDLE       INFO    flipping constraint 't0_ref@binary@constraint' to solve for 't0_supconj'
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_spot1src has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_synscatter_seed has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_mbol1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_synscatter_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_proximity_rv2_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_mbol2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_pshift has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_sbr1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_synscatter_sigma has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_sbr2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_spectra_disptype has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_cla[1] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_cla[2] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_mnorm has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_mass1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_spot2src has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_mass2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_ie_excess has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_vol1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_passband_mode has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_vol2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_plum1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_plum2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_extinction[1] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_extinction[2] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_proximity_rv1_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_usecla_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_el3[1] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_el3[2] has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_symder_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_spot1id has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_radius1 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_radius2 has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_synscatter_levweight has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_dc_lambda has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:50 IO           INFO    Parameter phoebe_compute_vga_switch has no Phoebe 2 counterpart
Thu, 04 Oct 2018 12:51 BUNDLE       INFO    flipping constraint 't0_supconj@binary@constraint' to solve for 't0_ref'

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), via b.export_legacy.


In [8]:
b.export_legacy('legacy_export.phoebe')


Thu, 04 Oct 2018 12:51 IO           WARNING requiv_max@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING freq@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pitch@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING yaw@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING long_an@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING irrad_frac_lost_bol@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING ld_func_bol@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING mass@primary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING requiv_max@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING freq@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pitch@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING yaw@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING long_an@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING irrad_frac_lost_bol@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING ld_func_bol@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING mass@secondary@star@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pblum_ref@primary@lc02@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pblum_ref@secondary@lc02@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING intens_weighting@lc02@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING fti_method@lc02@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Thu, 04 Oct 2018 12:51 IO           WARNING lc_method@lc02@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING fti_method@lc01@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pblum_ref@primary@lc01@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING pblum_ref@secondary@lc01@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING lc_method@lc01@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING intens_weighting@lc01@lc_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@secondary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_grav@primary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@secondary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@primary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_grav@secondary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING intens_weighting@rv1@rv_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@primary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@secondary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_grav@primary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@secondary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@primary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_grav@secondary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING intens_weighting@rv1@rv_dep@dataset has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@primary@rv1@phoebe01@phoebe@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING freq@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING t0_perpass@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING t0_supconj@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING mean_anom@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING long_an@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING asini@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING ecosw@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING esinw@binary@orbit@component has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING Since relflection number is zero albedo is being set to 0 for both components
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@primary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING rv_method@secondary@rv1@legacy01@legacy@compute has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING t0@system has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING ra@system has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING dec@system has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING epoch@system has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING distance@system has no phoebe 1 corollary
Thu, 04 Oct 2018 12:51 IO           WARNING hierarchy@system 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.


In [9]:
!head -n 30 legacy_export.phoebe


# Phoebe 1 file created from phoebe 2 bundle. Some functionality may be lost
phoebe_rvno = 2
phoebe_spots_no = 0
phoebe_lcno = 2
phoebe_indep = "Time (HJD)"
phoebe_el3_units = "Flux"
phoebe_ld_model = "Logarithmic law"
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

Next

Next up: let's learn all about constraints