Skip to content
Snippets Groups Projects
Commit cadeee48 authored by Max Drexler's avatar Max Drexler
Browse files

generated pngs and updated README

parent 28458fff
No related branches found
No related tags found
No related merge requests found
# Satellite TLE Utils # Satellite TLE Utils
## dailySatPositions ## TLEConverter
Creates a file of the daily position of a satellite from a file of TLEs Creates a .sbpt file of the daily position of a satellite from a file of TLEs
### Synopsis ### Synopsis
**dailySatPositions.py** [OPTIONS] SAT-NAME TLE-FILE **TLEConverter.py** [OPTIONS] SAT-NAME TLE-FILE
### Description ### Description
This script will generate a list of days and subpoints in the format This script will generate a .sbpt file with the following format
{day-format} {subpoint} {satellite} {year} {day of year} {subpoint}
... ...
for every day in the time range of the TLE file.
The script takes in a file that contains a list of TLE (two line or three line elements). The script takes in a file that contains a list of TLE (two line or three line elements).
Any improperly formatted TLEs will be skipped. Any improperly formatted TLEs will be skipped.
### Options ### Options
**-o, --output=OUTPUT** **-o, --output=OUTPUT**
Change the output of the daily positions, default is stdout Change the output of the daily subpoints, default is stdout
**-f, --format=FORMAT**
Change the {day-format} of the output, must follow C standard strftime date formats
**-m, --mode=MODE** **-m, --mode=MODE**
Change the mode to open the specified output, options are w,x,wb,xb Change the mode to open the specified output, options are w,x,wb,xb
**-v, --verbose** **-v, --verbose**
Changes the verbosity of script Changes the verbosity of script
## positionVisualizer ## multiTLEConverter
Creates multiple .sbpt files based on all the .tle files in a directory
### Synopsis
**multiTLEConverter**
### Description
This script will prompt the user for a directory full of .tle files, then the output directory for the to-be-generated .sbpt files.
Then the script will go through every .tle file in the directory and prompt the user for the same of the satellite associated with that tle.
Finally, the script will generate all the .sbpt files specified by the user.
## subptVisualizer
Visualizes one or more .sbpt files using matplotlib and numpy
### Synopsis
**subptVisualizer.py** [OPTIONS]
### Description
This script will create a .png image of a .sbpt file, graphing the satellites latitude through time.
### Options
**-l, --list=LIST**
Required list of the path to one or more .sbpt files
**-v, --verbose**
Changes the verbosity of script
**-o, --outdir=OUT**
Change the directory that the .png file is generated in, default is current directory
### Dependencies
To be implemented This script requires matplotlib and numpy to run.
File moved
File moved
import sys, os, random
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import numpy as np
LEGEND_LIST = []
COLORS = ['blue', 'red', 'green', 'purple', 'orange', 'black', 'lime', 'olive', 'sienna']
# initializes the plot
def initPlot(f):
plt.ylabel('Year')
plt.xlabel('Longitude')
plt.title('Geostationary Equator Coverage')
plt.figure().set_figheight(15)
plt.ylim()
plt.xlim(-180, 180)
#plt.axis([-180, 180, 1996, 1966])
# generates the boxes on the plot for a specific location file
def genPlot(f):
global COLORS, LEGEND_LIST
print("Using file " + f)
i = random.randint(0,len(COLORS) - 1)
color = COLORS[i]
del COLORS[i]
new_patch = mpatches.Patch(color=color, label=f[f.rindex('/') + 1 : f.index("_SUBPOINTS.txt")])
LEGEND_LIST.append(new_patch)
data = np.loadtxt(f, dtype='str', skiprows=2)
x_vals = np.char.partition(data[:,2], ':')[:,0].astype('float')
heights = np.full_like(data[:,0], 1 / 365, dtype = 'float')
widths = np.full_like(data[:,0], 60, dtype = 'float')
bottoms = data[:,0].astype('float')
plt.bar(x_vals, heights, width = widths, bottom = bottoms, color = color)
print('finished file ' + f)
def main(argv):
if(len(argv) != 2):
print("Usage: daily_pos_file out_dir")
exit()
os.makedirs(argv[1], exist_ok='True')
outName = ""
try:
f = open(argv[0], 'r')
except IOError as error:
print("Error reading file in pos_visualizer.py")
print(error)
initPlot(f)
if(os.path.isfile(argv[0])):
genPlot(argv[0])
try:
outName = argv[0][argv[0].rindex('/') + 1 : argv[0].find('_')]
except:
outName = 'sat-vis'
elif(os.path.isdir(argv[0])):
outName = 'all'
fileCount = 1
for filename in os.listdir(argv[0]):
if(fileCount > MAX_FILES):
break;
f = os.path.join(argv[0],filename)
if os.path.isfile(f):
fileCount+=1
genPlot(f)
plt.legend(handles=LEGEND_LIST, loc ='upper right')
plt.savefig(os.path.join(argv[1], outName + '.png'))
if __name__ == '__main__':
main(sys.argv[1:])
...@@ -4,6 +4,7 @@ try: ...@@ -4,6 +4,7 @@ try:
import matplotlib import matplotlib
matplotlib.use('agg') matplotlib.use('agg')
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
except ImportError as e: except ImportError as e:
print("Matplotlib is needed to generate graphs") print("Matplotlib is needed to generate graphs")
sys.exit(1) sys.exit(1)
...@@ -34,27 +35,40 @@ def main(argv): ...@@ -34,27 +35,40 @@ def main(argv):
args = parser.parse_args(argv) args = parser.parse_args(argv)
if(not os.path.isdir(args.outdir)):
print("Output directory does not exist: " + args.outdir)
sys.exit(1)
plt.ylabel('Year') plt.ylabel('Year')
plt.xlabel('Longitude') plt.xlabel('Longitude')
plt.title('Geostationary Equator Coverage') plt.title('Geostationary Equator Coverage')
plt.figure().set_figheight(15) plt.figure().set_figheight(15)
plt.xlim(-180, 180) plt.xlim(-180,180)
min_date = 9999999 min_date = 9999999
max_date = -9999999 max_date = -9999999
plot_list = [] plot_list = []
patch_list = []
for subpt in args.list: for subpt in args.list:
data = np.loadtxt(subpt, dtype='str') data = np.loadtxt(subpt, dtype='str')
min_date = min(min_date, int(data[0][1])) min_date = min(min_date, int(data[0][1]))
max_date = max(max_date, int(data[-1][1])) max_date = max(max_date, int(data[-1][1]))
plot_list.append(genData(data)) if(args.verbose):
print("Graphing " + data[0][0])
gen = genData(data)
p = plt.bar(gen[0], gen[1], width = gen[2], bottom = gen[3])
patch_list.append(mpatches.Patch(label=data[0][0], color = p[-1].get_facecolor()))
year_axis = np.arange(max_date, min_date - 1, -1, dtype='int')
plt.yticks(year_axis)
plt.gca().invert_yaxis()
plt.legend(handles=patch_list)
plt.ylim(min_date, max_date) if(len(args.list) == 1):
out_name = data[0][0]
for dat in plot_list: else:
plt.bar(dat[0], dat[1], width = dat[2], bottom = dat[3]) out_name = "sats"
plt.savefig(os.path.join(args.outdir, out_name + '.png'))
plt.savefig(os.path.join(args.outdir, args.list[0] + '.png'))
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv[1:]) main(sys.argv[1:])
pics/ATS-1.png

40.6 KiB

pics/ATS-3.png

39.7 KiB

pics/ATSs.png

21.8 KiB

pics/GOES-1.png

33.6 KiB

pics/GOES-13.png

28.5 KiB

pics/GOES-16.png

18.3 KiB

pics/GOES-2.png

33.1 KiB

pics/GOES-3.png

32.7 KiB

pics/GOES-4.png

32.8 KiB

pics/GOES-5.png

30.3 KiB

pics/GOES-6.png

28 KiB

pics/GOES-7.png

23 KiB

pics/GOES-old.png

49.7 KiB

pics/GOESs.png

69.4 KiB

pics/SMS-1.png

34.8 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment