1
1
Getting started
2
2
===============
3
3
4
+ .. jupyter-execute ::
5
+ :hide-code:
6
+ :hide-output:
7
+
8
+ %matplotlib inline
9
+
4
10
The motivation for this page/notebook is to take the reader through all
5
11
basic functionalities of the traffic library. In particular, we will cover:
6
12
@@ -78,7 +84,7 @@ Flight objects
78
84
79
85
Information about each :class: `~traffic.core.Flight ` is available through
80
86
attributes or properties:
81
-
87
+
82
88
.. jupyter-execute ::
83
89
84
90
dict(belevingsvlucht)
@@ -89,7 +95,7 @@ Flight objects
89
95
:attr: `~traffic.core.Flight.stop ` properties refer to the timestamps of the
90
96
first and last recorded samples. Note that all timestamps are by default set
91
97
to universal time (UTC) as it is common practice in aviation.
92
-
98
+
93
99
.. jupyter-execute ::
94
100
95
101
(belevingsvlucht.start, belevingsvlucht.stop)
@@ -103,7 +109,7 @@ Flight objects
103
109
104
110
Note the difference between the "strict" comparison (:math: `>`) vs. "or
105
111
equal" comparison (:math: `\geq `)
106
-
112
+
107
113
.. jupyter-execute ::
108
114
109
115
belevingsvlucht.after("2018-05-30 19:00", strict=False)
@@ -113,7 +119,7 @@ Flight objects
113
119
Each :class: `~traffic.core.Flight ` is wrapped around a
114
120
:class: `pandas.DataFrame `: when no method is available for your
115
121
particular need, you can always access the underlying dataframe.
116
-
122
+
117
123
.. jupyter-execute ::
118
124
119
125
belevingsvlucht.between("2018-05-30 19:00", "2018-05-30 20:00").data
@@ -147,14 +153,14 @@ Traffic objects
147
153
- a combination of ``timestamp `` and ``icao24 `` (aircraft identifier);
148
154
149
155
Indexation will be made on:
150
-
156
+
151
157
- ``icao24 ``, ``callsign `` (or ``flight_id `` if available):
152
158
153
159
.. jupyter-execute ::
154
160
155
161
quickstart["TAR722"] # return type: Flight, based on callsign
156
162
quickstart["39b002"] # return type: Flight, based on icao24
157
-
163
+
158
164
- an integer or a slice, to take flights in order in the collection:
159
165
160
166
.. jupyter-execute ::
@@ -179,8 +185,8 @@ Traffic objects
179
185
180
186
There are several ways to assign a flight identifier. The most simple one
181
187
that you will use in 99% of situations involves the
182
- :meth: `~traffic.core.Flight.flight_id ` method.
183
-
188
+ :meth: `~traffic.core.Flight.flight_id ` method.
189
+
184
190
.. jupyter-execute ::
185
191
186
192
quickstart.assign_id().eval()
@@ -241,7 +247,7 @@ visualisation renderers including `Matplotlib <https://matplotlib.org/>`_ and
241
247
Even a simple visualisation without an physical features plotted on the
242
248
y-channel can be meaningful. The following proposition helps visualising when
243
249
aircraft are airborne:
244
-
250
+
245
251
.. jupyter-execute ::
246
252
247
253
import altair as alt
@@ -261,7 +267,7 @@ visualisation renderers including `Matplotlib <https://matplotlib.org/>`_ and
261
267
262
268
The y-channel is however most often used to plot physical quantities such as
263
269
altitude, ground speed, or more.
264
-
270
+
265
271
.. jupyter-execute ::
266
272
267
273
alt.layer(
@@ -373,7 +379,7 @@ It is often a good practice to just plot the data as is before we get an idea of
373
379
how to proceed.
374
380
375
381
376
- .. jupyter-execute ::
382
+ .. jupyter-execute ::
377
383
378
384
with plt.style.context("traffic"):
379
385
fig, ax = plt.subplots(subplot_kw=dict(projection=Lambert93()))
@@ -404,15 +410,15 @@ color based on the vertical rate average value.
404
410
This approach is not perfect (there are quite some green trajectories) but gives
405
411
a good first idea of how traffic organises itself. Let's try to focus on the
406
412
traffic to and from one airport, e.g. ``LFPO ``, in order to refine the
407
- methodology.
413
+ methodology.
408
414
409
415
A first approach to select those trajectories would be to pick the first/last
410
416
point of the :class: `~traffic.core.Flight ` and check whether it falls within the
411
417
geographical scope of the airport. In the following snippet, we do things a bit
412
418
differently: we check whether the first/last 5 minutes of the trajectory
413
419
intersects the shape of the airport.
414
420
415
- .. jupyter-execute ::
421
+ .. jupyter-execute ::
416
422
417
423
from traffic.data import airports
418
424
@@ -483,7 +489,7 @@ matching, and extract relevant information (the runway information):
483
489
stats
484
490
485
491
486
- .. jupyter-execute ::
492
+ .. jupyter-execute ::
487
493
488
494
chart = (
489
495
alt.Chart(stats)
@@ -622,7 +628,7 @@ There are several ways to collect trajectories:
622
628
- the :meth: `~traffic.core.Traffic.from_flights ` class method builds a
623
629
:class: `~traffic.core.Traffic ` object from an iterable structure of
624
630
:class: `~traffic.core.Flight ` objects. It is more robust than the sum()
625
- Python function as it will ignore ``None `` objects which may be found in the
631
+ Python function as it will ignore ``None `` objects which may be found in the
626
632
iterable.
627
633
628
634
.. jupyter-execute ::
@@ -646,7 +652,7 @@ There are several ways to collect trajectories:
646
652
trajectory preprocessing operations. Operations are stacked before being
647
653
evaluated in a single iteration, using multiprocessing if needed, only after
648
654
the specification is fully described.
649
-
655
+
650
656
*Lazy evaluation * is a common wording in functional programming languages.
651
657
It refers to a mechanism where the actual evaluation is deferred.
652
658
@@ -662,7 +668,7 @@ remember that:
662
668
stacked method to every :class: `~traffic.core.Flight ` it can iterate on.
663
669
- If one of the methods returns ``False `` or ``None ``, the
664
670
:class: `~traffic.core.Flight ` is discarded;
665
- - If one of the methods returns ``True ``, the :class: `~traffic.core.Flight ` is
671
+ - If one of the methods returns ``True ``, the :class: `~traffic.core.Flight ` is
666
672
passed as is not the next method.
667
673
668
674
The landing trajectory selection rewrites as:
@@ -685,7 +691,7 @@ The landing trajectory selection rewrites as:
685
691
The :meth: `~traffic.core.Flight.aligned_on_ils ` call (without considerations
686
692
on the vertical rate and intersections) is actually enough for our needs
687
693
here, but more methods were stacked for explanatory purposes.
688
-
694
+
689
695
690
696
For reference, look at the subtle differences between the following processing:
691
697
@@ -698,8 +704,8 @@ For reference, look at the subtle differences between the following processing:
698
704
.has("aligned_on_ils('LFPO')")
699
705
.last('10 min')
700
706
.eval(max_workers=4)
701
- )
702
-
707
+ )
708
+
703
709
with plt.style.context('traffic'):
704
710
fig, ax = plt.subplots(subplot_kw=dict(projection=Lambert93()))
705
711
t1.plot(ax, color="#f58518")
@@ -708,7 +714,7 @@ For reference, look at the subtle differences between the following processing:
708
714
runways=dict(linewidth=1, color='black', zorder=3)
709
715
)
710
716
ax.spines['geo'].set_visible(False)
711
-
717
+
712
718
- take the last minute of the segment of trajectory which is aligned on runway 06:
713
719
714
720
.. jupyter-execute ::
0 commit comments