|
| 1 | +# Copyright (C) 2016 Swift Navigation Inc. |
| 2 | +# |
| 3 | +# Contact: Valeri Atamaniouk <[email protected]> |
| 4 | +# This source is subject to the license found in the file 'LICENSE' which must |
| 5 | +# be be distributed together with this source. All other rights reserved. |
| 6 | +# |
| 7 | +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, |
| 8 | +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| 9 | +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | + |
| 11 | +''' |
| 12 | +Unit tests for IQgen signal definitions |
| 13 | +''' |
| 14 | + |
| 15 | +from peregrine.iqgen.bits.signals import GPS |
| 16 | +from peregrine.iqgen.bits.signals import GLONASS |
| 17 | +from scipy.constants import c as C |
| 18 | + |
| 19 | + |
| 20 | +def test_GPSL1(): |
| 21 | + ''' |
| 22 | + Test GPS L1 signal methods |
| 23 | + ''' |
| 24 | + doppler = -10. / C * GPS.L1CA.CENTER_FREQUENCY_HZ |
| 25 | + assert GPS.L1CA.calcDopplerShiftHz(1000., 10.) == doppler |
| 26 | + assert GPS.L1CA.getCodeChipIndex(0.) == 0 |
| 27 | + assert GPS.L1CA.getCodeChipIndex(0.5) == 511500 |
| 28 | + assert GPS.L1CA.getSymbolIndex(0.) == 0 |
| 29 | + assert GPS.L1CA.getSymbolIndex(0.5) == 25 |
| 30 | + |
| 31 | + |
| 32 | +def test_GPSL2(): |
| 33 | + ''' |
| 34 | + Test GPS L2 signal methods |
| 35 | + ''' |
| 36 | + doppler = -10. / C * GPS.L2C.CENTER_FREQUENCY_HZ |
| 37 | + assert GPS.L2C.calcDopplerShiftHz(1000., 10.) == doppler |
| 38 | + assert GPS.L2C.getCodeChipIndex(0.) == 0 |
| 39 | + assert GPS.L2C.getCodeChipIndex(0.5) == 511500 |
| 40 | + assert GPS.L2C.getSymbolIndex(0.) == 0 |
| 41 | + assert GPS.L2C.getSymbolIndex(0.5) == 25 |
| 42 | + |
| 43 | + |
| 44 | +def test_GLONASS_common(): |
| 45 | + ''' |
| 46 | + Test common GLONASS signal methods |
| 47 | + ''' |
| 48 | + assert GLONASS.getCodeChipIndex(0.) == 0 |
| 49 | + assert GLONASS.getCodeChipIndex(0.5) == 511000 / 2 |
| 50 | + assert GLONASS.getSymbolIndex(0.) == 0 |
| 51 | + assert GLONASS.getSymbolIndex(0.5) == 50 |
| 52 | + |
| 53 | + |
| 54 | +def test_GLONASSL1(): |
| 55 | + ''' |
| 56 | + Test GLONASS L1 signal methods |
| 57 | + ''' |
| 58 | + doppler = -10. / C * GLONASS.L1S[0].CENTER_FREQUENCY_HZ |
| 59 | + assert GLONASS.L1S[0].calcDopplerShiftHz(1000., 10.) == doppler |
| 60 | + assert GLONASS.L1S[0].getCodeChipIndex(0.) == 0 |
| 61 | + assert GLONASS.L1S[0].getCodeChipIndex(0.5) == 511000 / 2 |
| 62 | + assert GLONASS.L1S[0].getSymbolIndex(0.) == 0 |
| 63 | + assert GLONASS.L1S[0].getSymbolIndex(0.5) == 50 |
| 64 | + |
| 65 | + |
| 66 | +def test_GLONASSL2(): |
| 67 | + ''' |
| 68 | + Test GLONASS L2 signal methods |
| 69 | + ''' |
| 70 | + doppler = -10. / C * GLONASS.L2S[0].CENTER_FREQUENCY_HZ |
| 71 | + assert GLONASS.L2S[0].calcDopplerShiftHz(1000., 10.) == doppler |
| 72 | + assert GLONASS.L2S[0].getCodeChipIndex(0.) == 0 |
| 73 | + assert GLONASS.L2S[0].getCodeChipIndex(0.5) == 511000 / 2 |
| 74 | + assert GLONASS.L2S[0].getSymbolIndex(0.) == 0 |
| 75 | + assert GLONASS.L2S[0].getSymbolIndex(0.5) == 50 |
0 commit comments