spinOS calculates binary orbital elements. Given a set of radial velocity measurements of a spectroscopic binary and/or relative position measurement of an astrometric binary, spinOS fits an orbital model by minimizing a chi squared metric. You need to supply an initial guess for the parameters that define the binary orbit:
- p: the period of the binary
- e: the eccentricity of the orbit
- i: the inclination of the orbit (with respect to the plane of the sky)
- omega: the argument of periastron of the secondary, with respect to its ascending node
- Omega: the longitude of the ascending node of the secondary, measured East from North
- t0: the time of periastron passage
- d: the distance to the system
- k1: the semiamplitude of the RV curve of the primary
- k2: the semiamplitude of the RV curve of the secondary
- gamma1: the peculiar velocity of the primary
- gamma2: the peculiar velocity of the secondary
- mt: the total mass of the system
This package provides a GUI to easily visualize your data. The GUI allows for easy plotting of data and models, as well as minimization of the model to your supplied data. The program then gives a best fit value for the parameters itemized above.
spinOS is written in Python 3. It is recommended to use a virtual environment to install the dependencies. The supplied yaml file can be used to configure your python environment, e.g. run
conda env create -f environment.yaml -n spinOS
to create a conda environment called spinOS. Then activate the environment with
conda activate spinOS
Next, spinOS uses C compiled code for the calculation of Kepler's equation. To compile the C code, run
python setup.py build_ext
This will create the shared library that is automatically loaded. This step is only necessary once, and the shared library will be used in subsequent runs of spinOS. It is strongly recommended, as the C code is significantly faster than the pure Python implementation (up to ~100x faster).
To use the GUI, simply run:
python spinOS.py [dir]
In the GUI data tab, put your working directory, where all your data files are relative to where you launched spinOS from. You can select files to be loaded in, or add Datasets and data entries manually in the respective tabs of the Data Manager. When loading in data, see formatting below.
In the System/parameters tab, you can play with the systemic parameters, and see the changes of the orbit on the plots (see below) by pressing 'refresh'. With the checkbuttons, indicate which parameters should be minimized. Below, some inferred parameters of the model are presented. Use the load guesses button to load all guesses from your guessfile indicated on top. The save buttons save either the guesses or fitted parameters to files you specify in the prompt (warning: may overwrite!)
In the minimize tab, you can apply a custom weighting of the astrometric data to the chi-squared value (typically, you would want to increase this if you trust astrometry better than spectroscopy, and have only few astrometric measurements; this is however, a frequentist approach to statistical fitting). You can minimize the model to the selected data with the minimize button, selecting a method first. Levenberg-Marquardt does local non-linear least squares minimization, while basinhopping tries to find a global minimum by iterating local Nelder-Mead simplex minimizations. Note that basinhopping can take considerably longer with lots of free parameters. After minimization, errors are estimated as the diagonal elements of the correlation matrix.
To better estimate uncertainties (taking into account correlations), you can go to the MCMC tab. Starting from a local minimum with estimated errors, MCMC recreates the parameters' posterior distributions using an ensemble sampler. When MCMC sampling, the first burn (default = 100) samples are discarded, and then only 1 every thin (default = 1) samples are retained in the final results. The philosophy behind this is that the underlying sampler does not draw independent samples from the posterior distribution, it first needs to 'settle' to the maximum likelihood region (hence the burn-in), and then a random walk will only yield independent results twice every time the characteristic autocorrelation time has passed (hence the thinning). These parameters are difficult to estimate beforehand. While a burn-in is necessary, thinning is not needed, since the reported errors are calculated from the quantiles of the chain's samples. Thinning would only be needed for visualization purposes, to reduce the number of points in the corner plot. The MCMC tab also allows for the use of gaussian priors on the parameters (e.g., for implementing constraints from other missions/datasets not modeled in spinOS). A corner plot button is provided, but may not produce exactly the plot you want or need. To properly use the MCMC results, save the chains to a file using the save button, and post-process the chains with your own scripts. Since it is hard to judge beforehand how one wants to visualize the results, this is left to the user. The chains are saved to an HDF5 file, which can be read in with the h5py package. use
import h5py
results = h5py.File('your_file.hdf5')
results.keys() # to see the datasets in the fileFinally, since V3.0.0, MCMC is reimplemented in a separate tab, and satisfies Bayesian statistics, removing the need to introduce statistical weights to the chi-squared metric, which is a frequentist approach (as was implemented in spinOS v2.X).
In the plot controls tab, various checkbuttons are provided to plot certain elements on the plot windows on the right. The phase slider allows for overplotting a dot at the phase indicated (for illustrative purposes, eg, for visually connecting the apparent orbit with the RV plot).
This application expects the data to be in the following format: All data files should be plain text files, formatted as: for RV data:
JD(days) RV(km/s) error_on_RV(km/s)
e.g.:
45000 25.1 2.1
45860 -4.2 1.1
etc...
for AS data: either (set button E/N):
JD(days) E_separation(mas) N_separation(mas) semimajor_ax_errorellipse(mas) semiminor_ax_errorellipse(mas) angle_E_of_N_of_major_ax(deg)
e.g.:
48000 -2.5 2.4 0.1 0.8 60
48050 2.1 8.4 0.4 0.5 90
etc...
or (set button Sep/PA):
JD(days) separation(mas) PA(deg) semimajor_ax_errorellipse(mas) semiminor_ax_errorellipse(mas) angle_E_of_N_of_major_ax(deg)
e.g.:
48000 3.5 316 0.1 0.8 60
48050 8.7 76 0.4 0.5 90
etc...
for the guess file, format should be e.g.:
e 0.648 True
i 86.53 True
omega 211.0 True
Omega 67.3 True
t0 56547.1 True
k1 31.0 False
k2 52.0 True
p 3252.0 True
gamma1 15.8 False
gamma2 5.6 False
mt 30.0 True
All eleven parameters should be guessed if you load in guesses. (for their meaning see above)
A LaTeX distribution that allows matplotlib.rc(usetex=True)
the supplied yaml file can be used to configure your python environment
e.g. run
conda create -n spinOS -f environment.yaml
Matthias FABRY
Department of Astrophysics and Planetary Science, Villanova University, PA, USA
7 October 2026
Copyright Matthias Fabry. This software is released under the GNU GPL-3.0-or-later License, which is attached to this repository
We thank the authors of scipy, lmfit, corner for the development of their respective packages.