1111import numpy as np
1212
1313from gnss_lib_py .navdata .navdata import NavData
14- from gnss_lib_py .parsers .google_decimeter import AndroidDerived2022
1514from gnss_lib_py .algorithms .fde import solve_fde , evaluate_fde
1615
17- @pytest .fixture (name = "root_path_2022" )
18- def fixture_root_path_2022 ():
19- """Location of measurements for unit test.
20-
21- Returns
22- -------
23- root_path_2022 : string
24- Folder location containing measurements.
25-
26- """
27- root_path = os .path .dirname (
28- os .path .dirname (
29- os .path .dirname (
30- os .path .realpath (__file__ ))))
31- root_path_2022 = os .path .join (root_path , 'data' ,'unit_test' ,'google_decimeter_2022' )
32- return root_path_2022
33-
34- @pytest .fixture (name = "derived_2022_path" )
35- def fixture_derived_2022_path (root_path_2022 ):
36- """Filepath of Android Derived measurements.
37-
38- Parameters
39- ----------
40- root_path_2022 : string
41- Folder location containing measurements.
42-
43- Returns
44- -------
45- derived_2022_path : string
46- Location for the unit_test Android derived 2022 measurements.
47-
48- Notes
49- -----
50- Test data is a subset of the Android Raw Measurement Dataset [1]_,
51- from the 2022 Decimeter Challenge. Particularly, the
52- train/2021-04-29-MTV-2/SamsungGalaxyS20Ultra trace. The dataset
53- was retrieved from
54- https://www.kaggle.com/competitions/smartphone-decimeter-2022/data
55-
56- References
57- ----------
58- .. [1] Fu, Guoyu Michael, Mohammed Khider, and Frank van Diggelen.
59- "Android Raw GNSS Measurement Datasets for Precise Positioning."
60- Proceedings of the 33rd International Technical Meeting of the
61- Satellite Division of The Institute of Navigation (ION GNSS+
62- 2020). 2020.
63-
64- """
65- derived_2022_path = os .path .join (root_path_2022 , 'device_gnss.csv' )
66- return derived_2022_path
67-
68- @pytest .fixture (name = "derived" )
69- def fixture_load_derived (derived_2022_path ):
70- """Load instance of AndroidDerived2022.
71-
72- Parameters
73- ----------
74- derived_2022_path : pytest.fixture
75- String with location of Android derived measurement file.
76-
77- Returns
78- -------
79- derived : AndroidDerived2022
80- Instance of AndroidDerived2022 for testing.
81-
82- """
83- derived = AndroidDerived2022 (derived_2022_path )
84- return derived
85-
8616@pytest .mark .parametrize ('method' ,
8717 [
8818 "residual" ,
8919 "edm" ,
9020 ])
91- def test_solve_fde (derived , method ):
21+ def test_solve_fde (derived_2022 , method ):
9222 """Test residual-based FDE.
9323
9424 Parameters
9525 ----------
96- derived : AndroidDerived2022
26+ derived_2022 : AndroidDerived2022
9727 Instance of AndroidDerived2022 for testing.
9828 method : string
9929 Method for fault detection and exclusion.
10030
10131 """
10232
10333 # test without removing outliers
104- navdata = derived .copy ()
34+ navdata = derived_2022 .copy ()
10535 navdata = solve_fde (navdata , method = method )
10636 assert "fault_" + method in navdata .rows
10737
10838 # max thresholds shouldn't remove any
109- navdata = derived .copy ()
39+ navdata = derived_2022 .copy ()
11040 navdata = solve_fde (navdata , threshold = np .inf , method = method )
11141 assert sum (navdata .where ("fault_" + method ,1 )["fault_" + method ]) == 0
11242
11343 # min threshold should remove most all
114- navdata = derived .copy ()
44+ navdata = derived_2022 .copy ()
11545 navdata = solve_fde (navdata , threshold = - np .inf , method = method )
11646 print (sum (navdata .where ("fault_" + method ,1 )["fault_" + method ]))
11747 assert len (navdata .where ("fault_" + method ,0 )) == 24
11848 num_unknown = len (navdata .where ("fault_" + method ,2 ))
11949
120- navdata = derived .copy ()
50+ navdata = derived_2022 .copy ()
12151 original_length = len (navdata )
12252 navdata = solve_fde (navdata ,
12353 threshold = - np .inf ,
@@ -130,38 +60,38 @@ def test_solve_fde(derived, method):
13060 np .array ([0 ]))
13161 assert len (navdata ) == original_length - num_unknown - 6
13262
133- def test_fde_fails (derived ):
63+ def test_fde_fails (derived_2022 ):
13464 """Test that solve_fde fails when it should.
13565
13666 Parameters
13767 ----------
138- derived : AndroidDerived2022
68+ derived_2022 : AndroidDerived2022
13969 Instance of AndroidDerived2022 for testing.
14070
14171 """
14272
14373 with pytest .raises (ValueError ) as excinfo :
144- solve_fde (derived , method = "perfect_method" )
74+ solve_fde (derived_2022 , method = "perfect_method" )
14575 assert "invalid method" in str (excinfo .value )
14676
14777@pytest .mark .parametrize ('method' ,
14878 [
14979 "residual" ,
15080 "edm" ,
15181 ])
152- def test_evaluate_fde (derived , method ):
82+ def test_evaluate_fde (derived_2022 , method ):
15383 """Evaluate FDE methods.
15484
15585 Parameters
15686 ----------
157- derived : AndroidDerived2022
87+ derived_2022 : AndroidDerived2022
15888 Instance of AndroidDerived2022 for testing.
15989 method : string
16090 Method for fault detection and exclusion.
16191
16292 """
16393
164- navdata = derived .copy ()
94+ navdata = derived_2022 .copy ()
16595 evaluate_fde (navdata ,
16696 method = method ,
16797 fault_truth_row = "MultipathIndicator" ,
0 commit comments