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

Commit

Permalink
Fix remaining iqgen unit test merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Adel Mamin authored and Pasi Miettinen committed May 19, 2016
1 parent c197b67 commit 7799353
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 177 deletions.
22 changes: 0 additions & 22 deletions peregrine/iqgen/bits/message_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from peregrine.iqgen.bits.message_const import Message as ConstMessage
from peregrine.iqgen.bits.message_lnav import Message as LNAVMessage
from peregrine.iqgen.bits.message_zeroone import Message as ZeroOneMessage
from peregrine.iqgen.bits.message_glo import Message as GLOMessage


class ObjectFactory(object):
Expand All @@ -43,8 +42,6 @@ def toMapForm(self, obj):
return self.__LNAVMessage_ToMap(obj)
elif t is ZeroOneMessage:
return self.__ZeroOneMessage_ToMap(obj)
elif t is GLOMessage:
return self.__GLOMessage_ToMap(obj)
else:
raise ValueError("Invalid object type")

Expand All @@ -60,8 +57,6 @@ def fromMapForm(self, data):
return self.__MapTo_LNAVMessage(data)
elif t == 'ZeroOneMessage':
return self.__MapTo_ZeroOneMessage(data)
elif t == 'GLOMessage':
return self.__MapTo_GLOMessage(data)
else:
raise ValueError("Invalid object type")

Expand Down Expand Up @@ -95,14 +90,6 @@ def __ZeroOneMessage_ToMap(self, obj):
data = {'type': 'ZeroOneMessage'}
return data

def __GLOMessage_ToMap(self, obj):
data = {'type': 'GLOMessage',
'prn': obj.prn,
'n_prefixBits': obj.n_prefixBits,
'n_msg0': obj.n_msg0,
'tow0': obj.tow0}
return data

def __MapTo_BlockMessage(self, data):
bits = data['bits']
return BlockMessage(bits)
Expand Down Expand Up @@ -134,14 +121,5 @@ def __MapTo_LNAVMessage(self, data):
def __MapTo_ZeroOneMessage(self, data):
return ZeroOneMessage()

def __MapTo_GLOMessage(self, data):
prn = data['prn']
n_prefixBits = data['n_prefixBits']
n_msg0 = data['n_msg0']
tow0 = data['tow0']
return GLOMessage(prn=prn,
tow0=tow0,
n_msg=n_msg0,
n_prefixBits=n_prefixBits)

factoryObject = ObjectFactory()
37 changes: 0 additions & 37 deletions peregrine/iqgen/bits/satellite_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""

from peregrine.iqgen.bits.satellite_gps import GPSSatellite
from peregrine.iqgen.bits.satellite_glo import GLOSatellite
from peregrine.iqgen.bits.amplitude_factory import factoryObject as amplitudeOF
from peregrine.iqgen.bits.doppler_factory import factoryObject as dopplerOF
from peregrine.iqgen.bits.message_factory import factoryObject as messageOF
Expand All @@ -34,17 +33,13 @@ def toMapForm(self, obj):
t = type(obj)
if t is GPSSatellite:
return self.__GPSSatellite_ToMap(obj)
elif t is GLOSatellite:
return self.__GLOSatellite_ToMap(obj)
else:
raise ValueError("Invalid object type")

def fromMapForm(self, data):
t = data['type']
if t == 'GPSSatellite':
return self.__MapTo_GPSSatellite(data)
elif t == 'GLOSatellite':
return self.__MapTo_GLOSatellite(data)
else:
raise ValueError("Invalid object type")

Expand All @@ -62,19 +57,6 @@ def __GPSSatellite_ToMap(self, obj):
}
return data

def __GLOSatellite_ToMap(self, obj):
data = {'type': 'GLOSatellite',
'prn': obj.prn,
'amplitude': amplitudeOF.toMapForm(obj.getAmplitude()),
'l1Enabled': obj.isL1Enabled(),
'l2Enabled': obj.isL2Enabled(),
'l1Message': messageOF.toMapForm(obj.getL1Message()),
'l2Message': messageOF.toMapForm(obj.getL2Message()),
'doppler': dopplerOF.toMapForm(obj.getDoppler()),
'codeDopplerIgnored': obj.isCodeDopplerIgnored()
}
return data

def __MapTo_GPSSatellite(self, data):
prn = data['prn']
doppler = dopplerOF.fromMapForm(data['doppler'])
Expand All @@ -96,23 +78,4 @@ def __MapTo_GPSSatellite(self, data):
satellite.setCodeDopplerIgnored(codeDopplerIgnored)
return satellite

