Bladeren bron

Adds only calculation mode.

master
Lukas Prause 2 jaren geleden
bovenliggende
commit
37412e4f96
1 gewijzigde bestanden met toevoegingen van 17 en 6 verwijderingen
  1. +17
    -6
      plot_gps.py

+ 17
- 6
plot_gps.py Bestand weergeven

@@ -23,7 +23,8 @@ def csv_to_dataframe(csv_list, dummy):
"{}{}".format(args.pcap_csv_folder, csv),
dtype=dict(is_retranmission=bool, is_dup_ack=bool),
)
tmp_df["datetime"] = pd.to_datetime(tmp_df["datetime"]) - pd.Timedelta(hours=1)
#tmp_df["datetime"] = pd.to_datetime(tmp_df["datetime"]) - pd.Timedelta(hours=1)
tmp_df["datetime"] = pd.to_datetime(tmp_df["datetime"])
tmp_df = tmp_df.set_index("datetime")
tmp_df.index = pd.to_datetime(tmp_df.index)
if transmission_df is None:
@@ -53,6 +54,8 @@ if __name__ == "__main__":
parser.add_argument("-l", "--label", help="Label above the plot.")
parser.add_argument("--no_legend", action="store_false", default=True, help="Do not show legend.")
parser.add_argument("--save", default=None, help="Location to save pdf file.")
parser.add_argument("--time_offset", default=None, type=int, help="Minutes added to GPS datetime.")
parser.add_argument("--no_plot", default=False, type=bool, help="Only calculations without plotting.")

parser.add_argument(
"--show_providerinfo",
@@ -138,6 +141,10 @@ if __name__ == "__main__":
# load dataframe an put it into geopandas
df = pd.read_csv(args.gps_file)
df["kmh"] = df["speed (knots)"].apply(lambda x: x * 1.852)
if args.time_offset:
df["datetime"] = pd.to_datetime(df["datetime"]) + pd.Timedelta(minutes=args.time_offset)
else:
df["datetime"] = pd.to_datetime(df["datetime"])
df = df.set_index("datetime")
df.index = pd.to_datetime(df.index)

@@ -156,7 +163,8 @@ if __name__ == "__main__":

# read serial csv
serial_df = pd.read_csv(args.serial_file)
serial_df["datetime"] = pd.to_datetime(serial_df["datetime"]) - pd.Timedelta(hours=1)
#serial_df["datetime"] = pd.to_datetime(serial_df["datetime"]) - pd.Timedelta(hours=1)
serial_df["datetime"] = pd.to_datetime(serial_df["datetime"])
serial_df = serial_df.set_index("datetime")
serial_df.index = pd.to_datetime(serial_df.index)

@@ -168,14 +176,17 @@ if __name__ == "__main__":
left_index=True,
)

print(gdf)

print("Start plotting...")
# format to needed format and add basemap as background
df_wm = gdf.to_crs(epsg=3857)
#df_wm.to_csv("debug-data.csv")
# ax2 = df_wm.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
print(df_wm)
if args.no_plot:
df_wm.to_csv("{}gps_plot.csv".format(args.save))
print("Saved calculations to: {}gps_plot.csv".format(args.save))
exit(0)

print("Start plotting...")

ax2 = df_wm.plot()
ax2 = df_wm.plot(args.column, cmap="hot", legend=args.no_legend, ax=ax2)
# ax2 = df_wm.plot.scatter(x="longitude", y="latitude", c="kmh", cmap="hot")

Laden…
Annuleren
Opslaan