Calculation of visual, spectroscopic and combined orbits in IDL
A. Tokovinin (c) 2012-2016

This distribution contains the following files:

Instruction.txt  (this file)
orbit.pro    Program code in IDL
orbitXY.pro  A version that fits X,Y instead of rho,theta
orbitT2.pro  Fit a triple star orbit
FIN379.inp   Example: combined orbit (see the data format description below)
GL765.inp    Example: combined orbit
ZetaAqr.in2  Example: triple star for orbitT2.pro

It is recommended to have the input file opened in a text editor while
running the orbit program. It can be edited and re-opened as needed. 

To start, call IDL, compile the program, and call it with one of the 
example files located in the same directory:

IDL> .r orbit
IDL> xorb, 'FIN379.inp'

The program window appears. Its functions are briefly described.

1. Buttons
----------

Open - opens file-selection dialog to load the new input file.

Reopen - reads same file from the disk

POS - plots visual orbit (positions).  Click on points to see the data
      on the screen.  Type orbplot,  /ps to save the postscript plot,
      as   suggested  by   the  hint   that  appears   after  pressing
      POS. Specify speckle=0.02  to mark differently observations with
      errors larger than 0.02.

RV - plots spectroscopic orbit. Click on primary-component points (squares) to see the data.
     Use orbplot, /ps to save the postscript plot.

Analysis - auxiliary functions to compute ephemeride, masses, or plot separation vs. time

Fit  - Fit  new orbital  elements by  Levenberg-Marquardt  method. The
      number of iterations, weighted residuals in theta, rho, RV1, RV2
      are printed, as well as total CHI2 and CHI2/N in the 4 types of data. 

Save - save new elements, data and residuals in the output *.out file.
       This   file  is   compatible  with   the  input   and   can  be
       loaded. However, it will be overwritten if saved
       again. Residuals are written in extra columns. 
  
Exit - quit the program


2. Elements
-----------

New value of  orbital elements can be entered in  the fields, they are
accepted after <CR> (Enter)

The toggle button after each element shows if it is fitted (1) or fixed (0).

The numbers to the right  of the buttons are element errors calculated
during the fit (initially zero, always zero for fixed elements)

3. Data format
--------------

The data  format is same  as in the  old FORTRAN program  ORBITX which
worked  under   DOS.   The  first   line  contains  the   object  name
(arbitrary), the  next 2 lines contain  RA and DEC in  the hh.mmss and
dd.mmss format (used only for precession correction in angle).

The following 10  lines list orbital elements as  (tag, value) on each
line. The  tags are used to  recognize the elements and  should not be
modified.   For irrelevant  elements (such  as K1,  K2, V0  for visual
orbits)  and/or   fixed  elements,  the  tags  are   preceded  by  *
(asterisk).  Missing elements receive zero values.

Object:	Name of the object
R.A.:   Right ascension in the form HH.MMSS, e.g. 19.2348 for 19h 23m 48s
Dec.:	Declination, DD.MMSS. Coordinates are used for the precession corr.
P:	Initial value of the orbital period in years or days

T:  Epoch of passage  through periastron  in years  or in  Julian Days
	minus 2400000, e.g. 46789.378. If  it is greated that 3000, it
	is assumed that the epoch  and period are days, otherwise they
	are assumed to be in years.
e:	Eccentricity
a:	Semi-major axis in arcseconds (irrelevant for SBs)
W:	Position angle of the line of nodes in degrees (irrelevant for SBs)
w:	Longitude of the periastron in degrees. According to the conventions
	for VBs, it is counted from the ascending node of the SECONDARY 
	whereas for SBs it is counted from the ascending node of the PRIMARY.
        In combined spectroscopic/visual orbits, the spectroscopic
        convention is be adopted.
i:	Inclination of the orbit in degrees (irrelevant for SBs)
K1:     Semi-amplitude of the velocity of the primary in km/s
K2:	Semi-amplitude of the secondary in km/s, irrelevant for SB1s
V0:	Velocity of the center of mass in km/s.

Symbol  'C' in  the first character of a line means  comment,  all such
lines are ignored. 

The positional data are in the form (time, theta, rho, error, ..., I1,
...) where ...  means possible extra columns. The tag  'I1' is used to
recognize positional measurements. Other numbers or text can be placed
in (...), provided that the text does not contain 'I1',

The  radial velocity  data  can be  in  two forms:  

- (time, RV, error,  ...  Va, ...)  where Va  marks the primary component, Vb
marks the secondary. Lines with the V: tag are ignored.

- (time, RV1, err1, RV2, Err2, ... V2, ...) for SB2 (both velocities).

It is possible  to mix time in years and in  Julian days (with 2400000
always subtracted) in the same file. The unit of time (JD or years) is
defined by the value of the T0 element: JD if T0>3000, years otherwise.

The  observational errors  are used  to calculate  weight.   Set large
errors to effectively eliminate poor data from the fit.

4. Other versions of the code
-----------------------------

orbitXY.pro  fits   rectangular  coordinatex  X,Y   instead  of  polar
coordinates  rho,theta to  avoid angle  discontinuity at  0/360deg. It
works exactly as orbit.pro.

orbitT2.pro is an experimental version to fit a triple star, with both
astrometric and  resolved observations of the inner  pair. The example
of input file for this program is ZetaAqr.in2.  

--------------- end --------------------------------------------------

