8383 dest = 'xaxh' ,
8484 help = 'Make x-axis hours instead of seconds.' )
8585
86+ parser .add_argument (
87+ '--ntw' ,
88+ action = 'store_true' ,
89+ dest = 'ntw' ,
90+ help = 'Plot differences in NTW instead of ECEF' )
91+
8692defaultPlotOptions = {
8793 "style_sheet" : "dark_background" ,
8894 "data_points_color" : "blue" ,
100106 "error_bar_alpha" : 0.2 ,
101107}
102108
109+ def cel2ntw (r , v ):
110+ r = np .array (r )
111+ v = np .array (v )
112+ T = v / np .linalg .norm (v )
113+ W = np .cross (r , v ) / np .linalg .norm (np .cross (r , v ))
114+ N = np .cross (T , W )
115+ R = np .column_stack ((N , T , W ))
116+ return R .transpose ()
117+
118+ def ntwdiff (t , x1 , y1 , z1 , vx1 , vy1 , vz1 , x2 , y2 , z2 ):
119+ ntws = []
120+ for i , t in enumerate (t ):
121+ R = cel2ntw (np .array ([x1 [i ], y1 [i ], z1 [i ]]), np .array ([vx1 [i ], vy1 [i ], vz1 [i ]]))
122+ dr = np .array ([x1 [i ]- x2 [i ], y1 [i ]- y2 [i ], z1 [i ]- z2 [i ]])
123+ ntw = R * dr
124+ ntws .append (ntw )
125+ return ntws
103126
104127def parse (source , sec2hr = False ):
105128 t = []; lx1 = []; ly1 = []; lz1 = [];
@@ -112,18 +135,18 @@ def parse(source, sec2hr=False):
112135 for line in source :
113136 # print(line.strip())
114137 if line [0 ] != '#' and (not 'Number of deriv calls' in line ):
115- # try:
116- sec , x1 , y1 , z1 , vx1 , vy1 , vz1 , x2 , y2 , z2 , vx2 , vy2 , vz2 = [ float (x ) for x in line .split (' ' ) ]
117- t .append (sec if sec2hr is False else sec / 3600. )
118- lx1 .append (x1 ); ly1 .append (y1 ); lz1 .append (z1 );
119- lx2 .append (x2 ); ly2 .append (y2 ); lz2 .append (z2 );
120- lvx1 .append (vx1 ); lvy1 .append (vy1 ); lvz1 .append (vz1 );
121- lvx2 .append (vx2 ); lvy2 .append (vy2 ); lvz2 .append (vz2 );
122- N += 1
123- mean_height = mean_height * (N - 1 )/ N + np .linalg .norm (np .array ((x1 ,y1 ,z1 ))* 1e-3 )/ N
124- mean_velo = mean_velo * (N - 1 )/ N + np .linalg .norm (np .array ((vx1 ,vy1 ,vz1 )))/ N
125- # except:
126- # pass
138+ try :
139+ sec , x1 , y1 , z1 , vx1 , vy1 , vz1 , x2 , y2 , z2 , vx2 , vy2 , vz2 = [ float (x ) for x in line .split (' ' ) ]
140+ t .append (sec if sec2hr is False else sec / 3600. )
141+ lx1 .append (x1 ); ly1 .append (y1 ); lz1 .append (z1 );
142+ lx2 .append (x2 ); ly2 .append (y2 ); lz2 .append (z2 );
143+ lvx1 .append (vx1 ); lvy1 .append (vy1 ); lvz1 .append (vz1 );
144+ lvx2 .append (vx2 ); lvy2 .append (vy2 ); lvz2 .append (vz2 );
145+ N += 1
146+ mean_height = mean_height * (N - 1 )/ N + np .linalg .norm (np .array ((x1 ,y1 ,z1 ))* 1e-3 )/ N
147+ mean_velo = mean_velo * (N - 1 )/ N + np .linalg .norm (np .array ((vx1 ,vy1 ,vz1 )))/ N
148+ except :
149+ pass
127150 else :
128151 if line .startswith ('#title' ):
129152 title = line .replace ('#title' ,'' ).strip ()
@@ -192,11 +215,27 @@ def match(t1, x1, t2, x2, matched_indexes = None):
192215 axs [0 ,1 ].plot (st , [scale_vel * (z [0 ]- z [1 ]) for z in zip (slvx1 ,slvx2 )],label = r'$\delta v_x$ {:}' .format (args .compare_to ))
193216 axs [1 ,1 ].plot (st , [scale_vel * (z [0 ]- z [1 ]) for z in zip (slvy1 ,slvy2 )],label = r'$\delta v_y$ {:}' .format (args .compare_to ))
194217 axs [2 ,1 ].plot (st , [scale_vel * (z [0 ]- z [1 ]) for z in zip (slvz1 ,slvz2 )],label = r'$\delta v_z$ {:}' .format (args .compare_to ))
195-
196- dt , dx , midx = match (st , slx1 , t , lx1 , None )
197- axs [0 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,slx2 , t ,lx2 ,midx )[1 ]],label = "_nolegend_" )
198- axs [1 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,sly2 , t ,ly2 ,midx )[1 ]],label = "_nolegend_" )
199- axs [2 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,slz2 , t ,lz2 ,midx )[1 ]],label = "_nolegend_" )
218+
219+ if not args .ntw :
220+ dt , dx , midx = match (st , slx1 , t , lx1 , None )
221+ axs [0 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,slx2 , t ,lx2 ,midx )[1 ]],label = "_nolegend_" )
222+ axs [1 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,sly2 , t ,ly2 ,midx )[1 ]],label = "_nolegend_" )
223+ axs [2 ,0 ].plot (dt , [scale_pos * (z ) for z in match (st ,slz2 , t ,lz2 ,midx )[1 ]],label = "_nolegend_" )
224+ else :
225+ dt , dx , midx = match (st , slx1 , t , lx1 , None )
226+ tx1 = [lx2 [i [0 ]] for i in midx ]
227+ ty1 = [ly2 [i [0 ]] for i in midx ]
228+ tz1 = [lz2 [i [0 ]] for i in midx ]
229+ tvx1 = [lvx2 [i [0 ]] for i in midx ]
230+ tvy1 = [lvy2 [i [0 ]] for i in midx ]
231+ tvz1 = [lvz2 [i [0 ]] for i in midx ]
232+ tx2 = [slx2 [i [1 ]] for i in midx ]
233+ ty2 = [sly2 [i [1 ]] for i in midx ]
234+ tz2 = [slz2 [i [1 ]] for i in midx ]
235+ ntwd = ntwdiff (dt , tx1 , ty1 , tz1 , tvx1 , tvy1 , tvz1 , tx2 , ty2 , tz2 )
236+ axs [0 ,0 ].plot (dt , [scale_pos * (z [0 ]) for z in ntwd ],label = "_nolegend_" )
237+ axs [1 ,0 ].plot (dt , [scale_pos * (z [1 ]) for z in ntwd ],label = "_nolegend_" )
238+ axs [2 ,0 ].plot (dt , [scale_pos * (z [2 ]) for z in ntwd ],label = "_nolegend_" )
200239 axs [0 ,1 ].plot (dt , [scale_vel * (z ) for z in match (st ,slvx2 ,t ,lvx2 ,midx )[1 ]],label = "_nolegend_" )
201240 axs [1 ,1 ].plot (dt , [scale_vel * (z ) for z in match (st ,slvy2 ,t ,lvy2 ,midx )[1 ]],label = "_nolegend_" )
202241 axs [2 ,1 ].plot (dt , [scale_vel * (z ) for z in match (st ,slvz2 ,t ,lvz2 ,midx )[1 ]],label = "_nolegend_" )
0 commit comments