Skip to content

Commit

Permalink
NPI-3655 improve readability of getVelPoly() function with more descr…
Browse files Browse the repository at this point in the history
…iptive variable names
  • Loading branch information
treefern committed Dec 18, 2024
1 parent 848d383 commit 50ae880
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions gnssanalysis/gn_io/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,28 +477,28 @@ def getVelPoly(sp3Df: _pd.DataFrame, deg: int = 35) -> _pd.DataFrame:
"""
est = sp3Df.unstack(1).EST[["X", "Y", "Z"]]
x = est.index.get_level_values("J2000").values
# x = est.index.values
y = est.values
time_values = est.index.get_level_values("J2000").values
xyz_positions = est.values

off, scl = mapparm([x.min(), x.max()], [-1, 1]) # map from input scale to [-1,1]
# map from input scale to [-1,1]
offset, scale_factor = mapparm([time_values.min(), time_values.max()], [-1, 1])

x_new = off + scl * (x)
coeff = _np.polyfit(x=x_new, y=y, deg=deg)
normalised_time_values = offset + scale_factor * (time_values)
coeff = _np.polyfit(x=normalised_time_values, y=xyz_positions, deg=deg)

x_prev = off + scl * (x - 1)
x_next = off + scl * (x + 1)
time_prev = offset + scale_factor * (time_values - 1)
time_next = offset + scale_factor * (time_values + 1)

xx_prev_combined = _np.broadcast_to((x_prev)[None], (deg + 1, x_prev.shape[0]))
xx_next_combined = _np.broadcast_to((x_next)[None], (deg + 1, x_prev.shape[0]))
time_prev_sqrd_combined = _np.broadcast_to((time_prev)[None], (deg + 1, time_prev.shape[0]))
time_next_sqrd_combined = _np.broadcast_to((time_next)[None], (deg + 1, time_prev.shape[0]))

inputs_prev = xx_prev_combined ** _np.flip(_np.arange(deg + 1))[:, None]
inputs_next = xx_next_combined ** _np.flip(_np.arange(deg + 1))[:, None]
inputs_prev = time_prev_sqrd_combined ** _np.flip(_np.arange(deg + 1))[:, None]
inputs_next = time_next_sqrd_combined ** _np.flip(_np.arange(deg + 1))[:, None]

res_prev = coeff.T.dot(inputs_prev)
res_next = coeff.T.dot(inputs_next)
vel_i = _pd.DataFrame(
(((y - res_prev.T) + (res_next.T - y)) / 2),
(((xyz_positions - res_prev.T) + (res_next.T - xyz_positions)) / 2),
columns=est.columns,
index=est.index,
).stack(future_stack=True)
Expand Down

0 comments on commit 50ae880

Please sign in to comment.