From 10c4cdda49e8e8ee580dce09b6a7c5da72cc6c00 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Mon, 31 Aug 2020 13:12:22 +0200 Subject: [PATCH] Move utils to thesis --- .../leo-input-fstream-container.cc | 0 .../leo-input-fstream-container.h | 0 utils/.gitignore | 1 - utils/geo2vec.py | 49 --------------- utils/import-tle.sh | 30 --------- utils/plot-airports.gnuplot | 13 ---- utils/plot-satellites.gnuplot | 31 ---------- utils/randgeo.sh | 3 - utils/requirements.txt | 1 - utils/tle2wps.py | 61 ------------------- wscript | 4 +- 11 files changed, 2 insertions(+), 191 deletions(-) rename {utils => helper}/leo-input-fstream-container.cc (100%) rename {utils => helper}/leo-input-fstream-container.h (100%) delete mode 100644 utils/.gitignore delete mode 100755 utils/geo2vec.py delete mode 100755 utils/import-tle.sh delete mode 100644 utils/plot-airports.gnuplot delete mode 100644 utils/plot-satellites.gnuplot delete mode 100755 utils/randgeo.sh delete mode 100644 utils/requirements.txt delete mode 100755 utils/tle2wps.py diff --git a/utils/leo-input-fstream-container.cc b/helper/leo-input-fstream-container.cc similarity index 100% rename from utils/leo-input-fstream-container.cc rename to helper/leo-input-fstream-container.cc diff --git a/utils/leo-input-fstream-container.h b/helper/leo-input-fstream-container.h similarity index 100% rename from utils/leo-input-fstream-container.h rename to helper/leo-input-fstream-container.h diff --git a/utils/.gitignore b/utils/.gitignore deleted file mode 100644 index 21d0b89..0000000 --- a/utils/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.venv/ diff --git a/utils/geo2vec.py b/utils/geo2vec.py deleted file mode 100755 index 7cf7a31..0000000 --- a/utils/geo2vec.py +++ /dev/null @@ -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])) - diff --git a/utils/import-tle.sh b/utils/import-tle.sh deleted file mode 100755 index 4162d9e..0000000 --- a/utils/import-tle.sh +++ /dev/null @@ -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 diff --git a/utils/plot-airports.gnuplot b/utils/plot-airports.gnuplot deleted file mode 100644 index 255e140..0000000 --- a/utils/plot-airports.gnuplot +++ /dev/null @@ -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 diff --git a/utils/plot-satellites.gnuplot b/utils/plot-satellites.gnuplot deleted file mode 100644 index cc35ed1..0000000 --- a/utils/plot-satellites.gnuplot +++ /dev/null @@ -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) - -} diff --git a/utils/randgeo.sh b/utils/randgeo.sh deleted file mode 100755 index 7fc0d3a..0000000 --- a/utils/randgeo.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -shuf $1 | head -n $2 | ./geo2vec.py diff --git a/utils/requirements.txt b/utils/requirements.txt deleted file mode 100644 index 332114f..0000000 --- a/utils/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -skyfield==1.26 diff --git a/utils/tle2wps.py b/utils/tle2wps.py deleted file mode 100755 index 7c8cb35..0000000 --- a/utils/tle2wps.py +++ /dev/null @@ -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) - diff --git a/wscript b/wscript index 9dfd27d..53c8c80 100644 --- a/wscript +++ b/wscript @@ -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: