meteortools.utils.plotTrack
1# Copyright (C) 2018-2023 Mark McIntyre 2 3import csv 4from matplotlib import pyplot as plt 5import numpy as np 6 7try: 8 from ..utils import greatCircleDistance 9except Exception: 10 from meteortools.utils import greatCircleDistance 11 12 13def trackToDistvsHeight(trackcsvfile): 14 """ 15 Plot a distance vs height graph from the supplied CSV file 16 17 Arguments: 18 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 19 20 Returns: 21 nothing, but it creates a PNG in the source folder containing the track plot 22 """ 23 inputfile = csv.reader(open(trackcsvfile)) 24 dists = [] 25 alts = [] 26 lat0 = -99 # use impossible value 27 lng0 = 0 28 for row in inputfile: 29 #columns are lat, long, height, times 30 if row[0] == 'lats': 31 continue 32 if lat0 == -99: 33 lat0 = np.radians(float(row[0])) 34 lng0 = np.radians(float(row[1])) 35 dist = 0 36 else: 37 lat = np.radians(float(row[0])) 38 lng = np.radians(float(row[1])) 39 dist = greatCircleDistance(lat0, lng0, lat, lng) 40 dists.append(dist) 41 alt = float(row[2])/1000 42 alts.append(alt) 43 plt.clf() 44 plt.plot(dists,alts) 45 outname = trackcsvfile.replace('.csv','_dist_alt.png') 46 plt.savefig(outname) 47 plt.close() 48 49 50def trackToTimevsVelocity(trackcsvfile): 51 """ 52 Plot a distance vs velocity graph from the supplied CSV file 53 54 Arguments: 55 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 56 57 Returns: 58 nothing, but it creates a PNG in the source folder containing the track plot 59 """ 60 inputfile = csv.reader(open(trackcsvfile)) 61 dists = [] 62 tims = [] 63 lat0 = -99 # use impossible value 64 lng0 = 0 65 for row in inputfile: 66 #columns are lat, long, height, times 67 if row[0] == 'lats': 68 continue 69 if lat0 == -99: 70 lat0 = np.radians(float(row[0])) 71 lng0 = np.radians(float(row[1])) 72 dist = 0 73 else: 74 lat = np.radians(float(row[0])) 75 lng = np.radians(float(row[1])) 76 dist = greatCircleDistance(lat0, lng0, lat, lng) 77 dists.append(dist) 78 tim = float(row[3]) 79 tims.append(tim) 80 vels=[] 81 vels.append(0) 82 for i in range(1,len(tims)): 83 vel = (dists[i]-dists[i-1])/(tims[i]-tims[i-1]) 84 print(vel) 85 vels.append(vel) 86 plt.clf() 87 plt.plot(tims,vels) 88 outname = trackcsvfile.replace('.csv','_tim_vel.png') 89 plt.savefig(outname) 90 plt.close() 91 92 93def trackToTimevsHeight(trackcsvfile): 94 """ 95 Plot a time vs height graph from the supplied CSV file 96 97 Arguments: 98 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 99 100 Returns: 101 nothing, but it creates a PNG in the source folder containing the track plot 102 """ 103 inputfile = csv.reader(open(trackcsvfile)) 104 tims = [] 105 alts = [] 106 for row in inputfile: 107 #columns are lat, long, height, times 108 if row[0] == 'lats': 109 continue 110 tims.append(float(row[3])) 111 alts.append(float(row[2])/1000) 112 plt.clf() 113 plt.plot(tims,alts) 114 outname = trackcsvfile.replace('.csv','_time_alt.png') 115 plt.savefig(outname) 116 plt.close()
14def trackToDistvsHeight(trackcsvfile): 15 """ 16 Plot a distance vs height graph from the supplied CSV file 17 18 Arguments: 19 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 20 21 Returns: 22 nothing, but it creates a PNG in the source folder containing the track plot 23 """ 24 inputfile = csv.reader(open(trackcsvfile)) 25 dists = [] 26 alts = [] 27 lat0 = -99 # use impossible value 28 lng0 = 0 29 for row in inputfile: 30 #columns are lat, long, height, times 31 if row[0] == 'lats': 32 continue 33 if lat0 == -99: 34 lat0 = np.radians(float(row[0])) 35 lng0 = np.radians(float(row[1])) 36 dist = 0 37 else: 38 lat = np.radians(float(row[0])) 39 lng = np.radians(float(row[1])) 40 dist = greatCircleDistance(lat0, lng0, lat, lng) 41 dists.append(dist) 42 alt = float(row[2])/1000 43 alts.append(alt) 44 plt.clf() 45 plt.plot(dists,alts) 46 outname = trackcsvfile.replace('.csv','_dist_alt.png') 47 plt.savefig(outname) 48 plt.close()
Plot a distance vs height graph from the supplied CSV file
Arguments:
trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time
Returns:
nothing, but it creates a PNG in the source folder containing the track plot
51def trackToTimevsVelocity(trackcsvfile): 52 """ 53 Plot a distance vs velocity graph from the supplied CSV file 54 55 Arguments: 56 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 57 58 Returns: 59 nothing, but it creates a PNG in the source folder containing the track plot 60 """ 61 inputfile = csv.reader(open(trackcsvfile)) 62 dists = [] 63 tims = [] 64 lat0 = -99 # use impossible value 65 lng0 = 0 66 for row in inputfile: 67 #columns are lat, long, height, times 68 if row[0] == 'lats': 69 continue 70 if lat0 == -99: 71 lat0 = np.radians(float(row[0])) 72 lng0 = np.radians(float(row[1])) 73 dist = 0 74 else: 75 lat = np.radians(float(row[0])) 76 lng = np.radians(float(row[1])) 77 dist = greatCircleDistance(lat0, lng0, lat, lng) 78 dists.append(dist) 79 tim = float(row[3]) 80 tims.append(tim) 81 vels=[] 82 vels.append(0) 83 for i in range(1,len(tims)): 84 vel = (dists[i]-dists[i-1])/(tims[i]-tims[i-1]) 85 print(vel) 86 vels.append(vel) 87 plt.clf() 88 plt.plot(tims,vels) 89 outname = trackcsvfile.replace('.csv','_tim_vel.png') 90 plt.savefig(outname) 91 plt.close()
Plot a distance vs velocity graph from the supplied CSV file
Arguments:
trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time
Returns:
nothing, but it creates a PNG in the source folder containing the track plot
94def trackToTimevsHeight(trackcsvfile): 95 """ 96 Plot a time vs height graph from the supplied CSV file 97 98 Arguments: 99 trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time 100 101 Returns: 102 nothing, but it creates a PNG in the source folder containing the track plot 103 """ 104 inputfile = csv.reader(open(trackcsvfile)) 105 tims = [] 106 alts = [] 107 for row in inputfile: 108 #columns are lat, long, height, times 109 if row[0] == 'lats': 110 continue 111 tims.append(float(row[3])) 112 alts.append(float(row[2])/1000) 113 plt.clf() 114 plt.plot(tims,alts) 115 outname = trackcsvfile.replace('.csv','_time_alt.png') 116 plt.savefig(outname) 117 plt.close()
Plot a time vs height graph from the supplied CSV file
Arguments:
trackcsvfile: [str] full path to a CSV file containing columns of lat, long, height, time
Returns:
nothing, but it creates a PNG in the source folder containing the track plot