celestia-gnss/tle2ssc

85 lines
2.2 KiB
Plaintext
Raw Normal View History

2022-05-21 12:39:21 -06:00
#!/usr/bin/python3
# tle2ssc
# Convert a TLE into an .ssc file for Celestia
#
# Usage:
# tle2ssc [filename]
# Example:
# tle2ssc foo-tle.txt
2022-05-21 13:51:34 -06:00
import os
os.environ['PPP_CONFIG_DIR'] = './config/'
from pyorbital import tlefile
from pyorbital import orbital
from pyorbital.orbital import Orbital
from datetime import datetime
now = datetime.utcnow()
2022-05-21 14:30:57 -06:00
tle = tlefile.read('GSAT0101', 'extras/galileo-gnss/galileo.txt')
2022-05-21 13:51:34 -06:00
#print(pyorbital.tlefile.SATELLITES)
#print(orbital.Orbital.get_position)
satname=tle.platform
satline1=tle.line1
satline2=tle.line2
satinclination=tle.inclination
2022-05-21 14:30:57 -06:00
# Fail:
#orb = Orbital(satname)
2022-05-21 13:51:34 -06:00
2022-05-21 14:30:57 -06:00
#print('Satellite name: ', satname)
#print('Line one of TLE:')
#print(satline1)
#print('Line two of TLE:')
#print(satline2)
#print('Inclination: ', satinclination)
# Create SSC
# From TLE:
# GSAT0101 (PRN E11)
# 1 37846U 11060A 22140.09549104 -.00000093 00000+0 00000+0 0 9998
# 2 37846 56.9858 22.1062 0004117 28.0726 331.9949 1.70474933 65739
#
# Satellite name: GSAT0101
# Satellite number: 37846U
# Satellite number: 37846
# International designator: 11060A
# Inclination: 56.9858
# Epoch year and Julian day fraction: 22140.09549104
# Right ascension of ascending node: 22.1062
# Eccentricity: 0004117
# First derivative of mean motion or ballistic coefficient: -.00000093
# Argument of perigee: 28.0726
# Second derivative of mean motion: 00000+0
# Mean anomaly: 331.9949
# Drag term or radiation pressure coefficient: 00000+0
# Mean motion: 1.70474933
# Ephemeris type: 0
# Element number and checksum: 9998
# Revolution number at epoch and checksum: 65739
print('"', satname, '" ','"Sol/Earth" {',sep="")
print(' Class "spacecraft"')
print(' # Mesh "foo.3ds"')
print(' radius 0.005')
print()
print(' EllipticalOrbit {')
print(' Epoch 2459718.94467728')
print(' Period 0.49859567')
print(' SemiMajorAxis 26560.345')
print(' Eccentricity 0.0057297')
print(' Inclination', satinclination)
print(' AscendingNode 156.8049')
print(' ArgOfPericenter 51.2220')
print(' MeanAnomaly 309.3262')
print(' }')
print(' Obliquity 55.5062')
print(' EquatorAscendingNode 156.8049')
print(' RotationOffset 80.2289')
print(' # Orientation [ ]')
print('}')
2022-05-21 13:51:34 -06:00