def __MapTo_GLOSatellite(self, data):
prn = data['prn']
doppler = dopplerOF.fromMapForm(data['doppler'])
amplitude = amplitudeOF.fromMapForm(data['amplitude'])
l1caEnabled = data['l1Enabled']
l2cEnabled = data['l2Enabled']
l1caMessage = messageOF.fromMapForm(data['l1Message'])
l2cMessage = messageOF.fromMapForm(data['l2Message'])
codeDopplerIgnored = data['codeDopplerIgnored']
satellite = GLOSatellite(prn)
satellite.setAmplitude(amplitude)
satellite.setDoppler(doppler)
satellite.setL1Enabled(l1caEnabled)
satellite.setL2Enabled(l2cEnabled)
satellite.setL1Message(l1caMessage)
satellite.setL2Message(l2cMessage)
satellite.setCodeDopplerIgnored(codeDopplerIgnored)
return satellite

factoryObject = ObjectFactory()
100 changes: 0 additions & 100 deletions tests/test_iqgen_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@
from peregrine.iqgen.bits.encoder_gps import GPSL2TwoBitsEncoder
from peregrine.iqgen.bits.encoder_gps import GPSL1L2TwoBitsEncoder

# GLONASS only
from peregrine.iqgen.bits.encoder_glo import GLONASSL1BitEncoder
from peregrine.iqgen.bits.encoder_glo import GLONASSL2BitEncoder
from peregrine.iqgen.bits.encoder_glo import GLONASSL1L2BitEncoder
from peregrine.iqgen.bits.encoder_glo import GLONASSL1TwoBitsEncoder
from peregrine.iqgen.bits.encoder_glo import GLONASSL2TwoBitsEncoder
from peregrine.iqgen.bits.encoder_glo import GLONASSL1L2TwoBitsEncoder

# Combined
from peregrine.iqgen.bits.encoder_other import GPSGLONASSBitEncoder
from peregrine.iqgen.bits.encoder_other import GPSGLONASSTwoBitsEncoder

# Utilities
import numpy
from peregrine.iqgen.if_iface import NormalRateConfig
Expand Down Expand Up @@ -539,91 +527,3 @@ def test_GPSL1L2TwoBitsEncoder_init():
assert isinstance(encoder, TwoBandsTwoBitsEncoder)
assert encoder.l1Index == NormalRateConfig.GPS.L1.INDEX
assert encoder.l2Index == NormalRateConfig.GPS.L2.INDEX


def test_GLONASSL1BitEncoder_init():
'''
Test construction of GLONASS L1 single bit encoder
'''
encoder = GLONASSL1BitEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, BandBitEncoder)
assert encoder.bandIndex == NormalRateConfig.GLONASS.L1.INDEX


def test_GLONASSL2BitEncoder_init():
'''
Test construction of GLONASS L2 single bit encoder
'''
encoder = GLONASSL2BitEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, BandBitEncoder)
assert encoder.bandIndex == NormalRateConfig.GLONASS.L2.INDEX


def test_GLONASSL1L2BitEncoder_init():
'''
Test construction of GLONASS L1/L2 single bit dual band encoder
'''
encoder = GLONASSL1L2BitEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, TwoBandsBitEncoder)
assert encoder.l1Index == NormalRateConfig.GLONASS.L1.INDEX
assert encoder.l2Index == NormalRateConfig.GLONASS.L2.INDEX


def test_GLONASSL1TwoBitsEncoder_init():
'''
Test construction of GLONASS L1 two bit encoder
'''
encoder = GLONASSL1TwoBitsEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, BandTwoBitsEncoder)
assert encoder.bandIndex == NormalRateConfig.GLONASS.L1.INDEX


def test_GLONASSL2TwoBitsEncoder_init():
'''
Test construction of GLONASS L2 two bit encoder
'''
encoder = GLONASSL2TwoBitsEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, BandTwoBitsEncoder)
assert encoder.bandIndex == NormalRateConfig.GLONASS.L2.INDEX


def test_GLONASSL1L2TwoBitsEncoder_init():
'''
Test construction of GLONASS L1/L2 two bit dual band encoder
'''
encoder = GLONASSL1L2TwoBitsEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, TwoBandsTwoBitsEncoder)
assert encoder.l1Index == NormalRateConfig.GLONASS.L1.INDEX
assert encoder.l2Index == NormalRateConfig.GLONASS.L2.INDEX


def test_GPSGLONASSBitEncoder_init():
'''
Test construction of GPS L1/L2 + GLONASS L1/L2 single bit quad band encoder
'''
encoder = GPSGLONASSBitEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, FourBandsBitEncoder)
assert encoder.bandIndexes[0] == NormalRateConfig.GPS.L2.INDEX
assert encoder.bandIndexes[1] == NormalRateConfig.GLONASS.L2.INDEX
assert encoder.bandIndexes[2] == NormalRateConfig.GLONASS.L1.INDEX
assert encoder.bandIndexes[3] == NormalRateConfig.GPS.L1.INDEX


