-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTruthFile.py
59 lines (48 loc) · 1.51 KB
/
TruthFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import CoordTrans as ct
import numpy as np
# Columns of the truth file
TIME = 0
BEACON = 1
ICAO = 2
POS_LAT = 3
POS_LON = 4
POS_ALT = 5
VEL_E = 7
VEL_N = 8
VEL_U = 9
TGT_SYS_X = 14
TGT_SYS_Y = 15
TGT_SYS_Z = 16
TGT_SYS_DOT = 17
TGT_SYS_Y_DOT = 18
TGT_SYS_Z_DOT = 19
ADSB_ON = 20
RADAR_ON = 21
AST_ON = 22
key_column_map = { 'time' : ( TIME, ),
'beacon' : ( BEACON, ),
'geodetic position' : ( POS_LAT, POS_LON, POS_ALT ),
'enu velocity' : ( VEL_E, VEL_N, VEL_U ),
'system position' : ( TGT_SYS_X, TGT_SYS_Y, TGT_SYS_Z ) }
def read( filename ):
with open( filename, 'r' ) as file :
lines = file.readlines()
file.close()
return np.array( [ [ float( x ) for x in line.strip().split() ] for line in lines ], dtype = float )
def get( data, **kwargs ) :
if kwargs is not None :
for key, value in kwargs.iteritems() :
if key == 'item' :
item = value
return data[ :, key_column_map[ item ] ]
class Aircraft( object ) :
def __init__( self, data, **kwargs ) :
if kwargs is not None :
for key, value in kwargs.iteritems() :
if key == 'beacon' :
beacon = value
data = data[ data[ :, BEACON ] == beacon, : ]
self.time = get( data, item = 'time' )
self.pos_geod = get( data, item = 'geodetic position' )
self.vel_enu = get( data, item = 'enu velocity' )
self.pos_sys = get( data, item = 'system position' )