tobac
tobac copied to clipboard
Allow for variable `dt` (and maximum delta time) in tracking
There are many instances in observational data where the delta-time is not held fixed, or where data gaps are present. tobac does not currently deal with this, instead asking users to come up with a constant dt
in tracking. I've started to get questions (and feature requests) for dealing with this, and I think this would be a good problem to solve.
We may be able to do it within our current framework, and within trackpy. At first glance, I think it will require a clever solution (at least without modifying trackpy). We could do it somewhat simply if we can find a way to allow for running trackpy semi-independently for each timestep (which we may be able to do through initial_guess_vels
: http://soft-matter.github.io/trackpy/dev/generated/trackpy.predict.NearestVelocityPredict.html#trackpy.predict.NearestVelocityPredict).
Had a quick dig into the trackpy.predict.NearestVelocityPredict
and found that it already supports variable dt (atleast in v0.6.0):
https://github.com/soft-matter/trackpy/blob/d4ff59f4c844b5bc90a1aa7325b43cbeccae1546/trackpy/predict.py#L168-L177
t_column
is found from either 't_column' or 'frame' in the input dataframe, so we could add an extra t_column
column to the track dataframe with values as time difference in seconds from the first frame, and possibly renaming frame
temporarily.
The main challenge would be to update search_range
for each step if v_max
is provided. I think the only way to do this would be to replicate trackpy.link_iter
but update Linker.search_range
for each iteration based on the dt of that time step.