#!pip install -I "phoebe>=2.4,<2.5"

"""
Explanation: Minimal Contact Binary System
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
"""


import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

"""
Explanation: As always, let's do imports and initialize a logger and a new bundle.
End of explanation
"""


b = phoebe.default_binary(contact_binary=True)

"""
Explanation: Here we'll initialize a default binary, but ask for it to be created as a contact system.
For more details see the contact binary hierarchy tutorial.
End of explanation
"""


b.add_dataset('mesh', compute_times=[0], dataset='mesh01')

b.add_dataset('orb', compute_times=np.linspace(0,1,201), dataset='orb01')

b.add_dataset('lc', times=np.linspace(0,1,21), dataset='lc01')

b.add_dataset('rv', times=np.linspace(0,1,21), dataset='rv01')

"""
Explanation: Adding Datasets
End of explanation
"""


b.run_compute(irrad_method='none')

"""
Explanation: Running Compute
End of explanation
"""


print(b['mesh01@model'].components)

"""
Explanation: Synthetics
To ensure compatibility with computing synthetics in detached and semi-detached systems in Phoebe, the synthetic meshes for our overcontact system are attached to each component separetely, instead of the contact envelope.
End of explanation
"""


afig, mplfig = b['mesh01@model'].plot(x='ws', show=True)

"""
Explanation: Plotting
Meshes
End of explanation
"""


afig, mplfig = b['orb01@model'].plot(x='ws',show=True)

"""
Explanation: Orbits
End of explanation
"""


afig, mplfig = b['lc01@model'].plot(show=True)

"""
Explanation: Light Curves
End of explanation
"""


afig, mplfig = b['rv01@model'].plot(show=True)

"""
Explanation: RVs
End of explanation
"""


