!pip install -I "phoebe>=2.0,<2.1"

"""
Explanation: 'lc' Datasets and Options
Setup
Let's first make sure we have the latest version of PHOEBE 2.0 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).
End of explanation
"""


%matplotlib inline

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.  See Building a System for more details.
End of explanation
"""


ps, constraints = phoebe.dataset.lc()
print ps

ps_dep = phoebe.dataset.lc_dep()
print ps_dep

"""
Explanation: Dataset Parameters
Let's create the ParameterSets which would be added to the Bundle when calling add_dataset. Later we'll call add_dataset, which will create and attach both these ParameterSets for us.
End of explanation
"""


print ps['times']

"""
Explanation: times
End of explanation
"""


print ps['fluxes']

"""
Explanation: fluxes
End of explanation
"""


print ps['sigmas']

"""
Explanation: sigmas
End of explanation
"""


print ps_dep['ld_func']

"""
Explanation: ld_func
End of explanation
"""


print ps_dep['ld_coeffs']

"""
Explanation: ld_coeffs
End of explanation
"""


print ps_dep['passband']

"""
Explanation: passband
End of explanation
"""


print ps_dep['intens_weighting']

"""
Explanation: intens_weighting
See the Intensity Weighting tutorial
End of explanation
"""


print ps_dep['pblum']

"""
Explanation: pblum
See the Passband Luminosity tutorial
End of explanation
"""


print ps_dep['l3']

"""
Explanation: l3
See the "Third" Light tutorial
End of explanation
"""


ps_compute = phoebe.compute.phoebe()
print ps_compute

"""
Explanation: Compute Options
Let's look at the compute options (for the default PHOEBE 2 backend) that relate to computing fluxes and the LC dataset.
Other compute options are covered elsewhere:
* parameters related to dynamics are explained in the section on the orb dataset
* parameters related to meshing, eclipse detection, and subdivision are explained in the section on the mesh dataset
End of explanation
"""


print ps_compute['lc_method']

"""
Explanation: lc_method
End of explanation
"""


print ps_compute['irrad_method']

"""
Explanation: irrad_method
End of explanation
"""


print ps_compute['boosting_method']

"""
Explanation: boosting_method
End of explanation
"""


print ps_compute['atm']

"""
Explanation: For more details on boosting, see the Beaming and Boosting example script
atm
End of explanation
"""


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

b.run_compute()

b['lc@model'].twigs

print b['times@lc@model']

print b['fluxes@lc@model']

"""
Explanation: For more details on heating, see the Reflection and Heating example script
Synthetics
End of explanation
"""


axs, artists = b['lc@model'].plot()

"""
Explanation: Plotting
By default, LC datasets plot as flux vs time.
End of explanation
"""


axs, artists = b['lc@model'].plot(x='phases')

"""
Explanation: Since these are the only two columns available in the synthetic model, the only other option is to plot in phase instead of time.
End of explanation
"""


b['period'].components

axs, artists = b['lc@model'].plot(x='phases:binary')

"""
Explanation: In system hierarchies where there may be multiple periods, it is also possible to determine whose period to use for phasing.
End of explanation
"""


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

b.run_compute()

print b['model'].datasets

"""
Explanation: Mesh Fields
If a mesh dataset exists at any of the same times as the time array in the lc dataset, OR if store_mesh is set to True in the compute options, then flux-related surface element quantities will be available in the model as well.
Let's add a single mesh at the first time of the light-curve and re-call run_compute
End of explanation
"""


b.filter(dataset='lc01', kind='mesh', context='model').twigs

"""
Explanation: These new columns are stored with the lc's dataset tag, but with the 'mesh' dataset-kind.
End of explanation
"""


axs, artists = b['mesh@model'].plot(facecolor='intensities', edgecolor=None)
# NOT:
# b['mesh01@model'].plot(facecolor='intensities', edgecolor=None)

"""
Explanation: Any of these columns are then available to use as edge or facecolors when plotting the mesh (see the section on the mesh dataset), but since the mesh elements are stored with the 'mesh01' dataset tag, and the LC quantities are stored with the 'lc01' dataset tag, it is important not to provide the 'mesh01' dataset tag before plotting.
End of explanation
"""


print b['pblum@primary@lc01@mesh@model']

"""
Explanation: Now let's look at each of the available fields.
pblum
For more details, see the tutorial on Passband Luminosities
End of explanation
"""


print b['abs_normal_intensities@primary@lc01@mesh@model']

"""
Explanation: 'pblum' is the passband luminosity of the entire star/mesh - this is a single value (unlike most of the parameters in the mesh) and does not have per-element values.
abs_normal_intensities
End of explanation
"""


print b['normal_intensities@primary@lc01@mesh@model']

"""
Explanation: 'abs_normal_intensities' are the absolute normal intensities per-element.
normal_intensities
End of explanation
"""


print b['abs_intensities@primary@lc01@mesh@model']

"""
Explanation: 'normal_intensities' are the relative normal intensities per-element.
abs_intensities
End of explanation
"""


print b['intensities@primary@lc01@mesh@model']

"""
Explanation: 'abs_intensities' are the projected absolute intensities (towards the observer) per-element.
intensities
End of explanation
"""


print b['boost_factors@primary@lc01@mesh@model']

"""
Explanation: 'intensities' are the projected relative intensities (towards the observer) per-element.
boost_factors
End of explanation
"""


