Skip to content

Commit 247c5f3

Browse files
committed
fix docs/typos requested in review of #72
1 parent 5e28ef6 commit 247c5f3

9 files changed

Lines changed: 57 additions & 39 deletions

File tree

docs/source/reference/reference.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ GNSS measurement naming conventions are as follows:
109109
estimated true signal transmission time.
110110
* :code:`z_sv_m` : (float) satellite ECEF z position in meters at best
111111
estimated true signal transmission time.
112-
* :code:`el_sv_deg` : Elevation of satellite in relation to the
113-
receiver's position.
114-
* :code:`az_sv_deg` : Azimuth of satellite in relation to the receiver's
115-
position.
112+
* :code:`el_sv_deg` : (float) Elevation of satellite in degrees in
113+
relation to the receiver's position.
114+
* :code:`az_sv_deg` : (float) Azimuth of satellite in degrees in
115+
relation to the receiver's position.
116116
* :code:`vx_sv_mps` : (float) satellite ECEF x velocity in meters per
117117
second at estimated true signal transmission time.
118118
* :code:`vy_sv_mps` : (float) satellite ECEF y velocity in meters per

gnss_lib_py/algorithms/residuals.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def solve_residuals(measurements, receiver_state, inplace=True):
7878
rx_t_idx].reshape(1,-1)
7979
pos_rx_m = np.tile(rx_pos, (num_svs, 1))
8080

81+
# assumes the use of corrected pseudoranges with the satellite
82+
# clock bias already removed
8183
gt_pr_m = np.linalg.norm(pos_rx_m - pos_sv_m, axis = 1,
8284
keepdims = True) \
8385
+ receiver_state[rx_idxs["b_*_m"],rx_t_idx]

