Skip to content

Commit 287a99c

Browse files
committed
Better handle the near singularity case
1 parent c765a3d commit 287a99c

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

notebooks/tutorials/utils/dop.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"Dillution of Precision (DOP) describes the effect of satellite geometry on the \n",
1010
"user's positioning accuracy. \n",
1111
"DOP can refer to multiple ideas:\n",
12+
"\n",
1213
"1. DOP in the horizontal or vertical direction,\n",
1314
"2. DOP on the time uncertainty,\n",
1415
"3. The full DOP matrix, or\n",
@@ -131,7 +132,7 @@
131132
"metadata": {},
132133
"outputs": [],
133134
"source": [
134-
"dop_navdata = glp.get_dop(navdata, GDOP= True, HDOP=True, VDOP=True, \n",
135+
"dop_navdata = glp.get_dop(navdata, GDOP= True, HDOP=True, VDOP=True,\n",
135136
" PDOP=True, TDOP=True, dop_matrix=True)\n",
136137
"print(dop_navdata)"
137138
]

tests/utils/test_dop.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,33 @@ def test_singularity_dop(navdata):
391391
A NavData with only one time entry of a *singular* satellite scenario.
392392
393393
"""
394-
with pytest.raises(np.linalg.LinAlgError):
395-
enut_matrix = _calculate_enut_matrix(navdata)
396-
np.linalg.inv(enut_matrix.T @ enut_matrix)
397394

398-
# Now check that we get all NaNs for the DOP values when we have a
399-
# singularity
395+
# Run the DOP calculation
400396
dop_dict = calculate_dop(navdata)
401397

402398
# Check the DOP output has all the expected keys
403399
assert dop_dict.keys() == {'dop_matrix',
404-
'GDOP', 'HDOP', 'VDOP', 'PDOP', 'TDOP'}
400+
'GDOP', 'HDOP', 'VDOP', 'PDOP', 'TDOP'}
401+
402+
try:
403+
enut_matrix = _calculate_enut_matrix(navdata)
404+
np.linalg.inv(enut_matrix.T @ enut_matrix)
405405

406-
# Check these are all NaNs
407-
for _, val in dop_dict.items():
408-
assert np.all(np.isnan(val))
406+
# If we get here, then we did not get a singularity error
407+
# This is possible due to floating point errors, so we will check
408+
# that the values are unrealistically large.
409+
# Note: we use np.any() since we can get small values in the DOP matrix
410+
for _, val in dop_dict.items():
411+
assert np.any(np.abs(val) > 1e6)
412+
413+
except np.linalg.LinAlgError:
414+
# We expect a singularity error. If we get the singularity error, then
415+
# the values should all be NaNs
416+
417+
# Now check that we get all NaNs for the DOP values when we have a
418+
# singularity
419+
for _, val in dop_dict.items():
420+
assert np.all(np.isnan(val))
409421

410422

411423
#############################################

0 commit comments

Comments
 (0)