def test_GPSGLONASSTwoBitsEncoder_init():
'''
Test construction of GPS L1/L2 + GLONASS L1/L2 two bit quad band encoder
'''
encoder = GPSGLONASSTwoBitsEncoder(NormalRateConfig)
assert isinstance(encoder, EncoderBase)
assert isinstance(encoder, FourBandsTwoBitsEncoder)
assert encoder.bandIndexes[0] == NormalRateConfig.GPS.L2.INDEX
assert encoder.bandIndexes[1] == NormalRateConfig.GLONASS.L2.INDEX
assert encoder.bandIndexes[2] == NormalRateConfig.GLONASS.L1.INDEX
assert encoder.bandIndexes[3] == NormalRateConfig.GPS.L1.INDEX
21 changes: 7 additions & 14 deletions tests/test_iqgen_gen_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@

from peregrine.iqgen.generate import generateSamples
from peregrine.iqgen.bits.satellite_gps import GPSSatellite
from peregrine.iqgen.bits.satellite_glo import GLOSatellite
from peregrine.iqgen.if_iface import HighRateConfig
from peregrine.iqgen.bits.encoder_other import GPSGLONASSBitEncoder
from peregrine.iqgen.bits.encoder_gps import GPSL1L2BitEncoder


def test_generateSamples0():
'''
Sample generation test:
- GPS L1/L2 + GLONASS L1/L2
- GPS L1/L2
- Noise sigma defined
- Band pass filter type
- No group delays
Expand All @@ -33,13 +32,10 @@ def test_generateSamples0():
sv0 = GPSSatellite(1)
sv0.setL1CAEnabled(True)
sv0.setL2CEnabled(True)
sv1 = GLOSatellite(0)
sv1.setL1Enabled(True)
sv1.setL2Enabled(True)
sv_list = [sv0, sv1]
sv_list = [sv0]

outputConfig = HighRateConfig
encoder = GPSGLONASSBitEncoder(outputConfig)
encoder = GPSL1L2BitEncoder(outputConfig)
time0S = 0.
nSamples = HighRateConfig.SAMPLE_BATCH_SIZE + 10000
noiseSigma = 1.
Expand Down Expand Up @@ -76,7 +72,7 @@ def update(self, value):
def test_generateSamples1():
'''
Sample generation test:
- GPS L1/L2 + GLONASS L1/L2
- GPS L1/L2
- No noise
- Low pass filter type
- No group delays
Expand All @@ -88,13 +84,10 @@ def test_generateSamples1():
sv0 = GPSSatellite(1)
sv0.setL1CAEnabled(True)
sv0.setL2CEnabled(True)
sv1 = GLOSatellite(0)
sv1.setL1Enabled(True)
sv1.setL2Enabled(True)
sv_list = [sv0, sv1]
sv_list = [sv0]

outputConfig = HighRateConfig
encoder = GPSGLONASSBitEncoder(outputConfig)
encoder = GPSL1L2BitEncoder(outputConfig)
time0S = 0.
nSamples = 9999
noiseSigma = None
Expand Down
4 changes: 0 additions & 4 deletions tests/test_iqgen_map_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
from peregrine.iqgen.bits.message_const import Message as ConstMessage
from peregrine.iqgen.bits.message_lnav import Message as LNAVMessage
from peregrine.iqgen.bits.message_zeroone import Message as ZeroOneMessage
from peregrine.iqgen.bits.message_glo import Message as GLOMessage

from peregrine.iqgen.bits.satellite_gps import GPSSatellite
from peregrine.iqgen.bits.satellite_glo import GLOSatellite

from peregrine.iqgen.bits.tcxo_poly import TCXOPoly as PolyTcxo
from peregrine.iqgen.bits.tcxo_sine import TCXOSine as SineTcxo
Expand Down Expand Up @@ -91,11 +89,9 @@ def test_factories():
to_map_and_back(MFO, ConstMessage(1))
to_map_and_back(MFO, LNAVMessage(1))
to_map_and_back(MFO, ZeroOneMessage())
to_map_and_back(MFO, GLOMessage(1))
value_error(MFO)

to_map_and_back(SFO, GPSSatellite(1))
to_map_and_back(SFO, GLOSatellite(1))
value_error(SFO)

to_map_and_back(TFO, PolyTcxo((1., 1.)))
Expand Down

0 comments on commit 7799353

Please sign in to comment.