gnss_lib_py/algorithms/snapshot.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def solve_wls(measurements, weight_type = None,
6161
position = np.zeros((4,1))
6262
for timestamp, _, measurement_subset in measurements.loop_time("gps_millis"):
6363

64-
pos_sv_m = np.hstack((measurement_subset["x_sv_m"].reshape(-1,1),
65-
measurement_subset["y_sv_m"].reshape(-1,1),
66-
measurement_subset["z_sv_m"].reshape(-1,1)))
64+
pos_sv_m = measurement_subset[["x_sv_m","y_sv_m","z_sv_m"]].T
65+
pos_sv_m = np.atleast_2d(pos_sv_m)
66+
6767
corr_pr_m = measurement_subset["corr_pr_m"].reshape(-1,1)
6868

6969
# remove NaN indexes
70-
nan_indexes = ~np.isnan(pos_sv_m).any(axis=1)
71-
pos_sv_m = pos_sv_m[nan_indexes]
72-
corr_pr_m = corr_pr_m[nan_indexes]
70+
not_nan_indexes = ~np.isnan(pos_sv_m).any(axis=1)
71+
pos_sv_m = pos_sv_m[not_nan_indexes]
72+
corr_pr_m = corr_pr_m[not_nan_indexes]
7373

7474
if weight_type is not None:
7575
if isinstance(weight_type,str) and weight_type in measurements.rows:
@@ -86,12 +86,14 @@ def solve_wls(measurements, weight_type = None,
8686

8787
states.append([timestamp] + np.squeeze(position).tolist())
8888
except RuntimeError as error:
89-
print("RuntimeWarning: " + "gps_millis: " + str(int(timestamp)) \
90-
+ ", " + str(error))
91-
89+
warnings.warn("RuntimeError encountered at gps_millis: " \
90+
+ str(int(timestamp)) + " RuntimeError: " \
91+
+ str(error), RuntimeWarning)
9292
states = np.array(states)
9393

9494
if states.size == 0:
95+
warnings.warn("No valid state estimate computed in WLS, "\
96+
+ "returning None.", RuntimeWarning)
9597
return None
9698

9799
state_estimate = NavData()
@@ -186,7 +188,8 @@ def wls(rx_est_m, pos_sv_m, corr_pr_m, weights = None,
186188
geometry_matrix[:,:3] = np.divide(pos_rx_m - pos_sv_m,
187189
gt_r_m.reshape(-1,1))
188190

189-
191+
# assumes the use of corrected pseudoranges with the satellite
192+
# clock bias already removed
190193
pr_delta = corr_pr_m - gt_r_m - rx_est_m[3,0]
191194
try:
192195
pos_x_delta = np.linalg.pinv(geometry_matrix.T @ weight_matrix @ geometry_matrix) \

gnss_lib_py/parsers/android.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def postprocess(self):
8585
self['corr_pr_m'] = pr_corrected
8686

8787
# rename gnss_id column to constellation type
88-
constellation_map = {0.:"unkown",
88+
constellation_map = {0.:"unknown",
8989
1.:"gps",
9090
2.:"sbas",
9191
3.:"glonass",
@@ -177,7 +177,7 @@ def postprocess(self):
177177
self['corr_pr_m'] = pr_corrected
178178

179179
# rename gnss_id column to constellation type
180-
constellation_map = {0.:"unkown",
180+
constellation_map = {0.:"unknown",
181181
1.:"gps",
182182
2.:"sbas",
183183
3.:"glonass",

gnss_lib_py/parsers/navdata.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ def where(self, key_idx, value, condition="eq"):
183183
NavData with columns where given condition is satisfied
184184
for specified row
185185
"""
186-
# Add a condition here instead of just comparing to a value.
187-
# Do so by adding a parameter for less than inequality, equality and
188-
# greater than inequality
189186
new_cols = self.argwhere(key_idx, value, condition)
190187
if new_cols.size == 0:
191188
return self.remove(cols=list(range(len(self))))
@@ -242,11 +239,13 @@ def argwhere(self, key_idx, value, condition="eq"):
242239
# Find columns where value can be found and return new NavData
243240
if condition=="eq":
244241
if not isinstance(value,str) and np.isnan(value):
242+
# check isinstance b/c np.isnan can't handle strings
245243
new_cols = np.argwhere(np.isnan(self.array[row, :]))
246244
else:
247245
new_cols = np.argwhere(self.array[row, :]==value)
248246
elif condition=="neq":
249247
if not isinstance(value,str) and np.isnan(value):
248+
# check isinstance b/c np.isnan can't handle strings
250249
new_cols = np.argwhere(~np.isnan(self.array[row, :]))
251250
else:
252251
new_cols = np.argwhere(self.array[row, :]!=value)
@@ -563,7 +562,7 @@ def in_rows(self, rows):
563562

564563
if isinstance(rows,str):
565564
rows = [rows]
566-
if type(rows) in (list, np.ndarray, tuple):
565+
if isinstance(rows, (list, np.ndarray, tuple)):
567566
if isinstance(rows,np.ndarray):
568567
rows = np.atleast_1d(rows)
569568
missing_rows = ["'"+row+"'" for row in rows
@@ -716,8 +715,8 @@ def __setitem__(self, key_idx, new_value):
716715
if isinstance(key_idx, str) and key_idx not in self.map:
717716
#Creating an entire new row
718717
if isinstance(new_value, np.ndarray) \
719-
and (new_value.dtype in (object,str) \
720-
or np.issubdtype(new_value.dtype,np.dtype('U'))):
718+
and (new_value.dtype in (object,str) \
719+
or np.issubdtype(new_value.dtype,np.dtype('U'))):
721720
# Adding string values
722721
new_value = new_value.astype(str)
723722
new_str_vals = len(np.unique(new_value))*np.ones(np.shape(new_value),
@@ -759,9 +758,9 @@ def __setitem__(self, key_idx, new_value):
759758
"Cannot assign/return combination of strings and numbers"
760759
if np.all(row_str):
761760
assert isinstance(new_value, np.ndarray) \
762-
and (new_value.dtype in (object,str) \
763-
or np.issubdtype(new_value.dtype,np.dtype('U'))), \
764-
"String assignment only supported for ndarray of type object"
761+
and (new_value.dtype in (object,str) \
762+
or np.issubdtype(new_value.dtype,np.dtype('U'))), \
763+
"String assignment only supported for ndarray of type object"
765764
inv_map = self.inv_map
766765
new_value = np.atleast_2d(new_value)
767766
new_str_vals = np.ones_like(new_value, dtype=self.arr_dtype)
@@ -882,7 +881,7 @@ def _get_set_str_rows(self, rows, new_value):
882881

883882
if isinstance(new_value, np.ndarray) and (new_value.dtype in (object,str) \
884883
or np.issubdtype(new_value.dtype,np.dtype('U'))):
885-
if type(new_value.item(0)) in (int, float):
884+
if isinstance(new_value.item(0), (int, float)):
886885
row_str_new = [False]*len(row_list)
887886
else:
888887
row_str_new = [True]*len(row_list)

gnss_lib_py/utils/visualizations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
MARKERS = ["o","*","P","v","s","^","p","<","h",">","H","X","D"]
4343

4444
GNSS_ORDER = ["gps","glonass","galileo","beidou","qzss","irnss","sbas",
45-
"unkown"]
45+
"unknown"]
4646

4747
mpl.rcParams['axes.prop_cycle'] = (cycler(color=STANFORD_COLORS) \
4848
+ cycler(marker=MARKERS))
@@ -61,8 +61,8 @@ def plot_metric(navdata, *args, groupby=None, title=None, save=False,
6161
Tuple of row names that are to be plotted. If one is given, that
6262
value is plotted on the y-axis. If two values are given, the
6363
first is plotted on the x-axis and the second on the y-axis.
64-
grouby : string
65-
Row name by which to groub and label plots.
64+
groupby : string
65+
Row name by which to group and label plots.
6666
title : string
6767
Title for the plot.
6868
save : bool
@@ -688,7 +688,7 @@ def _save_figure(figures, titles=None, prefix="", fnames=None): # pragma: no cov
688688
figures = [figures]
689689
if isinstance(titles,str) or titles is None:
690690
titles = [titles]
691-
if type(fnames) in (str, pathlib.Path) or fnames is None:
691+
if isinstance(fnames, (str, pathlib.Path)) or fnames is None:
692692
fnames = [fnames]
693693

694694
for fig_idx, figure in enumerate(figures):
@@ -874,7 +874,7 @@ def _save_plotly(figures, titles=None, prefix="", fnames=None,
874874
figures = [figures]
875875
if isinstance(titles,str) or titles is None:
876876
titles = [titles]
877-
if type(fnames) in (str, pathlib.Path) or fnames is None:
877+
if isinstance(fnames, (str, pathlib.Path)) or fnames is None:
878878
fnames = [fnames]
879879

880880
for fig_idx, figure in enumerate(figures):

tests/algorithms/test_snapshot.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def test_wls_fails(capsys):
475475
captured = capsys.readouterr()
476476
assert captured.out == "SVD did not converge\n"
477477

478-
def test_solve_wls_fails(capsys, derived):
478+
def test_solve_wls_fails(derived):
479479
"""Test expected fails
480480
481481
Parameters
@@ -487,7 +487,21 @@ def test_solve_wls_fails(capsys, derived):
487487

488488
navdata = derived.remove(cols=list(range(3,len(derived))))
489489

490-
solve_wls(navdata)
491-
captured = capsys.readouterr()
492-
assert "gps_millis" in captured.out
493-
assert "four satellites" in captured.out
490+
with pytest.warns(RuntimeWarning) as warns:
491+
solve_wls(navdata)
492+
493+
# verify RuntimeWarning
494+
assert len(warns) == 2
495+
496+
caught_four_sats = False
497+
caught_empty_state = False
498+
for warn in warns:
499+
assert issubclass(warn.category, RuntimeWarning)
500+
assert "WLS" in str(warn.message)
501+
if "four satellites" in str(warn.message):
502+
caught_four_sats = True
503+
elif "No valid state" in str(warn.message):
504+
caught_empty_state = True
505+
506+
assert caught_four_sats
507+
assert caught_empty_state

tests/parsers/test_navdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ def test_multi_set_changing_type(data,new_string):
11841184
[slice(7, 8),
11851185
8])
11861186
def test_wrong_init_set(row_idx):
1187-
""" Test init with unkown set.
1187+
""" Test init with unknown set.
11881188
11891189
"""
11901190
empty_data = NavData()

tests/utils/test_visualizations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ def test_sort_gnss_ids():
424424
425425
"""
426426

427-
unsorted_ids = ["galileo","beta","beidou","irnss","gps","unkown","glonass",
427+
unsorted_ids = ["galileo","beta","beidou","irnss","gps","unknown","glonass",
428428
"alpha","qzss","sbas"]
429429
sorted_ids = ["gps","glonass","galileo","beidou","qzss","irnss","sbas",
430-
"unkown", "alpha", "beta"]
430+
"unknown", "alpha", "beta"]
431431

432432
assert viz._sort_gnss_ids(unsorted_ids) == sorted_ids
433433
assert viz._sort_gnss_ids(np.array(unsorted_ids)) == sorted_ids

0 commit comments

Comments
 (0)