Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 09a118a

Browse files
author
Pasi Miettinen
committed
Merge branch 'i160-iqgen-unittests' of https://github.com/valeri-atamaniouk/peregrine into i115-glonass-acq
2 parents c024e03 + e1a24a0 commit 09a118a

18 files changed

+1392
-265
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ tests/test_data_old*
5656
.project
5757
.cproject
5858
.settings/
59+
60+
# Coverage
61+
.coverage
62+
htmlcov/
63+

peregrine/iqgen/bits/amplitude_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def convertUnits2SNR(value, units, noiseParams):
206206
snrDb = 10 * numpy.log10(snr)
207207
elif units == AmplitudeBase.UNITS_SNR_DB:
208208
snrDb = value
209-
else:
209+
else: # pragma: no cover
210210
assert False
211211
return snrDb
212212

@@ -240,6 +240,6 @@ def convertUnits2Amp(value, units, noiseParams):
240240
snrDb = value
241241
snr = 10. ** (0.1 * snrDb)
242242
amp = numpy.sqrt(4. * snr / freqTimesTau) * noiseSigma
243-
else:
243+
else: # pragma: no cover
244244
assert False
245245
return amp

peregrine/iqgen/bits/doppler_base.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,8 @@ def computeBatch(self,
181181
-------
182182
signal : numpy.ndarray(n_samples, dtype=float)
183183
Generated samples
184-
userTimeX_s : float
185-
End of interval time in seconds
186-
chipAll_idx : numpy.ndarray(n_samples, dtype=float)
187-
Code chip phases for the samples
188-
chips : numpy.ndarray(n_samples, dtype=int)
189-
Code combined with data
184+
dopplerAll_hz : numpy.ndarray(n_samples, dtype=float)
185+
Doppler values in Hz if debug is enabled
190186
'''
191187

192188
userTimeAll_s = self.applySignalDelays(userTimeAll_s, carrierSignal)

peregrine/iqgen/bits/doppler_sine.py

-15
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,6 @@ def __str__(self):
6565
format(self.distance0_m, self.tec_epm2, self.speed0_mps,
6666
self.amplutude_mps, self.period_s, self.codeDopplerIgnored)
6767

68-
def __repr__(self):
69-
'''
70-
Constructs python expression presentation of object.
71-
72-
Returns
73-
-------
74-
string
75-
Python expression presentation of object
76-
'''
77-
return "Doppler({}, {}, {}, {}, {})".format(self.distance0_m,
78-
self.tec_epm2,
79-
self.speed0_mps,
80-
self.amplutude_mps,
81-
self.period_s)
82-
8368
def computeDistanceM(self, svTime_s):
8469
'''
8570
Computes doppler shift in meters.

peregrine/iqgen/bits/prn_glo_l1l2.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
1515
"""
1616
import numpy
17-
from peregrine.include.glo_ca_code import value as GLONASS_CA_Code
17+
from peregrine.include.glo_ca_code import value as GLONASS_CACode
1818

19-
caCode = GLONASS_CA_Code[:]
19+
# Binary CA code (0/1)
20+
caCode = (GLONASS_CACode < 0).astype(numpy.uint8)
2021

2122

2223
class PrnCode(object):
@@ -36,11 +37,7 @@ def __init__(self, prnNo):
3637
SV identifier
3738
'''
3839
super(PrnCode, self).__init__()
39-
self.caCode = caCode[:]
40-
tmp = numpy.asarray(self.caCode, dtype=numpy.int8)
41-
tmp -= 1
42-
tmp /= -2
43-
self.binCode = tmp
40+
self.binCode = caCode
4441
self.prnNo = prnNo
4542
self.bitLookup = numpy.asarray([1, -1], dtype=numpy.int8)
4643

peregrine/iqgen/bits/prn_gps_l1ca.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
1717
"""
1818

19-
import peregrine.include.generateCAcode
19+
from peregrine.include.generateCAcode import caCodes as L1CACodes
2020

21-
caCodes = peregrine.include.generateCAcode.caCodes
21+
caCodes = (L1CACodes < 0).astype(numpy.uint8)
2222

2323

2424
class PrnCode(object):
@@ -38,11 +38,7 @@ def __init__(self, prnNo):
3838
SV identifier
3939
'''
4040
super(PrnCode, self).__init__()
41-
self.caCode = caCodes[prnNo - 1][:]
42-
tmp = numpy.asarray(self.caCode, dtype=numpy.int8)
43-
tmp -= 1
44-
tmp /= -2
45-
self.binCode = tmp
41+
self.binCode = caCodes[prnNo - 1]
4642
self.prnNo = prnNo
4743
self.bitLookup = numpy.asarray([1, -1], dtype=numpy.int8)
4844

peregrine/iqgen/bits/prn_gps_l2c.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from peregrine.include.generateL2CMcode import L2CMCodes
2121

22+
caCodes = (L2CMCodes < 0).astype(numpy.uint8)
23+
2224

2325
class PrnCode(object):
2426
'''
@@ -42,7 +44,7 @@ def __init__(self, prnNo):
4244
SV identifier
4345
'''
4446
super(PrnCode.CM_Code, self).__init__()
45-
self.binCode = numpy.asarray(L2CMCodes[prnNo - 1], dtype=numpy.int8) < 0
47+
self.binCode = caCodes[prnNo - 1]
4648

4749
def getCodeBits(self):
4850
return self.binCode

peregrine/iqgen/bits/satellite_base.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def setDoppler(self, doppler):
6262
'''
6363
self.doppler = doppler
6464

65-
def getSvName(self):
65+
def getName(self):
6666
'''
6767
Returns satellite name.
6868
@@ -96,12 +96,18 @@ def getAmplitude(self):
9696
return self.amplitude
9797

9898
def __str__(self):
99-
return self.getSvName()
100-
101-
def __repr__(self):
102-
return self.getSvName()
99+
'''
100+
Returns string representation of SV object
101+
'''
102+
return self.getName()
103103

104-
def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams):
104+
def getBatchSignals(self,
105+
userTimeAll_s,
106+
samples,
107+
outputConfig,
108+
noiseParams,
109+
band,
110+
debug):
105111
'''
106112
Generates signal samples.
107113
@@ -113,6 +119,12 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams):
113119
Array to which samples are added.
114120
outputConfig : object
115121
Output configuration object.
122+
noiseParams : NoiseParameters
123+
Noise parameters object.
124+
band : Band
125+
Band description object.
126+
debug : bool
127+
Debug flag
116128
117129
Returns
118130
-------
@@ -121,14 +133,14 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams):
121133
'''
122134
raise NotImplementedError()
123135

124-
def isBandEnabled(self, bandIndex, outputConfig):
136+
def isBandEnabled(self, band, outputConfig):
125137
'''
126138
Checks if particular band is supported and enabled.
127139
128140
Parameters
129141
----------
130-
bandIndex : int
131-
Signal band index
142+
band : Band
143+
Band description object.
132144
outputConfig : object
133145
Output configuration
134146

