Skip to content

Instantly share code, notes, and snippets.

@cbassa
Created April 8, 2022 13:58
Show Gist options
  • Save cbassa/3149152c8c642e2e93ac71910713b86e to your computer and use it in GitHub Desktop.
Save cbassa/3149152c8c642e2e93ac71910713b86e to your computer and use it in GitHub Desktop.
Sanitize Bobcat-1 GPS measurements
#!/usr/bin/env python3
import sys
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import ascii
if __name__ == "__main__":
d = ascii.read(sys.argv[1])
del d["col1"]
d.remove_row(0)
d.rename_column("col2", "GPSWeek")
d.rename_column("col3", "GPSSeconds")
d.rename_column("col4", "PosX")
d.rename_column("col5", "PosY")
d.rename_column("col6", "PosZ")
d.rename_column("col7", "VelX")
d.rename_column("col8", "VelY")
d.rename_column("col9", "VelZ")
d["GPSSeconds"] = d["GPSSeconds"].astype("float") / 1000.0
for col in d.columns:
d[col] = d[col].astype("float")
_, idx = np.unique(d["GPSSeconds"], return_index=True)
d = d[idx]
d["idx"] = np.arange(len(d))
d.write("sanitized.csv", overwrite=True, format="csv")
r = np.sqrt(d["PosX"]**2 + d["PosY"]**2 + d["PosZ"]**2)
fig, ax = plt.subplots()
texts = [f" {i}" for i in range(len(d))]
ax.plot(d["GPSSeconds"], r, ".")
for x, y, text in zip(d["GPSSeconds"], r, texts):
ax.text(x, y, text)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment