stilt.observations.releases_from_track#

stilt.observations.releases_from_track(track, *, every=None, spacing=None, altitude_ref='agl', gap='10min')[source]#

Return a release for each group of measurements along a track, and their table.

The measurements are grouped by time (every) or by distance along the track (spacing), and each group becomes one PointRelease at the mean time and position of its measurements.

Parameters:
  • track (DataFrame) – One row per measurement, with the columns in TRACK_SCHEMA, screened as you like. Its rows may come in any order.

  • every (str | timedelta | None) – Length of each group in time, such as "5min". Groups start on the clock: with "5min", at 18:00, 18:05, and so on. Five minutes when spacing is not given either.

  • spacing (float | None) – Length of each group along the track, in meters, in place of every. The distance is summed between consecutive measurements.

  • altitude_ref (Literal['agl', 'msl']) – Whether altitude is above ground (an inlet on a vehicle) or above sea level (an aircraft’s GPS altitude).

  • gap (str | timedelta) – A pause in the track longer than this ends a group, so a group never holds measurements from both sides of it.

Return type:

tuple[list[PointRelease], DataFrame]

Returns:

  • releases (list of PointRelease) – One per group, in time order. Two groups whose rounded time and position agree share one release.

  • table (pandas.DataFrame) – The track, in its own row order and index, with a release column holding each measurement’s release id. An existing release column is replaced. Keep it in the project with project.add_table("track", table).

Raises:

ValueError – If the track lacks a column in TRACK_SCHEMA or a value in one, if it has no rows, if both every and spacing are given, or if every, spacing, or gap is not positive.

Notes

A release’s time is its group’s mean time, rounded to the nearest minute, because a run starts on a whole minute. Its longitude and latitude are the mean position, rounded to 5 decimals (about 1 m), and its altitude the mean height, rounded to 0.1 m. The mean longitude of a group that crosses 180 degrees is taken across it.

A release stands for a stretch of track, so the release of a group that turns is inside the turn. Groups by every are as long as the distance the platform covers in that time; give an aircraft spacing to keep them short. With spacing, a platform that stands still and keeps measuring stays in one group until it moves on or pauses for longer than gap.

Examples

Ten minutes of a car driving east at about 10 m/s, measured every second:

>>> track = pd.DataFrame(
...     {
...         "time": pd.date_range("2024-07-01 18:00", periods=600, freq="1s"),
...         "longitude": np.linspace(-111.90, -111.83, 600),
...         "latitude": 40.76,
...         "altitude": 3.0,
...     }
... )
>>> releases, table = releases_from_track(track, every="5min")
>>> [r.id for r in releases]
['202407011802_-111.88253_40.76_3', '202407011807_-111.84747_40.76_3']
>>> table["release"].value_counts().tolist()
[300, 300]

In a project:

>>> project.add_releases(releases)
>>> project.add_table("track", table)