meteortools.rmsutils.plotRMSOrbits
1# Copyright (C) 2018-2023 Mark McIntyre 2 3# 4# python code to plot orbits given a CAMS style Orbit Info file 5# 6 7import sys 8import os 9import pandas as pd 10import datetime 11import matplotlib.pyplot as plt 12try: 13 from wmpl.Utils.PlotOrbits import plotOrbits 14except: 15 print('WMPL not available') 16 17 18def plotRMSOrbits(orbitFile, outdir=None, hideplot=True): 19 """ 20 plots a set of orbits from RMS data, with one line per set of osculations 21 22 Arguments: 23 orbitFile: [string] full path to RMS orbit details file 24 outdir: [string] the location to write to. defaults to folder of source file 25 hideplot: [bool] don't display the plot. Default true 26 27 Returns: 28 none 29 30 Notes: 31 Orbitfile should be a csv file with the following labelled columns: 32 _a, _e, _incl, _peri, _node, _datetime 33 34 _datetime should be in the format YYYY-MM-DDTHH-MM-SS 35 36 """ 37 if outdir is None: 38 outdir, _ = os.path.split(orbitFile) 39 40 evttime = None 41 42 # read in the data file as a list of lines 43 data = pd.read_csv(orbitFile) 44 avals = list(data['_a']) 45 evals = list(data['_e']) 46 ivals = list(data['_incl']) 47 wvals = list(data['_peri']) 48 nvals = list(data['_node']) 49 dvals = list(data['_datetime']) 50 # create an empty array to contain the orbital elements 51 orb_elements=[] 52 53 # ignore the first two lines, split the remaining lines up and find the 54 # elements we want 55 for i in range(len(avals)): 56 if avals[i] > 0 and avals[i]<=10: 57 elemline = [avals[i],evals[i],ivals[i],wvals[i],nvals[i]] 58 # add the elements to the array 59 orb_elements.append(elemline) 60 if evttime is None: 61 evttime = dvals[i] 62 63 # plot and save the orbits 64 plotOrbits(orb_elements, datetime.datetime.strptime(evttime, '%Y-%m-%dT%H-%M-%S'), color_scheme='light') 65 plt.savefig(os.path.join(outdir, f'RMS_{evttime}.png')) 66 if not hideplot: 67 plt.show() 68 plt.close() 69 70 return 71 72 73if __name__ == '__main__': 74 if len(sys.argv) < 3: 75 print('usage: python plotRMSOrbits source_file target_folder') 76 77 plotRMSOrbits(sys.argv[1], sys.argv[2])
def
plotRMSOrbits(orbitFile, outdir=None, hideplot=True):
19def plotRMSOrbits(orbitFile, outdir=None, hideplot=True): 20 """ 21 plots a set of orbits from RMS data, with one line per set of osculations 22 23 Arguments: 24 orbitFile: [string] full path to RMS orbit details file 25 outdir: [string] the location to write to. defaults to folder of source file 26 hideplot: [bool] don't display the plot. Default true 27 28 Returns: 29 none 30 31 Notes: 32 Orbitfile should be a csv file with the following labelled columns: 33 _a, _e, _incl, _peri, _node, _datetime 34 35 _datetime should be in the format YYYY-MM-DDTHH-MM-SS 36 37 """ 38 if outdir is None: 39 outdir, _ = os.path.split(orbitFile) 40 41 evttime = None 42 43 # read in the data file as a list of lines 44 data = pd.read_csv(orbitFile) 45 avals = list(data['_a']) 46 evals = list(data['_e']) 47 ivals = list(data['_incl']) 48 wvals = list(data['_peri']) 49 nvals = list(data['_node']) 50 dvals = list(data['_datetime']) 51 # create an empty array to contain the orbital elements 52 orb_elements=[] 53 54 # ignore the first two lines, split the remaining lines up and find the 55 # elements we want 56 for i in range(len(avals)): 57 if avals[i] > 0 and avals[i]<=10: 58 elemline = [avals[i],evals[i],ivals[i],wvals[i],nvals[i]] 59 # add the elements to the array 60 orb_elements.append(elemline) 61 if evttime is None: 62 evttime = dvals[i] 63 64 # plot and save the orbits 65 plotOrbits(orb_elements, datetime.datetime.strptime(evttime, '%Y-%m-%dT%H-%M-%S'), color_scheme='light') 66 plt.savefig(os.path.join(outdir, f'RMS_{evttime}.png')) 67 if not hideplot: 68 plt.show() 69 plt.close() 70 71 return
plots a set of orbits from RMS data, with one line per set of osculations
Arguments:
orbitFile: [string] full path to RMS orbit details file
outdir: [string] the location to write to. defaults to folder of source file
hideplot: [bool] don't display the plot. Default true
Returns:
none
Notes:
Orbitfile should be a csv file with the following labelled columns:
_a, _e, _incl, _peri, _node, _datetime
_datetime should be in the format YYYY-MM-DDTHH-MM-SS