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

Commit 2c72d02

Browse files
author
Adel Mamin
committed
Add unit test for alias detector
1 parent 86655a4 commit 2c72d02

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/test_alias_detector.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (C) 2016 Swift Navigation Inc.
2+
#
3+
# This source is subject to the license found in the file 'LICENSE' which must
4+
# be be distributed together with this source. All other rights reserved.
5+
#
6+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
7+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
8+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
9+
10+
import numpy as np
11+
from peregrine import alias_detector
12+
13+
def get_error(ad, expected_err_hz):
14+
angle = expected_err_hz * 2 * np.pi * 0.001
15+
rotation = np.exp(1j * angle)
16+
17+
ad.reinit()
18+
19+
iq = rotation
20+
ad.first(iq)
21+
22+
for i in range(ad.acc_len):
23+
ad.second(iq)
24+
ad.first(iq)
25+
iq *= rotation
26+
iq /= abs(iq)
27+
28+
return ad.get_err_hz()
29+
30+
def test_alias_detect():
31+
'''
32+
Alias lock detector test
33+
'''
34+
35+
ad_l1ca = alias_detector.AliasDetector()
36+
ad_l2c = alias_detector.AliasDetector()
37+
38+
meas_err_hz = [-75, -80, -25, -30, 0, 20, 25, 65, 75]
39+
true_err_hz = [-75, -75, -25, -25, 0, 25, 25, 75, 75]
40+
41+
for ad in [ad_l1ca, ad_l2c]:
42+
for i, err_hz in enumerate(meas_err_hz):
43+
assert true_err_hz[i] == get_error(ad, err_hz)

0 commit comments

Comments
 (0)