Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fit Your First Model

You have a night of pointing data in an INDAT file and you want a model you can load into your mount software. This page fits the six basic equatorial terms to warp-astron.dat, reads the result, finds the worst star, and saves the model as an OUTMOD file. It takes a few minutes, first in the pointing shell and then in Rust.

What you need

  • The pointing shell, built with the cli feature:
cargo install --path celestial-pointing --features cli
  • An INDAT file. The examples use warp-astron.dat from celestial-pointing/tests/data: 98 stars observed from latitude +39° on 2026 April 21.

An INDAT file starts with a caption, option lines and a run record, followed by one line per star. After a ! comment line, warp-astron.dat begins:

ASCOM Mount
:NODA
:EQUAT
+39 00 26 2026 4 21 20.55 761.74 228.00  0.60 0.5500 0.0065
14 36 55.4451 +72 03 24.120 02 50 45.3800 +105 57 19.273  10 22.219
15 21 01.1992 +71 44 28.166 03 34 46.4042 +106 16 25.098  10 23.341
05 38 55.5074 +79 14 20.514 05 40 49.7057 +77 16 22.670  10 24.698

The run record gives the site latitude, the date and the weather: temperature in °C, pressure in hPa, height in metres, relative humidity, wavelength in µm and lapse rate in K/m. Each star line has the star’s apparent RA and Dec, the mount’s RA and Dec as its encoders report them, and the local sidereal time in hours and minutes. A mount declination beyond ±90°, such as +105 57 19, means the telescope was on the far side of the pier, beyond the pole.

Fit the six basic terms

Start the shell in line mode and give it four commands:

$ pointing --plain
*INDAT warp-astron.dat
...
*USE IH ID NP CH ME MA
*FIT

       coeff       change     value    sigma

  1     IH      +8512.559  +8512.56   14.883
  2     ID      +7206.960  +7206.96   18.313
  3     NP        -22.682    -22.68   30.817
  4     CH      -1234.764  -1234.76   16.706
  5     ME       -133.523   -133.52   14.296
  6     MA        +64.384    +64.38   25.283

Sky RMS = 109.11
Popn SD = 112.61

Observation #61 is a weak outlier candidate.

INDAT reads the file and prints it back. USE adds terms to the model at zero, and FIT fits them by least squares. Without --plain, pointing opens a full-screen UI that runs the same commands and adds plots beside them.

Read the result

Each row gives a term’s change in this fit, its value and its sigma, all in arcseconds. A term is measured when its value is several times its sigma. Here IH, ID, CH and ME are many sigma from zero. MA is at 2.5 sigma, so it’s probably real. NP is smaller than its sigma, so this night’s data can’t tell it from zero.

IH and ID are over two degrees. The index terms take up the zero points of the encoders, however far off they are, so a mount whose encoders were never synced to the sky shows large index terms and still fits well.

Sky RMS is the RMS distance on the sky between where the model says each star is and where it was, 109 arcseconds here. Popn SD, the population standard deviation or PSD, is the same quantity corrected for the number of terms fitted. It grows when you add a term that doesn’t earn its place, so it’s the number to watch when you compare models.

A Sky RMS of 109 arcseconds means the six basic terms leave a lot unexplained. Pointing Terms shows how to find the pattern that’s left, and Automodel and Vetting searches for it automatically.

Find the worst star

The last line of the fit names the observation least like the others. SLIST lists each star’s residuals, and a number after it leaves out the stars below that many arcseconds:

*SLIST 200

   #   HA          Dec            Az     ZD       dX       dD       dS       dZ       dR

  61   +00 15 46.7 -29 47 22  183.67  68.89  -146.01  -152.43   154.40   143.87   211.06

RMS of 98 unmasked observations                57.73    92.59                     109.11
Observations with dR below 200.00" are not listed

Star 61 was low in the south, 69° from the zenith, and missed by 211 arcseconds. “Weak outlier candidate” means a miss that large happens by chance in 1 to 5 percent of typical stars, so it isn’t evidence of a bad observation by itself. To try the fit without it, type MASK 61 and FIT again. UNMASK 61 puts it back. The Command Shell has the full table of outlier grades.

Save the model

OUTMOD writes the model and the statistics of the last fit:

*OUTMOD warp.mod
*END
ASCOM Mount
T   98 109.1074   42.095  -0.0498
  IH      +8512.5593    14.88251
  ID      +7206.9603    18.31300
  NP        -22.6823    30.81694
  CH      -1234.7643    16.70552
  ME       -133.5232    14.29577
  MA        +64.3841    25.28287
END

The first line is the INDAT caption. The statistics record holds the fit method, the number of observations, the Sky RMS, and the refraction constants A and B in arcseconds that the fit used. Each term follows with its value and sigma. A fixed term is marked = and has no sigma.

INMOD warp.mod reads the model back into the shell. The file holds the terms and not the mask, so mask the same stars again before you refit.

Fit from Rust

The same fit in a program reads the file, reduces each star to an observed hour angle and declination, and fits the model:

use std::path::Path;

use celestial_core::constants::ARCSEC_TO_RAD;
use celestial_pointing::astrometry::{RefractionModelKind, RunRefraction};
use celestial_pointing::fit::{fit, FitOptions};
use celestial_pointing::model::{model_from_names, Model};
use celestial_pointing::observation::ObservationSet;
use celestial_pointing::outmod::{format_outmod, OutmodFile};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let observations = ObservationSet::read_indat(
        Path::new("warp-astron.dat"),
        RunRefraction::FromWeather(RefractionModelKind::Ciddor),
    )?;
    let reduced = observations.reduce()?;
    let start = Model::new(model_from_names(&["IH", "ID", "NP", "CH", "ME", "MA"]))?;
    let outcome = fit(&reduced, &start, &FitOptions::default())?;

    let outmod = OutmodFile {
        caption: observations.caption.clone(),
        method: "T".to_string(),
        count: outcome.residual_x.len(),
        rms: outcome.rms,
        refraction_a: observations.refraction.a / ARCSEC_TO_RAD,
        refraction_b: observations.refraction.b / ARCSEC_TO_RAD,
        terms: outcome.model.terms().to_vec(),
        sampled_psd: None,
    };
    std::fs::write("warp.mod", format_outmod(&outmod)?)?;
    print!("{}", format_outmod(&outmod)?);
    Ok(())
}

It prints the same file the shell wrote. read_indat computes the refraction constants from the weather in the run record with the Ciddor model. RunRefraction::Constants takes them directly instead, for a file without weather. outcome.model holds the fitted terms, and outcome.rms and outcome.psd the two statistics. The library API is being reshaped, so expect these names to change.

Next steps