from numpy import sin, cos, zeros import fkepler fkepler.settol(1.e-5) def v_rad(K, tau, e, long, T0, v0, times): """ Calculate the radial (line-of-sight) velocity for a Keplerian orbit as a function of orbital parameters, COM velocity, and time. The parameters are: K = velocity amplitude tau = period e = eccentricity long = longitude of periastron (radians) T0 = time of periastron crossing v0 = COM velocity The times argument can be either a single float (with the velocity returned as a float) or an array of floats (with the velocity returned as a corresponding array). tau, T0 and times should be in the same units (typically days). K can use a different unit of time (typically m/s). """ fkepler.setup_Tp(tau, e, T0) if type(times)==float: c, s = fkepler.t2TA(times) # Get cos, sin of true anomaly else: c, s = fkepler.vt2TA(times) return v0 + K*cos(long)*(e+c) + K*sin(long)*s
import string from math import * from scipy import zeros, ones, Float, sum from scipy import random as r import fkepler fkepler.settol(1.e-3) def Kepler_setup(tau, e, T0, times): global cs_vals fkepler.setup(tau, e, T0) return fkepler.vt2TA(times) def Kepler0(tau, e, T0, times, cs_vals): return ones(len(times), Float) def Kepler1(tau, e, T0, times, cs_vals): return e + cs_vals[:,0] def Kepler2(tau, e, T0, times, cs_vals): return cs_vals[:,1] def phaseCurve(ofile, tau, e, T0, amps, data, n, sigma=None): """Write data for plotting a velocity curve against observations. The data are written as phases in [0,1), and the curve is written as n phases in [-.5, 1.5] and the corresponding velocities. Return chi**2 for the curve.""" # First, make the curve. dt = 2./(n-1) phases = zeros(n, Float)
import string from math import * from scipy import zeros, ones, Float, sum from scipy import random as r import fkepler fkepler.settol(1.e-3) def Kepler_setup(tau, e, T0, times): global cs_vals fkepler.setup(tau, e, T0) return fkepler.vt2TA(times) def Kepler0(tau, e, T0, times, cs_vals): return ones(len(times), Float) def Kepler1(tau, e, T0, times, cs_vals): return e + cs_vals[:, 0] def Kepler2(tau, e, T0, times, cs_vals): return cs_vals[:, 1] def phaseCurve(ofile, tau, e, T0, amps, data, n, sigma=None): """Write data for plotting a velocity curve against observations. The data are written as phases in [0,1), and the curve is written as n phases in [-.5, 1.5] and the corresponding velocities.
from numpy import sin, cos, zeros import fkepler fkepler.settol(1.e-5) def v_rad(K, tau, e, long, T0, v0, times): """ Calculate the radial (line-of-sight) velocity for a Keplerian orbit as a function of orbital parameters, COM velocity, and time. The parameters are: K = velocity amplitude tau = period e = eccentricity long = longitude of periastron (radians) T0 = time of periastron crossing v0 = COM velocity The times argument can be either a single float (with the velocity returned as a float) or an array of floats (with the velocity returned as a corresponding array). tau, T0 and times should be in the same units (typically days). K can use a different unit of time (typically m/s). """ fkepler.setup_Tp(tau, e, T0) if type(times) == float: c, s = fkepler.t2TA(times) # Get cos, sin of true anomaly else: c, s = fkepler.vt2TA(times) return v0 + K * cos(long) * (e + c) + K * sin(long) * s