<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 'rv' 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).
Step1:  As always, let's do imports and initialize a logger and a new Bundle.  See Building a System for more details.
Step2:  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.
Step3:  For information on these passband-dependent parameters, see the section on the lc dataset (these are used only to compute fluxes when rv_method=='flux-weighted')
times
Step4:  rvs
Step5:  sigmas
Step6:  Compute Options
Let's look at the compute options (for the default PHOEBE 2 backend) that relate to the RV dataset.
Other compute options are covered elsewhere
Step7:  rv_method
Step8:  If rv_method is set to 'dynamical' then the computed radial velocities are simply the z-velocities of the centers of mass of each component.  In this case, only the dynamical options are relevant.  For more details on these, see the section on the orb dataset.
If rv_method is set to 'flux-weighted' then radial velocities are determined by the z-velocity of each visible surface element of the mesh, weighted by their respective intensities.  Since the stars are placed in their orbits by the dynamic options, the section on the orb dataset is still applicable.  So are the meshing options described in mesh dataset and the options for computing fluxes in lc dataset.
rv_grav
Step9:  See the Gravitational Redshift Example Script for more details on the influence this parameter has on radial velocities.
Synthetics
Step10:  Plotting
By default, RV datasets plot as 'rvs' vs 'times'.
Step11:  Since these are the only two columns available in the synthetic model, the only other options is to plot in phase instead of time.
Step12:  In system hierarchies where there may be multiple periods, it is also possible to determine whose period to use for phasing.
Step13:  Mesh Fields
If a mesh dataset exists at any of the same times as the time array in the rv dataset, or if pbmesh is set to True in the compute options, then radial velocities for each surface element will be available in the model as well (only if mesh_method=='flux_weighted').
Since the radial velocities are flux-weighted, the flux-related quantities are also included.  For a description of these, see the section on the lc dataset.
Let's add a single mesh at the first time of the rv dataset and re-call run_compute
Step14:  These new columns are stored with the rv's dataset tag, but with the mesh model-kind.
Step15:  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 rv (including flux-related) quantities are stored with the 'rv01' dataset tag, it is important not to provide the 'mesh01' dataset tag before plotting.
Step16:  rvs
<ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.0,<2.1"
Explanation: 'rv' 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.rv()
print ps
ps_dep = phoebe.dataset.rv_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: For information on these passband-dependent parameters, see the section on the lc dataset (these are used only to compute fluxes when rv_method=='flux-weighted')
times
End of explanation
print ps['rvs']
Explanation: rvs
End of explanation
print ps['sigmas']
Explanation: sigmas
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 the RV 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 (used if rv_method=='flux-weighted') are explained in the section on the mesh dataset
* parameters related to computing fluxes (used if rv_method=='flux-weighted') are explained in the section on the lc dataset
End of explanation
print ps_compute['rv_method']
Explanation: rv_method
End of explanation
print ps_compute['rv_grav']
Explanation: If rv_method is set to 'dynamical' then the computed radial velocities are simply the z-velocities of the centers of mass of each component.  In this case, only the dynamical options are relevant.  For more details on these, see the section on the orb dataset.
If rv_method is set to 'flux-weighted' then radial velocities are determined by the z-velocity of each visible surface element of the mesh, weighted by their respective intensities.  Since the stars are placed in their orbits by the dynamic options, the section on the orb dataset is still applicable.  So are the meshing options described in mesh dataset and the options for computing fluxes in lc dataset.
rv_grav
End of explanation
b.add_dataset('rv', times=np.linspace(0,1,101), dataset='rv01')
b.run_compute(irrad_method='none')
b['rv@model'].twigs
print b['times@primary@rv@model']
print b['rvs@primary@rv@model']
Explanation: See the Gravitational Redshift Example Script for more details on the influence this parameter has on radial velocities.
Synthetics
End of explanation
axs, artists = b['rv@model'].plot()
Explanation: Plotting
By default, RV datasets plot as 'rvs' vs 'times'.
End of explanation
axs, artists = b['rv@model'].plot(x='phases')
Explanation: Since these are the only two columns available in the synthetic model, the only other options is to plot in phase instead of time.
End of explanation
b['period'].components
axs, artists = b['rv@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(irrad_method='none')
print b['model'].datasets
Explanation: Mesh Fields
If a mesh dataset exists at any of the same times as the time array in the rv dataset, or if pbmesh is set to True in the compute options, then radial velocities for each surface element will be available in the model as well (only if mesh_method=='flux_weighted').
Since the radial velocities are flux-weighted, the flux-related quantities are also included.  For a description of these, see the section on the lc dataset.
Let's add a single mesh at the first time of the rv dataset and re-call run_compute
End of explanation
b.filter(dataset='rv01', kind='mesh', context='model').twigs
Explanation: These new columns are stored with the rv's dataset tag, but with the mesh model-kind.
End of explanation
axs, artists = b['mesh@model'].plot(facecolor='rvs', edgecolor=None)
# NOT:
# axs, artists = b['mesh01@model'].plot(facecolor='rvs', 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 rv (including flux-related) quantities are stored with the 'rv01' dataset tag, it is important not to provide the 'mesh01' dataset tag before plotting.
End of explanation
print b['rvs@primary@rv01@mesh@model']
Explanation: rvs
End of explanation
<END_TASK>