Skip to content

Commit

Permalink
Merge pull request #19 from valeri-atamaniouk/i160-final-patches
Browse files Browse the repository at this point in the history
iqgen: unit tests for signals
  • Loading branch information
valeri-atamaniouk committed Apr 21, 2016
2 parents 7f58d3c + cb65afb commit 82f9e41
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 211 deletions.
199 changes: 0 additions & 199 deletions peregrine/iqgen/bits/encoder_factory.py

This file was deleted.

75 changes: 75 additions & 0 deletions tests/test_iqgen_signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2016 Swift Navigation Inc.
#
# Contact: Valeri Atamaniouk <[email protected]>
# This source is subject to the license found in the file 'LICENSE' which must
# be be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

'''
Unit tests for IQgen signal definitions
'''

from peregrine.iqgen.bits.signals import GPS
from peregrine.iqgen.bits.signals import GLONASS
from scipy.constants import c as C


def test_GPSL1():
'''
Test GPS L1 signal methods
'''
doppler = -10. / C * GPS.L1CA.CENTER_FREQUENCY_HZ
assert GPS.L1CA.calcDopplerShiftHz(1000., 10.) == doppler
assert GPS.L1CA.getCodeChipIndex(0.) == 0
assert GPS.L1CA.getCodeChipIndex(0.5) == 511500
assert GPS.L1CA.getSymbolIndex(0.) == 0
assert GPS.L1CA.getSymbolIndex(0.5) == 25


def test_GPSL2():
'''
Test GPS L2 signal methods
'''
doppler = -10. / C * GPS.L2C.CENTER_FREQUENCY_HZ
assert GPS.L2C.calcDopplerShiftHz(1000., 10.) == doppler
assert GPS.L2C.getCodeChipIndex(0.) == 0
assert GPS.L2C.getCodeChipIndex(0.5) == 511500
assert GPS.L2C.getSymbolIndex(0.) == 0
assert GPS.L2C.getSymbolIndex(0.5) == 25


def test_GLONASS_common():
'''
Test common GLONASS signal methods
'''
assert GLONASS.getCodeChipIndex(0.) == 0
assert GLONASS.getCodeChipIndex(0.5) == 511000 / 2
assert GLONASS.getSymbolIndex(0.) == 0
assert GLONASS.getSymbolIndex(0.5) == 50


def test_GLONASSL1():
'''
Test GLONASS L1 signal methods
'''
doppler = -10. / C * GLONASS.L1S[0].CENTER_FREQUENCY_HZ
assert GLONASS.L1S[0].calcDopplerShiftHz(1000., 10.) == doppler
assert GLONASS.L1S[0].getCodeChipIndex(0.) == 0
assert GLONASS.L1S[0].getCodeChipIndex(0.5) == 511000 / 2
assert GLONASS.L1S[0].getSymbolIndex(0.) == 0
assert GLONASS.L1S[0].getSymbolIndex(0.5) == 50


def test_GLONASSL2():
'''
Test GLONASS L2 signal methods
'''
doppler = -10. / C * GLONASS.L2S[0].CENTER_FREQUENCY_HZ
assert GLONASS.L2S[0].calcDopplerShiftHz(1000., 10.) == doppler
assert GLONASS.L2S[0].getCodeChipIndex(0.) == 0
assert GLONASS.L2S[0].getCodeChipIndex(0.5) == 511000 / 2
assert GLONASS.L2S[0].getSymbolIndex(0.) == 0
assert GLONASS.L2S[0].getSymbolIndex(0.5) == 50
24 changes: 12 additions & 12 deletions tests/test_iqgen_sv_glo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy


def test_GPSSv_init():
def test_GLOSv_init():
'''
GLONASS SV initialization test
'''
Expand All @@ -34,7 +34,7 @@ def test_GPSSv_init():
assert isinstance(sv.doppler, DopplerBase)


def test_GPSSV_bands():
def test_GLOSV_bands():
'''
GLONASS SV band configurations
'''
Expand All @@ -58,9 +58,9 @@ def test_GPSSV_bands():
assert sv.isL2Enabled()


def test_GPSSV_messages():
def test_GLOSV_messages():
'''
GPS SV messages test
GLONASS SV messages test
'''
sv = GLOSatellite(1)
assert sv.l1Message == sv.getL1Message()
Expand All @@ -75,19 +75,19 @@ def test_GPSSV_messages():
assert sv.l2Message == sv.getL2Message() != msg2


def test_GPSSV_str():
def test_GLOSV_str():
'''
GPS SV string representation
GLONASS SV string representation
'''
sv = GLOSatellite(3)
value = str(sv)
assert value.find('GLONASS') >= 0
assert value.find('3') >= 0


def test_SVBase_getBatchSignals0():
def test_GLOSv_getBatchSignals0():
'''
GPS SV signal generation: not enabled
GLONASS SV signal generation: not enabled
'''
sv = GLOSatellite(1)
start = 0.
Expand All @@ -106,9 +106,9 @@ def test_SVBase_getBatchSignals0():
assert (samples == 0).all()


def test_SVBase_getBatchSignals1():
def test_GLOSv_getBatchSignals1():
'''
GPS SV signal generation: not available
GLONASS SV signal generation: not available
'''
sv = GLOSatellite(1)
start = 0.
Expand All @@ -127,7 +127,7 @@ def test_SVBase_getBatchSignals1():
assert (samples == 0).all()


def test_SVBase_getBatchSignals2():
def test_GLOSv_getBatchSignals2():
'''
GLONASS SV signal generation: L1
'''
Expand All @@ -154,7 +154,7 @@ def test_SVBase_getBatchSignals2():
assert (samples[3] == 0).all()


def test_SVBase_getBatchSignals3():
def test_GLOSv_getBatchSignals3():
'''
GLONASS SV signal generation: L2
'''
Expand Down

0 comments on commit 82f9e41

Please sign in to comment.