12
12
import peregrine .iqgen .iqgen_main as iqgen
13
13
import peregrine .defaults as defaults
14
14
import peregrine .gps_constants as gps
15
+ import peregrine .glo_constants as glo
15
16
import numpy as np
16
17
17
18
from mock import patch
18
19
19
20
20
21
def fileformat_to_bands (file_format ):
21
- if file_format == '1bit' :
22
- bands = ['l1ca' ]
23
- elif file_format == '1bit_x2' :
24
- bands = ['l1ca' , 'l2c' ]
25
- elif file_format == '2bits' :
26
- bands = ['l1ca' ]
27
- elif file_format == '2bits_x2' :
28
- bands = ['l1ca' , 'l2c' ]
29
- elif file_format == '2bits_x4' :
30
- bands = ['l1ca' , 'l2c' ]
22
+ profile = defaults .file_encoding_profile [file_format ]
23
+ bands = []
24
+ for p in profile :
25
+ if p == defaults .sample_channel_GPS_L1 :
26
+ bands += [gps .L1CA ]
27
+ elif p == defaults .sample_channel_GPS_L2 :
28
+ bands += [gps .L2C ]
29
+ elif p == defaults .sample_channel_GLO_L1 :
30
+ bands += [glo .GLO_L1 ]
31
+ elif p == defaults .sample_channel_GLO_L2 :
32
+ bands += [glo .GLO_L2 ]
31
33
return bands
32
34
33
35
@@ -67,8 +69,8 @@ def generate_2bits_x4_sample_file(filename):
67
69
samples [channel_lookup [rx ]][:] = chan
68
70
# Store the result back to the same file
69
71
packed = np .zeros (num_samples , dtype = np .uint8 )
70
- packed = samples [3 ][:: ] << 6
71
- packed |= samples [0 ][::] & 3
72
+ packed [:] = samples [3 ] << 6
73
+ packed |= samples [0 ] & 3
72
74
with open (filename , 'wb' ) as f :
73
75
packed .tofile (f )
74
76
@@ -77,17 +79,17 @@ def generate_2bits_x4_sample_file(filename):
77
79
78
80
def generate_piksi_sample_file (filename ):
79
81
samples_lookup = [
80
- 0b11111100 ,
81
- 0b11011000 ,
82
- 0b10110100 ,
83
- 0b10010000 ,
84
- 0b00000000 ,
85
- 0b00100100 ,
86
- 0b01001000 ,
87
- 0b01101100
82
+ 0b11111100 ,
83
+ 0b11011000 ,
84
+ 0b10110100 ,
85
+ 0b10010000 ,
86
+ 0b00000000 ,
87
+ 0b00100100 ,
88
+ 0b01001000 ,
89
+ 0b01101100
88
90
]
89
91
samples_lookup_values = [
90
- - 7 , - 7 , - 5 , - 5 , - 3 , - 3 , - 1 , - 1 , 1 , 1 , 3 , 3 , 5 , 5 , 7 , 7
92
+ - 7 , - 7 , - 5 , - 5 , - 3 , - 3 , - 1 , - 1 , 1 , 1 , 3 , 3 , 5 , 5 , 7 , 7
91
93
]
92
94
num_samples = int (1e6 )
93
95
packed = np .zeros (num_samples , dtype = np .uint8 )
@@ -104,23 +106,53 @@ def generate_sample_file(gps_sv_prn, init_doppler,
104
106
freq_profile , generate = .1 ):
105
107
sample_file = 'iqgen-data-samples.bin'
106
108
params = ['iqgen_main' ]
107
- params += ['--gps-sv' , str (gps_sv_prn )]
108
-
109
- if file_format == '1bit' :
110
- encoder = '1bit'
111
- params += ['--bands' , 'l1ca' ]
112
- elif file_format == '1bit_x2' :
113
- encoder = '1bit'
114
- params += ['--bands' , 'l1ca+l2c' ]
115
- elif file_format == '2bits' :
116
- encoder = '2bits'
117
- params += ['--bands' , 'l1ca' ]
118
- elif file_format == '2bits_x2' :
119
- encoder = '2bits'
120
- params += ['--bands' , 'l1ca+l2c' ]
121
- elif file_format == '2bits_x4' :
122
- encoder = '2bits'
123
- params += ['--bands' , 'l1ca+l2c' ]
109
+ bands = fileformat_to_bands (file_format )
110
+
111
+ if gps .L1CA in bands or gps .L2C in bands :
112
+ params += ['--gps-sv' , str (gps_sv_prn )]
113
+
114
+ if file_format == defaults .FORMAT_1BIT_X1_GPS_L1 :
115
+ encoder = '1bit'
116
+ params += ['--bands' , 'l1ca' ]
117
+ elif file_format == defaults .FORMAT_1BIT_X2_GPS_L1L2 :
118
+ encoder = '1bit'
119
+ params += ['--bands' , 'l1ca+l2c' ]
120
+ elif file_format == defaults .FORMAT_2BITS_X1_GPS_L1 :
121
+ encoder = '2bits'
122
+ params += ['--bands' , 'l1ca' ]
123
+ elif file_format == defaults .FORMAT_2BITS_X2_GPS_L1L2 :
124
+ encoder = '2bits'
125
+ params += ['--bands' , 'l1ca+l2c' ]
126
+ elif file_format == defaults .FORMAT_2BITS_X4_GPS_L1L2_GLO_L1L2 :
127
+ encoder = '2bits'
128
+ params += ['--bands' , 'l1ca+l2c' ]
129
+ else :
130
+ assert False
131
+ elif glo .GLO_L1 in bands or glo .GLO_L2 in bands :
132
+ params += ['--glo-sv' , str (gps_sv_prn )]
133
+
134
+ if file_format == defaults .FORMAT_1BIT_X1_GLO_L1 :
135
+ encoder = '1bit'
136
+ params += ['--bands' , 'l1' ]
137
+ elif file_format == defaults .FORMAT_1BIT_X1_GLO_L2 :
138
+ encoder = '1bit'
139
+ params += ['--bands' , 'l2' ]
140
+ elif file_format == defaults .FORMAT_1BIT_X2_GLO_L1L2 :
141
+ encoder = '1bit'
142
+ params += ['--bands' , 'l1+l2' ]
143
+ elif file_format == defaults .FORMAT_2BITS_X1_GLO_L1 :
144
+ encoder = '2bits'
145
+ params += ['--bands' , 'l1' ]
146
+ elif file_format == defaults .FORMAT_2BITS_X2_GLO_L1L2 :
147
+ encoder = '2bits'
148
+ params += ['--bands' , 'l1+l2' ]
149
+ elif file_format == defaults .FORMAT_2BITS_X4_GPS_L1L2_GLO_L1L2 :
150
+ encoder = '2bits'
151
+ params += ['--bands' , 'l1+l2' ]
152
+ else :
153
+ assert False
154
+ else :
155
+ assert False
124
156
125
157
params += ['--encoder' , encoder ]
126
158
params += ['--doppler-type' , 'const' ]
@@ -153,12 +185,12 @@ def run_peregrine(file_name, file_format, freq_profile,
153
185
short_long_cycles = None ):
154
186
155
187
parameters = [
156
- 'peregrine' ,
157
- '--file' , file_name ,
158
- '--file-format' , file_format ,
159
- '--profile' , freq_profile ,
160
- skip_param , str (skip_val ),
161
- '--progress-bar' , 'stdout'
188
+ 'peregrine' ,
189
+ '--file' , file_name ,
190
+ '--file-format' , file_format ,
191
+ '--profile' , freq_profile ,
192
+ skip_param , str (skip_val ),
193
+ '--progress-bar' , 'stdout'
162
194
]
163
195
if skip_tracking :
164
196
parameters += ['-t' ]
0 commit comments