Skip to content

Commit ad8eb85

Browse files
committed
inrows check and doc string update
1 parent a9aca55 commit ad8eb85

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

gnss_lib_py/utils/dop.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def get_dop(navdata, **which_dop):
3939
NavData instance containing received GNSS measurements for a
4040
particular time instance, contains elevation and azimuth angle
4141
information for an estimated location.
42+
Instance of the NavData class which must include at least
43+
``gps_millis``, ``el_sv_deg``, and ``az_sv_deg``
4244
4345
which_dop : dict
4446
Dictionary of which dop values are needed. Default is HDOP and VDOP.
@@ -68,6 +70,9 @@ def get_dop(navdata, **which_dop):
6870
Dilution of precision data along with the relevant time stamp.
6971
"""
7072

73+
# Check that the navdata has the necessary elevation and azimuth data
74+
navdata.in_rows(['gps_millis', 'el_sv_deg', 'az_sv_deg'])
75+
7176
# Default which_dop values assume HDOP and VDOP are needed.
7277
default_which_dop = {'GDOP': False,
7378
'HDOP': True,

notebooks/tutorials/utils/dop.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
"outputs": [],
4949
"source": [
5050
"glp.make_dir(\"../data\")\n",
51-
"\n",
52-
"# %wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/google_decimeter_2022/device_gnss.csv --quiet -nc -O \"../data/device_gnss.csv\"\n",
5351
"urllib.request.urlretrieve(\"https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/google_decimeter_2022/device_gnss.csv\", \"../data/device_gnss.csv\")\n",
5452
"\n",
5553
"navdata = glp.AndroidDerived2022(\"../data/device_gnss.csv\")"

tests/utils/test_dop.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,33 +388,31 @@ def test_singularity_dop(navdata):
388388
Parameters
389389
----------
390390
navdata : NavData
391-
A NavData with only one time entry of a *singular* satellite scenario.
391+
A NavData with only one time entry of a **singular** satellite scenario.
392392
393393
"""
394394

395395
# Run the DOP calculation
396396
dop_dict = calculate_dop(navdata)
397397

398-
print("DOP dict")
399-
print(dop_dict)
400-
401398
# Check the DOP output has all the expected keys
402399
assert dop_dict.keys() == {'dop_matrix',
403400
'GDOP', 'HDOP', 'VDOP', 'PDOP', 'TDOP'}
404401

405402
try:
406403
enut_matrix = _calculate_enut_matrix(navdata)
407-
print("ENUT matrix")
408-
print(enut_matrix)
409-
410-
dop_manual = np.linalg.inv(enut_matrix.T @ enut_matrix)
411-
print("DOP manual")
412-
print(dop_manual)
404+
np.linalg.inv(enut_matrix.T @ enut_matrix)
413405

414406
# If we get here, then we did not get a singularity error
415407
# This is possible due to floating point errors, so we will check
416408
# that the values are unrealistically large.
409+
#
410+
# Note: When very poorly conditioned, the DOP matrix can have negative
411+
# entries. Then, the square root of the DOP matrix will be nan! So,
412+
# we first check for nans, and then for large values (otherwise there
413+
# is an issue in comparing nan > number).
417414
# Note: we use np.any() since we can get small values in the DOP matrix
415+
# even if singular (i.e., in the off-diagonal entries).
418416
for _, val in dop_dict.items():
419417
assert np.any(np.isnan(val)) or np.any(np.abs(val) > 1e6)
420418

0 commit comments

Comments
 (0)