diff --git a/README.md b/README.md index 19fec30bb81188fd808635055a47fc6a808dfdd9..d80e1f794d1a18a0dae65b84ed7a45ce3c5b3489 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,73 @@ # 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 -**dailySatPositions.py** [OPTIONS] SAT-NAME TLE-FILE +**TLEConverter.py** [OPTIONS] SAT-NAME TLE-FILE ### 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). Any improperly formatted TLEs will be skipped. ### Options **-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** Change the mode to open the specified output, options are w,x,wb,xb **-v, --verbose** 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. diff --git a/TLEConverter.py b/bin/TLEConverter.py similarity index 100% rename from TLEConverter.py rename to bin/TLEConverter.py diff --git a/multiTLEConverter.bash b/bin/multiTLEConverter.bash similarity index 100% rename from multiTLEConverter.bash rename to bin/multiTLEConverter.bash diff --git a/bin/pos_visualizer.py b/bin/pos_visualizer.py deleted file mode 100644 index 89f5206c680d957238ffba24dc3ede08affbf7e8..0000000000000000000000000000000000000000 --- a/bin/pos_visualizer.py +++ /dev/null @@ -1,78 +0,0 @@ -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:]) diff --git a/bin/dailyPositionVisualizer.py b/bin/subptVisualizer.py similarity index 68% rename from bin/dailyPositionVisualizer.py rename to bin/subptVisualizer.py index da6d1d58e54837fc4f6cfcb7585e34107ecfd2d0..e6a5d63b731f764e960cbf111ad308964c0cf4ec 100644 --- a/bin/dailyPositionVisualizer.py +++ b/bin/subptVisualizer.py @@ -4,6 +4,7 @@ try: import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt + import matplotlib.patches as mpatches except ImportError as e: print("Matplotlib is needed to generate graphs") sys.exit(1) @@ -34,27 +35,40 @@ def main(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.xlabel('Longitude') plt.title('Geostationary Equator Coverage') plt.figure().set_figheight(15) - plt.xlim(-180, 180) + plt.xlim(-180,180) min_date = 9999999 max_date = -9999999 plot_list = [] + patch_list = [] for subpt in args.list: data = np.loadtxt(subpt, dtype='str') min_date = min(min_date, int(data[0][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) - - for dat in plot_list: - plt.bar(dat[0], dat[1], width = dat[2], bottom = dat[3]) - - plt.savefig(os.path.join(args.outdir, args.list[0] + '.png')) + if(len(args.list) == 1): + out_name = data[0][0] + else: + out_name = "sats" + plt.savefig(os.path.join(args.outdir, out_name + '.png')) if __name__ == '__main__': main(sys.argv[1:]) diff --git a/pics/ATS-1.png b/pics/ATS-1.png new file mode 100644 index 0000000000000000000000000000000000000000..43ec219036661a9852e705f36d55e6138663ce35 Binary files /dev/null and b/pics/ATS-1.png differ diff --git a/pics/ATS-3.png b/pics/ATS-3.png new file mode 100644 index 0000000000000000000000000000000000000000..595c98446b35dd60e316fc57fa838549347b8eed Binary files /dev/null and b/pics/ATS-3.png differ diff --git a/pics/ATSs.png b/pics/ATSs.png new file mode 100644 index 0000000000000000000000000000000000000000..a1b259041b22d65a9084712390b5014626bb0217 Binary files /dev/null and b/pics/ATSs.png differ diff --git a/pics/GOES-1.png b/pics/GOES-1.png new file mode 100644 index 0000000000000000000000000000000000000000..4905ece58a233ea5c6e2575c3c581c0bff62cf79 Binary files /dev/null and b/pics/GOES-1.png differ diff --git a/pics/GOES-13.png b/pics/GOES-13.png new file mode 100644 index 0000000000000000000000000000000000000000..e74a5462e3c9ddc5bcf660516ed1366dbd2be74b Binary files /dev/null and b/pics/GOES-13.png differ diff --git a/pics/GOES-16.png b/pics/GOES-16.png new file mode 100644 index 0000000000000000000000000000000000000000..609564dc37d8b6a5a4b0696f188315af8bb03aba Binary files /dev/null and b/pics/GOES-16.png differ diff --git a/pics/GOES-2.png b/pics/GOES-2.png new file mode 100644 index 0000000000000000000000000000000000000000..989c49ac45e04d36f75bb97733c123ccf469ca0b Binary files /dev/null and b/pics/GOES-2.png differ diff --git a/pics/GOES-3.png b/pics/GOES-3.png new file mode 100644 index 0000000000000000000000000000000000000000..3c4e503332bf6f644c89f7747ff42908ac59a521 Binary files /dev/null and b/pics/GOES-3.png differ diff --git a/pics/GOES-4.png b/pics/GOES-4.png new file mode 100644 index 0000000000000000000000000000000000000000..f2a62f997f836ca3a48ab428e43933ce1e73d1d8 Binary files /dev/null and b/pics/GOES-4.png differ diff --git a/pics/GOES-5.png b/pics/GOES-5.png new file mode 100644 index 0000000000000000000000000000000000000000..fdb550c6bb46ae263ef6c0966db6072c7ba647c6 Binary files /dev/null and b/pics/GOES-5.png differ diff --git a/pics/GOES-6.png b/pics/GOES-6.png new file mode 100644 index 0000000000000000000000000000000000000000..4c1a7ef08cbf3621398042c48798f7be1bc3b111 Binary files /dev/null and b/pics/GOES-6.png differ diff --git a/pics/GOES-7.png b/pics/GOES-7.png new file mode 100644 index 0000000000000000000000000000000000000000..b36424709fea04c1057b0988059b42519518274a Binary files /dev/null and b/pics/GOES-7.png differ diff --git a/pics/GOES-old.png b/pics/GOES-old.png new file mode 100644 index 0000000000000000000000000000000000000000..e8e708663b22a43318c69e565d4640e8556352ef Binary files /dev/null and b/pics/GOES-old.png differ diff --git a/pics/GOESs.png b/pics/GOESs.png new file mode 100644 index 0000000000000000000000000000000000000000..10e02b1f97d0493c9621a0db558e60bd305b0e22 Binary files /dev/null and b/pics/GOESs.png differ diff --git a/pics/SMS-1.png b/pics/SMS-1.png new file mode 100644 index 0000000000000000000000000000000000000000..96592fb02f3a98ed1c9a10f802326c04c7660076 Binary files /dev/null and b/pics/SMS-1.png differ diff --git a/pics/SMS-2.png b/pics/SMS-2.png new file mode 100644 index 0000000000000000000000000000000000000000..34486182a4a6f6ac504a03cd6971c71f697c1b39 Binary files /dev/null and b/pics/SMS-2.png differ diff --git a/pics/SMSs.png b/pics/SMSs.png new file mode 100644 index 0000000000000000000000000000000000000000..da67dd0c09ee289334bc5fcdc2626e693ec47a64 Binary files /dev/null and b/pics/SMSs.png differ diff --git a/pics/all-before97.png b/pics/all-before97.png new file mode 100644 index 0000000000000000000000000000000000000000..292cd6528dabfc5d9de48afb7daed094c17c363c Binary files /dev/null and b/pics/all-before97.png differ diff --git a/pics/all.png b/pics/all.png new file mode 100644 index 0000000000000000000000000000000000000000..608761d959b384a381c77251d5419f47abf7301b Binary files /dev/null and b/pics/all.png differ diff --git a/subpts/ATS-1_SUBPOINTS.sbpt b/subpts/ATS-1.sbpt similarity index 100% rename from subpts/ATS-1_SUBPOINTS.sbpt rename to subpts/ATS-1.sbpt diff --git a/subpts/ATS-3_SUBPOINTS.sbpt b/subpts/ATS-3.sbpt similarity index 100% rename from subpts/ATS-3_SUBPOINTS.sbpt rename to subpts/ATS-3.sbpt diff --git a/subpts/GOES-1_SUBPOINTS.sbpt b/subpts/GOES-1.sbpt similarity index 100% rename from subpts/GOES-1_SUBPOINTS.sbpt rename to subpts/GOES-1.sbpt diff --git a/subpts/GOES-13_SUBPOINTS.sbpt b/subpts/GOES-13.sbpt similarity index 100% rename from subpts/GOES-13_SUBPOINTS.sbpt rename to subpts/GOES-13.sbpt diff --git a/subpts/GOES-16_SUBPOINTS.sbpt b/subpts/GOES-16.sbpt similarity index 100% rename from subpts/GOES-16_SUBPOINTS.sbpt rename to subpts/GOES-16.sbpt diff --git a/subpts/GOES-2_SUBPOINTS.sbpt b/subpts/GOES-2.sbpt similarity index 100% rename from subpts/GOES-2_SUBPOINTS.sbpt rename to subpts/GOES-2.sbpt diff --git a/subpts/GOES-3_SUBPOINTS.sbpt b/subpts/GOES-3.sbpt similarity index 100% rename from subpts/GOES-3_SUBPOINTS.sbpt rename to subpts/GOES-3.sbpt diff --git a/subpts/GOES-4_SUBPOINTS.sbpt b/subpts/GOES-4.sbpt similarity index 100% rename from subpts/GOES-4_SUBPOINTS.sbpt rename to subpts/GOES-4.sbpt diff --git a/subpts/GOES-5_SUBPOINTS.sbpt b/subpts/GOES-5.sbpt similarity index 100% rename from subpts/GOES-5_SUBPOINTS.sbpt rename to subpts/GOES-5.sbpt diff --git a/subpts/GOES-6_SUBPOINTS.sbpt b/subpts/GOES-6.sbpt similarity index 100% rename from subpts/GOES-6_SUBPOINTS.sbpt rename to subpts/GOES-6.sbpt diff --git a/subpts/GOES-7_SUBPOINTS.sbpt b/subpts/GOES-7.sbpt similarity index 100% rename from subpts/GOES-7_SUBPOINTS.sbpt rename to subpts/GOES-7.sbpt diff --git a/subpts/SMS-1_SUBPOINTS.sbpt b/subpts/SMS-1.sbpt similarity index 100% rename from subpts/SMS-1_SUBPOINTS.sbpt rename to subpts/SMS-1.sbpt diff --git a/subpts/SMS-2_SUBPOINTS.sbpt b/subpts/SMS-2.sbpt similarity index 100% rename from subpts/SMS-2_SUBPOINTS.sbpt rename to subpts/SMS-2.sbpt