pandas_x.algorithms module¶
- pandas_x.algorithms.ds_from_s(distance)[source]¶
Calculate point-to-point displacements from cumulative distances.
The chosen scheme: displacement at [i] represents the distance from [i-1] to [i].
- Parameters
distance (pandas.Series) – cumulative distances along the route in meters. Must be numeric dtype.
- Returns
point-to-point displacements along the route in meters.
- Return type
pandas.Series
- pandas_x.algorithms.ds_from_xy(lat, lon)[source]¶
Calculate point-to-point displacements from GPS coordinates.
The chosen scheme: displacement at [i] represents the distance from [i-1] to [i].
- Parameters
lat (pandas.Series) – latitude coordinates along the route in degrees N (-90, 90). Must be numeric dtype.
lon (pandas.Series) – longitude coordinates along the route in degrees E (-180, 180). Must be numeric dtype.
- Returns
point-to-point displacements along the route in meters.
- Return type
pandas.Series
- Assumptions:
Earth is a perfect sphere, with radius =
pandas_x.scalar.EARTH_RADIUS_METERS.The point-to-point distances are sufficiently short (so that latitude distortion and curvature have limited effects).
- pandas_x.algorithms.reduced_point_index(lat, lon, min_dist=15.0)[source]¶
Eliminates gps points that are too close together.
No matter how far apart the points, always returns the start and end points.
Originally developed in my mapmatching package; an old version still exists there.
- Parameters
lat (pandas.Series) – latitude values along the path.
lon (pandas.Series) – longitude values along the path.
min_dist (float) – The minimum distance (meters) between the resulting downsampled GPS coordinates. Default 15.
- Returns
A boolean array that can be used to subsample a
pandas.Seriescorresponding to this GPS trace, based on this minimum distance scheme.- Return type
list
- pandas_x.algorithms.s_from_ds(displacement)[source]¶
Calculate cumulative distances from point-to-point displacements.
The chosen scheme: displacement at [i] represents the distance from [i-1] to [i]. This scheme means converting displacements to cumulative distances does not require any extrapolation.
- Parameters
displacement (pandas.Series) – point-to-point displacements along the route in meters. Must be numeric dtype.
- Returns
cumulative distances along the route in meters.
- Return type
pandas.Series
- pandas_x.algorithms.s_from_v(speed, time=None)[source]¶
Calculate point-to-point displacements from speed.
The chosen scheme: speed at [i] represents the distance from [i] to [i+1]. This means distance.diff() and time.diff() are shifted by one index from speed. I have chosen to extrapolate the position at the first index by assuming we start at a cumulative distance of 0.
- Parameters
speed (pandas.Series) – speed along the route in meters per second. Must be numeric dtype.
time (pandas.Series) – cumulative time from start along the route in seconds. Must be numeric dtype. Default None.
- Returns
point-to-point displacements along the route in meters.
- Return type
pandas.Series
- pandas_x.algorithms.v_from_ds(displacement, time=None)[source]¶
Calculate speed from point-to-point displacements.
The chosen scheme: displacement at [i] represents the distance from [i-1] to [i], while speed at [i] represents the distance from [i] to [i+1]. This means displacements and time.diff() are shifted by one index from speed. I have chosen to extrapolate the speed at the final position by ffill.
- Parameters
displacement (pandas.Series) – point-to-point displacements along the route in meters. Must be numeric dtype.
time (pandas.Series) – cumulative time from start along the route in seconds. Must be numeric dtype. Default None.
- Returns
speed along the route in meters per second.
- Return type
pandas.Series
- pandas_x.algorithms.v_from_s(distance, time=None)[source]¶
Calculate speed from cumulative distances.
The chosen scheme: speed at [i] represents the distance from [i] to [i+1]. This means distance.diff() and time.diff() are shifted by one index from speed. I have chosen to extrapolate the speed at the final position by ffill.
- Parameters
distance (pandas.Series) – cumulative distances along the route in meters. Must be numeric dtype.
time (pandas.Series) – cumulative time from start along the route in seconds. Must be numeric dtype. Default None.
- Returns
speed along the route in meters per second.
- Return type
pandas.Series