<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Advanced
Step1:  Saving a Bundle
Step2:  To save the Bundle to a file, we can call the save method of the Bundle and pass a filename.
Step3:  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
Step4:  Loading a Bundle
To open an existing Bundle from the file we just created, call Bundle.open and pass the filename.
Step5:  Just to prove this worked, we can check to make sure we retained the changed value of inclination.
Step6:  Support for Other Codes
Legacy
Importing from a PHOEBE Legacy file is as simple as passing the filename to from_legacy
Step7:  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.
Step8:  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.
<ASSISTANT_TASK:>
Python Code:
#!pip install -I "phoebe>=2.4,<2.5"
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()
Explanation: Advanced: Saving, Loading, and Exporting
Setup
Let's first make sure we have the latest version of PHOEBE 2.4 installed (uncomment this line if running in an online notebook session such as colab).
End of explanation
b['incl@orbit'] = 56.789
Explanation: Saving a Bundle
End of explanation
print(b.save('test.phoebe'))
Explanation: To save the Bundle to a file, we can call the save method of the Bundle and pass a filename.
End of explanation
!head -n 30 test.phoebe
Explanation: 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).
End of explanation
b2 = phoebe.Bundle.open('test.phoebe')
Explanation: Loading a Bundle
To open an existing Bundle from the file we just created, call Bundle.open and pass the filename.
End of explanation
print(b2.get_value('incl@orbit'))
Explanation: Just to prove this worked, we can check to make sure we retained the changed value of inclination.
End of explanation
b = phoebe.Bundle.from_legacy('legacy.phoebe')
Explanation: Support for Other Codes
Legacy
Importing from a PHOEBE Legacy file is as simple as passing the filename to from_legacy:
End of explanation
b.export_legacy('legacy_export.phoebe')
Explanation: 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.
End of explanation
!head -n 30 legacy_export.phoebe
Explanation: 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.
End of explanation
<END_TASK>