Open callumrollo opened 7 months ago
Here's the function you want for a simple linear interpolation in Python https://docs.scipy.org/doc/scipy/tutorial/interpolate/1D.html#tutorial-interpolate-1dsection
Try something like:
import numpy as np import datetime import pandas as pd import matplotlib.pyplot as plt original_lat = [50, 51] original_lon = [1, 2] original_datetime = pd.date_range(datetime.datetime(1990,1,2,5,0), datetime.datetime(1990,1,2,5,10), freq='600s') # waypoints from nav every 5 mins video_datetime = pd.date_range(datetime.datetime(1990,1,2,5,0), datetime.datetime(1990,1,2,5,10), freq='100ms') # 10 minutes of video @ 10 Hz = 6000 frames video_lon = np.interp(video_datetime, original_datetime, original_lon) # interp lon video_lat = np.interp(video_datetime, original_datetime, original_lat) # interp lat video_locations = pd.DataFrame({'datetime':video_datetime, 'lon': video_lon, 'lat': video_lat}) video_locations.to_csv('video_locations_interpolated.csv')
The only tricky part of this is dealing with datetimes, as always
Plotting up quick
fig, ax = plt.subplots() ax.scatter(video_lon, video_lat, s=1, label="video frames") ax.scatter(original_lon, original_lat, label="ROV turns") ax.legend()
Thank you very much for the tip, Callum! I will probably try to make something like this in the future.
Here's the function you want for a simple linear interpolation in Python https://docs.scipy.org/doc/scipy/tutorial/interpolate/1D.html#tutorial-interpolate-1dsection
Try something like:
The only tricky part of this is dealing with datetimes, as always
Plotting up quick