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

"""
Explanation: 'orb' 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.orb()
print ps

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


print ps['times']

"""
Explanation: times
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 dynamics and the ORB dataset
End of explanation
"""


print ps_compute['dynamics_method']

"""
Explanation: dynamics_method
End of explanation
"""


print ps_compute['ltte']

"""
Explanation: The 'dynamics_method' parameter controls how stars and components are placed in the coordinate system as a function of time and has several choices:
 * keplerian (default): Use Kepler's laws to determine positions.  If the system has more than two components, then each orbit is treated independently and nested (ie there are no dynamical/tidal effects - the inner orbit is treated as a single point mass in the outer orbit).
 * more coming soon
ltte
End of explanation
"""


b.add_dataset('orb', times=np.linspace(0,3,201))

b.run_compute()

b['orb@model'].twigs

print b['times@primary@orb01@orb@model']

print b['xs@primary@orb01@orb@model']

print b['vxs@primary@orb01@orb@model']

"""
Explanation: The 'ltte' parameter sets whether light travel time effects (Roemer delay) are included.  If set to False, the positions and velocities are returned as they actually are for that given object at that given time.  If set to True, they are instead returned as they were or will be when their light reaches the origin of the coordinate system.
See the Systemic Velocity Example Script for an example of how 'ltte' and 'vgamma' (systemic velocity) interplay.
Synthetics
End of explanation
"""


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

"""
Explanation: Plotting
By default, orb datasets plot as 'ys' vx 'xs' (plane of sky).  Notice the y-scale here with inclination set to 90.
End of explanation
"""


axs, artists = b['orb@model'].plot(x='times', y='vxs')

"""
Explanation: As always, you have access to any of the arrays for either axes, so if you want to plot 'vxs' vs 'times'
End of explanation
"""


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

axs, artists = b['orb@model'].plot(xlim=(-4,4), ylim=(-4,4), zlim=(-4,4))

"""
Explanation: 3d axes are not yet supported for orbits, but hopefully will be soon.
Once they are supported, they will default to x, y, and z positions plotted on their respective axes.
End of explanation
"""


