| "{}{}".format(args.pcap_csv_folder, csv), | "{}{}".format(args.pcap_csv_folder, csv), | ||||
| dtype=dict(is_retranmission=bool, is_dup_ack=bool), | 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 = tmp_df.set_index("datetime") | ||||
| tmp_df.index = pd.to_datetime(tmp_df.index) | tmp_df.index = pd.to_datetime(tmp_df.index) | ||||
| if transmission_df is None: | if transmission_df is None: | ||||
| parser.add_argument("-l", "--label", help="Label above the plot.") | 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("--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("--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( | parser.add_argument( | ||||
| "--show_providerinfo", | "--show_providerinfo", | ||||
| # load dataframe an put it into geopandas | # load dataframe an put it into geopandas | ||||
| df = pd.read_csv(args.gps_file) | df = pd.read_csv(args.gps_file) | ||||
| df["kmh"] = df["speed (knots)"].apply(lambda x: x * 1.852) | 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 = df.set_index("datetime") | ||||
| df.index = pd.to_datetime(df.index) | df.index = pd.to_datetime(df.index) | ||||
| # read serial csv | # read serial csv | ||||
| serial_df = pd.read_csv(args.serial_file) | 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 = serial_df.set_index("datetime") | ||||
| serial_df.index = pd.to_datetime(serial_df.index) | serial_df.index = pd.to_datetime(serial_df.index) | ||||
| left_index=True, | left_index=True, | ||||
| ) | ) | ||||
| print(gdf) | |||||
| print("Start plotting...") | |||||
| # format to needed format and add basemap as background | # format to needed format and add basemap as background | ||||
| df_wm = gdf.to_crs(epsg=3857) | df_wm = gdf.to_crs(epsg=3857) | ||||
| #df_wm.to_csv("debug-data.csv") | #df_wm.to_csv("debug-data.csv") | ||||
| # ax2 = df_wm.plot(figsize=(10, 10), alpha=0.5, edgecolor='k') | # 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() | ||||
| ax2 = df_wm.plot(args.column, cmap="hot", legend=args.no_legend, ax=ax2) | 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") | # ax2 = df_wm.plot.scatter(x="longitude", y="latitude", c="kmh", cmap="hot") |