peregrine/iqgen/bits/satellite_glo.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ def getL2Message(self):
137137
'''
138138
return self.l1Message
139139

140-
def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, debug):
140+
def getBatchSignals(self,
141+
userTimeAll_s,
142+
samples,
143+
outputConfig,
144+
noiseParams,
145+
band,
146+
debug):
141147
'''
142148
Generates signal samples.
143149
@@ -149,6 +155,10 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
149155
Array to which samples are added.
150156
outputConfig : object
151157
Output configuration object.
158+
noiseParams : NoiseParameters
159+
Noise parameters object
160+
band : Band
161+
Band description object.
152162
debug : bool
153163
Debug flag
154164
@@ -158,10 +168,8 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
158168
Debug information
159169
'''
160170
result = []
161-
if (self.l1Enabled):
162-
band = outputConfig.GLONASS.L1
171+
if (self.l1Enabled and band == outputConfig.GLONASS.L1):
163172
intermediateFrequency_hz = band.INTERMEDIATE_FREQUENCIES_HZ[self.prn]
164-
frequencyIndex = band.INDEX
165173
values = self.doppler.computeBatch(userTimeAll_s,
166174
self.amplitude,
167175
noiseParams,
@@ -171,15 +179,13 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
171179
self.caCode,
172180
outputConfig,
173181
debug)
174-
numpy.add(samples[frequencyIndex],
182+
numpy.add(samples[band.INDEX],
175183
values[0],
176-
out=samples[frequencyIndex])
184+
out=samples[band.INDEX])
177185
debugData = {'type': "GLOL1", 'doppler': values[1]}
178186
result.append(debugData)
179-
if (self.l2Enabled):
180-
band = outputConfig.GLONASS.L2
187+
if (self.l2Enabled and band == outputConfig.GLONASS.L2):
181188
intermediateFrequency_hz = band.INTERMEDIATE_FREQUENCIES_HZ[self.prn]
182-
frequencyIndex = band.INDEX
183189
values = self.doppler.computeBatch(userTimeAll_s,
184190
self.amplitude,
185191
noiseParams,
@@ -189,21 +195,21 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
189195
self.caCode,
190196
outputConfig,
191197
debug)
192-
numpy.add(samples[frequencyIndex],
198+
numpy.add(samples[band.INDEX],
193199
values[0],
194-
out=samples[frequencyIndex])
200+
out=samples[band.INDEX])
195201
debugData = {'type': "GLOL2", 'doppler': values[1]}
196202
result.append(debugData)
197203
return result
198204

199-
def isBandEnabled(self, bandIndex, outputConfig):
205+
def isBandEnabled(self, band, outputConfig):
200206
'''
201207
Checks if particular band is supported and enabled.
202208
203209
Parameters
204210
----------
205-
bandIndex : int
206-
Signal band index
211+
band : Band
212+
Band description object.
207213
outputConfig : object
208214
Output configuration
209215
@@ -212,9 +218,9 @@ def isBandEnabled(self, bandIndex, outputConfig):
212218
True, if the band is supported and enabled; False otherwise.
213219
'''
214220
result = None
215-
if bandIndex == outputConfig.GLONASS.L1.INDEX:
221+
if band == outputConfig.GLONASS.L1:
216222
result = self.isL1Enabled()
217-
elif bandIndex == outputConfig.GLONASS.L2.INDEX:
223+
elif band == outputConfig.GLONASS.L2:
218224
result = self.isL2Enabled()
219225
else:
220226
result = False

peregrine/iqgen/bits/satellite_gps.py

+24-16
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ def getL2CMessage(self):
147147
'''
148148
return self.l2cMessage
149149

