Skip to content

Commit a5d8836

Browse files
committed
1 parent 9994412 commit a5d8836

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

docs/quickstart.rst

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Getting started
22
===============
33

4+
.. jupyter-execute::
5+
:hide-code:
6+
:hide-output:
7+
8+
%matplotlib inline
9+
410
The motivation for this page/notebook is to take the reader through all
511
basic functionalities of the traffic library. In particular, we will cover:
612

@@ -78,7 +84,7 @@ Flight objects
7884

7985
Information about each :class:`~traffic.core.Flight` is available through
8086
attributes or properties:
81-
87+
8288
.. jupyter-execute::
8389

8490
dict(belevingsvlucht)
@@ -89,7 +95,7 @@ Flight objects
8995
:attr:`~traffic.core.Flight.stop` properties refer to the timestamps of the
9096
first and last recorded samples. Note that all timestamps are by default set
9197
to universal time (UTC) as it is common practice in aviation.
92-
98+
9399
.. jupyter-execute::
94100

95101
(belevingsvlucht.start, belevingsvlucht.stop)
@@ -103,7 +109,7 @@ Flight objects
103109

104110
Note the difference between the "strict" comparison (:math:`>`) vs. "or
105111
equal" comparison (:math:`\geq`)
106-
112+
107113
.. jupyter-execute::
108114

109115
belevingsvlucht.after("2018-05-30 19:00", strict=False)
@@ -113,7 +119,7 @@ Flight objects
113119
Each :class:`~traffic.core.Flight` is wrapped around a
114120
:class:`pandas.DataFrame`: when no method is available for your
115121
particular need, you can always access the underlying dataframe.
116-
122+
117123
.. jupyter-execute::
118124

119125
belevingsvlucht.between("2018-05-30 19:00", "2018-05-30 20:00").data
@@ -147,14 +153,14 @@ Traffic objects
147153
- a combination of ``timestamp`` and ``icao24`` (aircraft identifier);
148154

149155
Indexation will be made on:
150-
156+
151157
- ``icao24``, ``callsign`` (or ``flight_id`` if available):
152158

153159
.. jupyter-execute::
154160

155161
quickstart["TAR722"] # return type: Flight, based on callsign
156162
quickstart["39b002"] # return type: Flight, based on icao24
157-
163+
158164
- an integer or a slice, to take flights in order in the collection:
159165

160166
.. jupyter-execute::
@@ -179,8 +185,8 @@ Traffic objects
179185

180186
There are several ways to assign a flight identifier. The most simple one
181187
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+
184190
.. jupyter-execute::
185191

186192
quickstart.assign_id().eval()
@@ -241,7 +247,7 @@ visualisation renderers including `Matplotlib <https://matplotlib.org/>`_ and
241247
Even a simple visualisation without an physical features plotted on the
242248
y-channel can be meaningful. The following proposition helps visualising when
243249
aircraft are airborne:
244-
250+
245251
.. jupyter-execute::
246252

247253
import altair as alt
@@ -261,7 +267,7 @@ visualisation renderers including `Matplotlib <https://matplotlib.org/>`_ and
261267
262268
The y-channel is however most often used to plot physical quantities such as
263269
altitude, ground speed, or more.
264-
270+
265271
.. jupyter-execute::
266272

267273
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
373379
how to proceed.
374380

375381

376-
.. jupyter-execute::
382+
.. jupyter-execute::
377383

378384
with plt.style.context("traffic"):
379385
fig, ax = plt.subplots(subplot_kw=dict(projection=Lambert93()))
@@ -404,15 +410,15 @@ color based on the vertical rate average value.
404410
This approach is not perfect (there are quite some green trajectories) but gives
405411
a good first idea of how traffic organises itself. Let's try to focus on the
406412
traffic to and from one airport, e.g. ``LFPO``, in order to refine the
407-
methodology.
413+
methodology.
408414

409415
A first approach to select those trajectories would be to pick the first/last
410416
point of the :class:`~traffic.core.Flight` and check whether it falls within the
411417
geographical scope of the airport. In the following snippet, we do things a bit
412418
differently: we check whether the first/last 5 minutes of the trajectory
413419
intersects the shape of the airport.
414420

415-
.. jupyter-execute::
421+
.. jupyter-execute::
416422

417423
from traffic.data import airports
418424

@@ -483,7 +489,7 @@ matching, and extract relevant information (the runway information):
483489
stats
484490

485491

486-
.. jupyter-execute::
492+
.. jupyter-execute::
487493

488494
chart = (
489495
alt.Chart(stats)
@@ -622,7 +628,7 @@ There are several ways to collect trajectories:
622628
- the :meth:`~traffic.core.Traffic.from_flights` class method builds a
623629
:class:`~traffic.core.Traffic` object from an iterable structure of
624630
: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
626632
iterable.
627633

628634
.. jupyter-execute::
@@ -646,7 +652,7 @@ There are several ways to collect trajectories:
646652
trajectory preprocessing operations. Operations are stacked before being
647653
evaluated in a single iteration, using multiprocessing if needed, only after
648654
the specification is fully described.
649-
655+
650656
*Lazy evaluation* is a common wording in functional programming languages.
651657
It refers to a mechanism where the actual evaluation is deferred.
652658

@@ -662,7 +668,7 @@ remember that:
662668
stacked method to every :class:`~traffic.core.Flight` it can iterate on.
663669
- If one of the methods returns ``False`` or ``None``, the
664670
: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
666672
passed as is not the next method.
667673

668674
The landing trajectory selection rewrites as:
@@ -685,7 +691,7 @@ The landing trajectory selection rewrites as:
685691
The :meth:`~traffic.core.Flight.aligned_on_ils` call (without considerations
686692
on the vertical rate and intersections) is actually enough for our needs
687693
here, but more methods were stacked for explanatory purposes.
688-
694+
689695

690696
For reference, look at the subtle differences between the following processing:
691697

@@ -698,8 +704,8 @@ For reference, look at the subtle differences between the following processing:
698704
.has("aligned_on_ils('LFPO')")
699705
.last('10 min')
700706
.eval(max_workers=4)
701-
)
702-
707+
)
708+
703709
with plt.style.context('traffic'):
704710
fig, ax = plt.subplots(subplot_kw=dict(projection=Lambert93()))
705711
t1.plot(ax, color="#f58518")
@@ -708,7 +714,7 @@ For reference, look at the subtle differences between the following processing:
708714
runways=dict(linewidth=1, color='black', zorder=3)
709715
)
710716
ax.spines['geo'].set_visible(False)
711-
717+
712718
- take the last minute of the segment of trajectory which is aligned on runway 06:
713719

714720
.. jupyter-execute::

0 commit comments

Comments
 (0)