Move utils to thesis

This commit is contained in:
Tim Schubert 2020-08-31 13:12:22 +02:00
parent ab0fcddb3e
commit 10c4cdda49
11 changed files with 2 additions and 191 deletions

1
utils/.gitignore vendored
View file

@ -1 +0,0 @@
.venv/

View file

@ -1,49 +0,0 @@
#!/usr/bin/env python3
import logging as log
import fileinput
from sys import argv
from skyfield.api import Topos, load
log.basicConfig(level=log.DEBUG)
"""
Converts pairs of format `name longitute latitude` to `ns3::Vector` format in ITRF frame
See `ns3::Vector::operator >>`
"""
def isogeo():
for i in range(-60,60,5):
for j in range(-180,180,5):
yield "foo,%f,%f" % (i, j)
"""
Stores the vector data
"""
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __repr__(self):
return "%f:%f:%f" % (self.x, self.y, self.z)
if __name__ == "__main__":
if len(argv) > 1:
if argv[1] == "-r":
f = isogeo()
else:
f = fileinput.input(argv[1])
else:
f = fileinput.input()
for line in f:
_, lat, lng = line.split(',')
location = Topos(float(lat), float(lng))
d = location.itrf_xyz().m
print(Vector(d[0], d[1], d[2]))

View file

@ -1,30 +0,0 @@
#!/bin/sh
set -u
set -e
search=$1
# Get the ids of sats matching the search term
if [ ! -f ids.txt ]
then
curl https://celestrak.com/pub/satcat.txt | grep "$search" | cut -b14-18 > ids.txt
fi
# Download TLE data for each sat
while read id
do
if [ ! -f $id.txt ]
then
wget "https://celestrak.com/satcat/tle.php?CATNR=$id" -O $id.txt
fi
# 6000 s ~ 95 min ~ 1 orbital period
done < ids.txt
while read id
do
if [ ! -f $id.waypoints ]
then
./tle2wps.py $id.txt 2020 08 28 6000 > $id.waypoints
fi
done < ids.txt

View file

@ -1,13 +0,0 @@
set datafile separator comma
set key autotitle columnheader
set xrange [-180:180]
set yrange [-90:90]
set grid
set size ratio -1
set xlabel "Latitude"
set ylabel "Longitude"
set term pdfcairo font "Nexus,12" size 20cm,10cm
set output 'airports.pdf'
plot '../data/ground-stations/airports.csv' using 3:2

View file

@ -1,31 +0,0 @@
set datafile separator ",:"
set key autotitle columnheader
set terminal gif animate size 2000,2000
set output 'output.gif'
unset xtics
unset ytics
unset ztics
unset border
set xrange [-8e6:8e6]
set yrange [-8e6:8e6]
set zrange [-8e6:8e6]
set parametric
set isosamples 20,20
unset key
unset title
set hidden3d
# number of nodes per time slot
EARTH=6.370e6
sats=ARG1
ground=ARG2
numsats=ARG3
numsamples=ARG4
do for [j=0:numsamples-1] {
splot [-pi:pi][-pi/2:pi/2] EARTH*cos(u)*cos(v), EARTH*sin(u)*cos(v), EARTH*sin(v), \
ground using 1:2:3 lt rgb "green", \
sats using 3:4:5:2 every ::(j*numsats)::((j+1)*numsats)
}

View file

@ -1,3 +0,0 @@
#!/bin/sh
shuf $1 | head -n $2 | ./geo2vec.py

View file

@ -1 +0,0 @@
skyfield==1.26

View file

@ -1,61 +0,0 @@
#!/usr/bin/env python3
"""
Creates a stream of waypoints using SGP4 and two-line element (TLE) information
Up-to-date TLEs can be obtained from [Celestrak](https://celestrak.com/satcat/search.php)
"""
import logging as log
import argparse
from datetime import datetime
from skyfield.api import EarthSatellite, Time, load, utc
log.basicConfig(level=log.DEBUG)
"""
Class for exporting `ns3::Waypoint` in its own serialized format.
See `ns3::Waypoint::operator <<`
"""
class Waypoint:
def __init__(self, time, x, y, z):
self.time = time
self.x = x
self.y = y
self.z = z
def __repr__(self):
return("%fs $ %f:%f:%f" % (self.time, self.x, self.y, self.z))
"""
Use Skyfield to generate the waypoints
"""
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('tle', type=str, help='Two-line element data')
parser.add_argument('year', type=int, help='year to start at')
parser.add_argument('month', type=int, help='month to start at')
parser.add_argument('day', type=int, help='day to start at')
parser.add_argument('duration', type=int, help='duration in seconds')
args = parser.parse_args()
ts = load.timescale(builtin=True)
sats = load.tle_file(args.tle)
log.info("Loaded %d satellites" % len(sats))
duration = args.duration
for sat in sats:
log.info("Generating waypoints for %s" % sat.name)
# skyfield will automatically overflow the seconds and produce the next correct second
t_start = ts.utc(year=args.year, month=args.month, day=args.day)
for t in ts.utc(year=args.year, month=args.month, day=args.day, second=range(1, duration, 1)):
geocentric = sat.at(t)
t_rel = (t.tai - t_start.tai) * 10**5
d = geocentric.itrf_xyz().m
wp = Waypoint(t_rel, d[0], d[1], d[2])
print(wp)

View file

@ -12,6 +12,7 @@ def build(bld):
'helper/arp-cache-helper.cc',
'helper/isl-helper.cc',
'helper/leo-channel-helper.cc',
'helper/leo-input-fstream-container.cc',
'helper/leo-orbit-node-helper.cc',
'helper/nd-cache-helper.cc',
'helper/ground-node-helper.cc',
@ -29,7 +30,6 @@ def build(bld):
'model/mock-channel.cc',
'model/isl-mock-channel.cc',
'model/isl-propagation-loss-model.cc',
'utils/leo-input-fstream-container.cc',
]
module_test = bld.create_ns3_module_test_library('leo')
@ -55,6 +55,7 @@ def build(bld):
'helper/arp-cache-helper.h',
'helper/isl-helper.h',
'helper/leo-channel-helper.h',
'helper/leo-input-fstream-container.h',
'helper/leo-orbit-node-helper.h',
'helper/nd-cache-helper.h',
'helper/ground-node-helper.h',
@ -75,7 +76,6 @@ def build(bld):
'model/mock-channel.h',
'model/isl-mock-channel.h',
'model/isl-propagation-loss-model.h',
'utils/leo-input-fstream-container.h',
]
if bld.env.ENABLE_EXAMPLES: