Celestia/Star Database Format

See also this page on GitHub.

The stars.dat file contains information about stars in a binary format. The byte order is little-endian. The format is as follows:

A 14-byte file header:

8-byte character string   "CELSTARS"
2-byte unsigned integer   version number = 0x0100
4-byte unsigned integer   number of records in file

Followed by records of length 20 bytes of the form:

4-byte unsigned integer   Hipparcos catalog number (=0 for Sol)
4-byte floating point     x-coordinate in light years
4-byte floating point     y-coordinate in light years
4-byte floating point     z-coordinate in light years
2-byte signed integer     absolute magnitude * 256
2-byte unsigned integer   spectral class

The x, y and z coordinates are calculated as follows

where d is the distance in light years, θ = RA + 180°, φ = Dec − 90° and ε = 23.4392911°.

Spectral class

edit

The spectral class is written as four hexadecimal digits 0xKTSL.

The K digit represents the kind of object, these are:

K=0   normal star
K=1   white dwarf
K=2   neutron star
K=3   black hole

The T digit represents the spectral type. It has different meanings depending on whether the object is a normal star or a white dwarf. This digit is ignored when the object is a neutron star or black hole.

      normal stars            white dwarfs
-----------------------------------------------------
T=0   spectral type O         spectral type DA
T=1   spectral type B         spectral type DB
T=2   spectral type A         spectral type DC
T=3   spectral type F         spectral type DO
T=4   spectral type G         spectral type DQ
T=5   spectral type K         spectral type DZ
T=6   spectral type M         unknown spectral type D
T=7   spectral type R         spectral type DX
T=8   spectral type S
T=9   spectral type N
T=a   spectral type WC
T=b   spectral type WN
T=c   unknown spectral type
T=d   spectral type L
T=e   spectral type T
T=f   spectral type C

The S digit represents the spectral subtype. This digit is ignored for neutron stars and black holes.

S=0   spectral subtype 0
S=1   spectral subtype 1
S=2   spectral subtype 2
S=3   spectral subtype 3
S=4   spectral subtype 4
S=5   spectral subtype 5
S=6   spectral subtype 6
S=7   spectral subtype 7
S=8   spectral subtype 8
S=9   spectral subtype 9
S=a   unknown spectral subtype

The L digit represents the luminosity class. This digit is only relevant for normal stars.

L=0   luminosity class Ia-O
L=1   luminosity class Ia
L=2   luminosity class Ib
L=3   luminosity class II
L=4   luminosity class III
L=5   luminosity class IV
L=6   luminosity class V
L=7   luminosity class VI (also written as prefix sd)
L=8   unknown luminosity class

Thus a star of spectral type G2V uses the number 0x0426.

Old format

edit

Prior to version 1.4.0, Celestia used a slightly different stars.dat format.

A 4-byte file header of the form:

4-byte unsigned integer   number of records

Followed by records of length 25:

4-byte unsigned integer   Hipparcos catalog number
4-byte unsigned integer   HD catalog number
4-byte floating point     Right Ascension in degrees
4-byte floating point     Declination in degrees
4-byte floating point     Parallax (in milliarcseconds?)
2-byte signed integer     Apparent magnitude * 256
2-byte unsigned integer   Spectral class
1-byte unsigned integer   Parallax error * 200

Note that for current versions of Celestia, the HD catalog numbers are stored in the hdxindex.dat file.