1
0
Fork 0
sattools/src/tleupdate

81 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Check if TLE directory exists
if [ ! -d $ST_TLEDIR ]; then
mkdir -p $ST_TLEDIR
fi
# Goto TLE dir
cd $ST_TLEDIR
# Get date
DATE=`date +%Y%m%d_%H%M%S`
# Get space-track catalog
if [[ ! -z "${ST_LOGIN}" ]]; then
# Get cookie
wget --post-data=$ST_LOGIN --cookies=on --keep-session-cookies --save-cookies=/tmp/cookies.txt 'https://www.space-track.org/ajaxauth/login' -o /tmp/stget.log
# Get data
wget --keep-session-cookies --load-cookies=/tmp/cookies.txt 'https://www.space-track.org/basicspacedata/query/class/tle_latest/ORDINAL/1/EPOCH/%3Enow-30/format/3le' -O catalog.tle
dos2unix catalog.tle
# Fix missing leading zeros
sed -i -e "s/^1 /1 0000/g" -e "s/^2 /2 0000/g" -e "s/^1 /1 000/g" -e "s/^2 /2 000/g" -e "s/^1 /1 00/g" -e "s/^2 /2 00/g" -e "s/^1 /1 0/g" -e "s/^2 /2 0/g" catalog.tle
cp catalog.tle ${DATE}_catalog.txt
rm login
fi
# Get classfd
wget https://mmccants.org/tles/classfd.zip -O classfd.zip
unzip -o classfd.zip
dos2unix classfd.tle
cp classfd.tle ${DATE}_classfd.txt
rm classfd.zip
# Get inttles
wget https://mmccants.org/tles/inttles.zip -O inttles.zip
unzip -o inttles.zip
dos2unix inttles.tle
cp inttles.tle ${DATE}_inttles.txt
rm inttles.zip
# Get CALPOLY tles
wget http://mstl.atl.calpoly.edu/~ops/keps/kepler.txt -O kepler.tle
dos2unix kepler.tle
sed -i -e "s/^1 /1 0000/g" -e "s/^2 /2 0000/g" -e "s/^1 /1 000/g" -e "s/^2 /2 000/g" -e "s/^1 /1 00/g" -e "s/^2 /2 00/g" -e "s/^1 /1 0/g" -e "s/^2 /2 0/g" kepler.tle
# Get SatNOGS TLE
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=satnogs&FORMAT=tle" -O satnogs.tle
dos2unix satnogs.tle
cp satnogs.tle ${DATE}_satnogs.txt
# Get top 100 Visible TLE
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=visual&FORMAT=tle" -O visual.tle
dos2unix visual.tle
cp visual.tle ${DATE}_visual.txt
# Last 30 days launches
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=last-30-days&FORMAT=tle" -O gp.tle
dos2unix gp.tle
cp gp.tle ${DATE}_gp.txt
# Space Stations
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=stations&FORMAT=tle" -O stations.tle
dos2unix stations.tle
cp stations.tle ${DATE}_stations.txt
# Active Satellites
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=active&FORMAT=tle" -O active.tle
dos2unix active.tle
cp active.tle ${DATE}_active.txt
# GNSS
wget "https://celestrak.org/NORAD/elements/gp.php?GROUP=gnss&FORMAT=tle" -O gnss.tle
dos2unix gnss.tle
cp gnss.tle ${DATE}_gnss.txt
# Create TLE bulk file
cat active.tle classfd.tle catalog.tle gnss.tle gp.tle kepler.tle satnogs.tle stations.tle visual.tle > bulk.tle
cat bulk.tle | grep -e "^1 " | awk '{if ($2<80000 || $2>99000) printf("%05d %s\n",$2,$3)}' | sort | uniq >$ST_DATADIR/data/desig.txt