BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class StellarOrbitModel( NonLinearModel )[source]

Model for the radial velocity variations of a star caused by a orbiting planet.

The algorithm was taken from Cory Boule etal. (2017) J. of Double Star Observations Vol 13 p.189. Boule

par symbol description limits comment
p0 e eccentricity of the elliptic orbit 0<e<1 0 = circular orbit
p1 a semi major axis a>0
p2 P period of the orbit P>0
p3 T phase since periastron passage 0<T<2π
p4 i inclination of the orbit wrt sky 0<i<π 0 = pi = in sky plane
p5 Ω position angle from North
to the line of nodes 0<Ω<π 0 = north
p6 ω longitude from the node (in p5)
to the periastron 0<ω<2π 0 = periastron in node

Due to the fact that the orbit can be mirrored in the sky plane, one of p5 or p6 has to be limited to [0,pi] and the other to [0,2pi]. However it could be preferred to keep the inclination between [0,pi] as it keeps the ascending node at the same place. All parameter from 3 on, are cyclic and would profit from a circular prior.

The parameters are initialized at [0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]. It is a non-linear model.

This class uses [Kepplers2ndLaw to find the radius and anomaly.](Kepplers2ndLaw to find the radius and anomaly.)

Attributes

  • keppler : Kepplers2ndLaw()
         to calculate the radius and true anomaly
  • ndout : int
         The number of outputs is 2. Use MultipleOutputProblem.
  • spherical : bool
         if True return the results in spherical coordinates, as [rho,phi]
         otherwise return euclidian coordinates [x,y]
         Angles are measured counterclockwise from north to east
         North is Down (-y) and East is to the Right (+x)
  • cyclic : { 1 : 2*pi }
         Only if spherical, indicating that result[:,1] is cyclic.
  • toRect : Tools.toRect
         Return (x,y) coordinates from (rho,phi). See Tools
  • toSpher : Tools.toSpher
         Return (rho,phi) coordinates from (x,y). See Tools

Attributes from Model
     npchain, parameters, stdevs, xUnit, yUnit

Attributes from FixedModel
     npmax, fixed, parlist, mlist

Attributes from BaseModel
     npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames

Examples

sm = StellarOrbitModel( )
print( sm.npars )
7

StellarOrbitModel( copy=None, spherical=True, **kwargs ) [source]

Radial velocity model.

Number of parameters is 5

Parameters

  • copy : StellarOrbitModel
         model to copy
  • spherical : bool (True)
         produce output in sperical coordinates (rho,phi)
         otherwise in rectilinear coordinates (x,y)
  • fixed : dictionary of {int:float}
         int list if parameters to fix permanently. Default None.
         float list of values for the fixed parameters.
         Attribute fixed can only be set in the constructor.

copy( spherical=None ) [source]
Copy method.

Parameters

  • spherical : None or bool
         return spherical (True) or rectangular (False) coordinates

baseResult( xdata, params ) [source]
Returns
the result of the model function as a 2-d array containing [rho,phi] when spherical is true else [x,y]

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters.

The parameters are explained in the [#StellarOrbitModel constructor.](#StellarOrbitModel constructor.)

getOrbit( xdata, params, d3=False ) [source]
Calculate the 2 (or 3)-dim result of the model function as a tuple of arrays

The pertaining rho, phi, (theta) are available from self.

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters.
  • d3 : bool (False)
         return 3 dim result if true else 2 dim

The parameters are explained in the [#StellarOrbitModel constructor.](#StellarOrbitModel constructor.)

Returns

  • x, y(, z) : tuple of arrays
         containing the rectangular coordinates

baseDerivative( xdata, params, d3=False ) [source]
Returns the derivative [df1/dt, df2/dt] of the model function. Where f1 = rho if spherical else x
       f2 = phi if spherical else y and t is time, input data, here aliased to 'xdata'

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters.
  • d3 : boolean
         when True also return df3/dt in the array
         f3 is theta if spherical else z

The parameters are explained in the [#StellarOrbitModel constructor.](#StellarOrbitModel constructor.)

basePartial( xdata, params, parlist=None, d3=False ) [source]
Returns the partials at the xdata value.

Parameters

  • xdata : array_like
         values at which to calculate the result
  • params : array_like
         values for the parameters. (not used for linear models)
  • parlist : array_like
         list of indices active parameters (or None for all)
  • d3 : bool
         if True also return derivatives of theta cq z

The parameters are explained in the [#StellarOrbitModel constructor.](#StellarOrbitModel constructor.)

baseName( ) [source]
Returns a string representation of the model.

baseParameterUnit( k ) [source]
Return the unit of a parameter. (TBC)

Parameters

  • k : int
         the kth parameter.

convertParameters( param, stdevs=None, year=2000 ) [source]
Return time of periastron (p3) in years after year and inclination (p4),
     the position angle from North to the line of nodes (p5) and
     the longitude from line of nodes to periastron (p6) in degrees

Parameters

  • param : array
         parameters to be converted
  • stdevs : array
         standard deviations to be converted
  • year : float
         return the first periastron passage after year

Returns
converted parameters if stdevs is None converted (parameters, stdevs) else

plotOrbit( par, npoint=361, xdata=None, ydata=None, plot=None, color='k', ls='-' ) [source]
Plot the orbit in N points, a forward pointing arrow at T = 0, the line to the periastron and an extended line of nodes.

if ydata is present, plot the datapoints. If also xdata is present, plot the connecting lines too.

Parameters

  • par : array
         parameter of the model
  • npoint : int
         number of points in the orbit
  • xdata : array
         array of times at which the data are measured
  • ydata : 2d array
         array of [x,y] pairs representing the data
  • plot : None or pyplot
         None make a self standing plot and show it
         pyplot operate within thid plot; do not show
  • color, ls : color and linestyle
         for the plot
Methods inherited from NonLinearModel
Methods inherited from Model
Methods inherited from FixedModel
Methods inherited from BaseModel