150-
def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, debug):
150+
def getBatchSignals(self,
151+
userTimeAll_s,
152+
samples,
153+
outputConfig,
154+
noiseParams,
155+
band,
156+
debug):
151157
'''
152158
Generates signal samples.
153159
@@ -159,6 +165,10 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
159165
Array to which samples are added.
160166
outputConfig : object
161167
Output configuration object.
168+
noiseParams : NoiseParameters
169+
Noise parameters object
170+
band : Band
171+
Band description object.
162172
debug : bool
163173
Debug flag
164174
@@ -168,9 +178,8 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
168178
Debug information
169179
'''
170180
result = []
171-
if (self.l1caEnabled):
172-
intermediateFrequency_hz = outputConfig.GPS.L1.INTERMEDIATE_FREQUENCY_HZ
173-
frequencyIndex = outputConfig.GPS.L1.INDEX
181+
if (self.l1caEnabled and band == outputConfig.GPS.L1):
182+
intermediateFrequency_hz = band.INTERMEDIATE_FREQUENCY_HZ
174183
values = self.doppler.computeBatch(userTimeAll_s,
175184
self.amplitude,
176185
noiseParams,
@@ -180,14 +189,13 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
180189
self.l1caCode,
181190
outputConfig,
182191
debug)
183-
numpy.add(samples[frequencyIndex],
192+
numpy.add(samples[band.INDEX],
184193
values[0],
185-
out=samples[frequencyIndex])
194+
out=samples[band.INDEX])
186195
debugData = {'type': "GPSL1", 'doppler': values[1]}
187196
result.append(debugData)
188-
if (self.l2cEnabled):
189-
intermediateFrequency_hz = outputConfig.GPS.L2.INTERMEDIATE_FREQUENCY_HZ
190-
frequencyIndex = outputConfig.GPS.L2.INDEX
197+
if (self.l2cEnabled and band == outputConfig.GPS.L2):
198+
intermediateFrequency_hz = band.INTERMEDIATE_FREQUENCY_HZ
191199
values = self.doppler.computeBatch(userTimeAll_s,
192200
self.amplitude,
193201
noiseParams,
@@ -197,21 +205,21 @@ def getBatchSignals(self, userTimeAll_s, samples, outputConfig, noiseParams, deb
197205
self.l2cCode,
198206
outputConfig,
199207
debug)
200-
numpy.add(samples[frequencyIndex],
208+
numpy.add(samples[band.INDEX],
201209
values[0],
202-
out=samples[frequencyIndex])
210+
out=samples[band.INDEX])
203211
debugData = {'type': "GPSL2", 'doppler': values[1]}
204212
result.append(debugData)
205213
return result
206214

207-
def isBandEnabled(self, bandIndex, outputConfig):
215+
def isBandEnabled(self, band, outputConfig):
208216
'''
209217
Checks if particular band is supported and enabled.
210218
211219
Parameters
212220
----------
213-
bandIndex : int
214-
Signal band index
221+
band : Band
222+
Band description object.
215223
outputConfig : object
216224
Output configuration
217225
@@ -220,9 +228,9 @@ def isBandEnabled(self, bandIndex, outputConfig):
220228
True, if the band is supported and enabled; False otherwise.
221229
'''
222230
result = None
223-
if bandIndex == outputConfig.GPS.L1.INDEX:
231+
if band == outputConfig.GPS.L1:
224232
result = self.isL1CAEnabled()
225-
elif bandIndex == outputConfig.GPS.L2.INDEX:
233+
elif band == outputConfig.GPS.L2:
226234
result = self.isL2CEnabled()
227235
else:
228236
result = False

0 commit comments

Comments
 (0)