Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/traffic/algorithms/metadata/flightplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def most_probable_navpoints(
) -> Iterator[pd.DataFrame]:
table = self.all_aligned_segments(traj, all_points)
for block in self.groupby_intervals(table):
d_max = block.eval("duration.max()")
d_max = block.eval("duration.max()", engine="python")
t_threshold = d_max - pd.Timedelta("30s") # noqa: F841
yield (
block.sort_values("shift_mean")
Expand Down
8 changes: 6 additions & 2 deletions src/traffic/algorithms/navigation/holding_pattern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def apply(self, flight: Flight) -> Iterator[Flight]:
window = window.assign(flight_id=str(i))
resampled = window.resample(self.samples)

if resampled.data.eval("track.isnull()").any():
if resampled.data.eval(
"track.isnull()", engine="python"
).any():
continue

features = (
Expand All @@ -99,7 +101,9 @@ def apply(self, flight: Flight) -> Iterator[Flight]:
).values.reshape(1, -1)

if self.vertical_rate:
if resampled.data.eval("vertical_rate.notnull()").any():
if resampled.data.eval(
"vertical_rate.notnull()", engine="python"
).any():
continue
vertical_rates = (
resampled.data.vertical_rate.values.reshape(1, -1)
Expand Down
4 changes: 3 additions & 1 deletion src/traffic/core/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def __eq__(self, other: Any) -> bool:

def total_duration(self) -> pd.Timedelta:
"""Returns the sum of durations of all intervals."""
return self.consolidate().data.eval("(stop - start).sum()")
return self.consolidate().data.eval(
"(stop - start).sum()", engine="python"
)

def __radd__(self, other: Literal[0] | Interval) -> IntervalCollection:
if other == 0:
Expand Down
14 changes: 9 additions & 5 deletions src/traffic/data/datasets/flightradar24.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def from_csv(cls, filename: str | Path) -> Flight:
timestamp = @pd.to_datetime(timestamp, unit='s', utc=True)
latitude = Position.str.split(",").str[0].astype("float")
longitude = Position.str.split(",").str[1].astype("float")
"""
""",
engine="python",
)
.drop(columns=["UTC", "Position"])
)
Expand All @@ -71,7 +72,8 @@ def from_csv(cls, filename: str | Path) -> Flight:
timestamp = timestamp.str.replace("Z", "")
timestamp = @pd.to_datetime(timestamp, utc=True)
icao24 = icao24.str.slice(2)
"""
""",
engine="python",
)
.drop(
columns=[
Expand Down Expand Up @@ -111,13 +113,14 @@ def from_json(cls, filename: str | Path) -> Flight:
pd.json_normalize(
[elt["ems"] for elt in flight["track"] if elt["ems"]]
)
.eval("mach = mach / 1000")
.eval("mach = mach / 1000", engine="python")
.rename(columns=dict(ts="timestamp"))
)
data = pd.concat([data, ems_data]).sort_values("timestamp")
data = (
data.eval(
"timestamp = @pd.to_datetime(timestamp, unit='s', utc=True)"
"timestamp = @pd.to_datetime(timestamp, unit='s', utc=True)",
engine="python",
)
.assign(
flight_id=flight["identification"]["id"],
Expand Down Expand Up @@ -255,7 +258,8 @@ def extract_flights(
),
on="flight_id",
).eval(
"timestamp = @pd.to_datetime(snapshot_id, utc=True, unit='s')"
"timestamp = @pd.to_datetime(snapshot_id, utc=True, unit='s')",
engine="python",
)
)

Expand Down
6 changes: 4 additions & 2 deletions src/traffic/data/eurocontrol/aixm/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ def parse_data(self) -> pd.DataFrame:
pd.concat(
[
self.data_routes.query("prefix.notnull()").eval(
"name = prefix + secondLetter + number"
"name = prefix + secondLetter + number",
engine="python",
),
self.data_routes.query("prefix.isnull()").eval(
"name = secondLetter + number"
"name = secondLetter + number",
engine="python",
),
]
)
Expand Down