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

"""
Explanation: Eccentricity (Volume Conservation)
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()

b = phoebe.default_binary()

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


print(b.get_parameter(qualifier='ecc'))

print(b.get_parameter(qualifier='ecosw', context='component'))

print(b.get_parameter(qualifier='esinw', context='component'))

"""
Explanation: Relevant Parameters
End of explanation
"""


print(b.get_parameter(qualifier='ecosw', context='constraint'))

print(b.get_parameter(qualifier='esinw', context='constraint'))

"""
Explanation: Relevant Constraints
End of explanation
"""


b.add_dataset('mesh', times=np.linspace(0,1,11), columns=['volume'])

b.set_value('ecc', 0.2)

b.run_compute()

print(b['volume@primary@model'])

afig, mplfig = b['mesh01'].plot(x='times', y='volume', ylim=(4.18, 4.20), show=True)

b.remove_dataset('mesh01')

"""
Explanation: Influence on Meshes (volume conservation)
End of explanation
"""


b.add_dataset('rv', times=np.linspace(0,1,51))

b.run_compute()

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

b.remove_dataset('rv01')

"""
Explanation: Influence on Radial Velocities
End of explanation
"""


b.add_dataset('lc', times=np.linspace(0,1,51))

b.run_compute()

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

"""
Explanation: Influence on Light Curves (fluxes)
End of explanation
"""


