remisalmon / gpx-interpolate

Python function to interpolate GPX data using piecewise cubic Hermite splines
MIT License
49 stars 12 forks source link

Timestamp smoothing #5

Closed goamberg closed 4 years ago

goamberg commented 4 years ago

Hi

Is it possible also to smooth the timestamps a little? These are calculated speed graphs image Green line is the original (raw) Red line is with -d5 -r 0.5 Blue line is with -d5 r 0.25 (I also tested -d3 with similar results)

It seems to try to over- and undercorrect. I checked on "splprep" for the timestamps and tried some other values there, but I am not getting anywhere with it it seems.

Cheers Goam

remisalmon commented 4 years ago

Try commenting those lines:

    lat_interp = np.round(lat_interp*1e6)/1e6
    lon_interp = np.round(lon_interp*1e6)/1e6
    ele_interp = np.round(ele_interp*1e6)/1e6
    tstamp_interp = np.round(tstamp_interp*1e2)/1e2

That will create larger GPX files but I suspect 1e-6 precision is not sufficient with small resolution such as yours.

goamberg commented 4 years ago

I used rounding to 10 digits for the lat and lon and 3 digits for the elevation with this. Time I used with 4 digits. The track in lat/lon/ele is perfect! I checked several lines in QGIS now and it is exact! That part is already awesome.

But here is a test with commenting all 4 image red line is original track - green is interpolated again calculated speed to set position and timestamps into a relation

Time stamps are strange like this. It seems they are to late at one point, and try to catch up at the next point.

remisalmon commented 4 years ago

Can you share the gpx file, as well as the interpolation degree and resolution?

goamberg commented 4 years ago

sure thing lap1.zip lap1.gpx - original file lap1_interpolated.gpx - interpolated with: -d 5 -r 0.1 lap1_w_speed.gpx - calculated speed from lap1.gpx directly lap1_interpolated_w_speed.gpx - calculated speed from interpolated file

I have 2 more laps tested like this, if you need more data.

goamberg commented 4 years ago

You were right all along with the rounding of the time digits. While your script can make many calculated time digits, my programs seem only to use milliseconds. With my edge cases this is not enough and would need 4 or more digits.

These jumps are when its for example between 5 or 6 ms between points. But your script is more at 5.4.. to 5.5..

Now I have to find programs that can take advantage of this, but that is certainly not your problem ;-) Sorry for wasting your time on this