Processing Flights ================== This notebook takes a dataset from a file or (Geo)DataFrame and flights which have been dumped to a file (see ``demo-export-flights.ipynb``) and procuces a graph of airspace handovers, saving the result to a file. Ensure you have already dumped some flight data using the aforementioned notebook, and set the data location in ``~/.config/flight_processing/flight_processing.conf``. .. code:: ipython3 from flight_processing import DataConfig from flight_processing.data import GraphBuilder, FlightDownloader import geopandas import logging logger = logging.getLogger() logger.setLevel(level=logging.INFO) logging.getLogger('traffic').disabled = True Example 1: known dataset from file ---------------------------------- This example uses the already encoded bounds of Switzerland and its airspace bounds which have already been saved to a file. .. code:: ipython3 # Initialise graphbuilder = GraphBuilder("switzerland") .. parsed-literal:: INFO:flight_processing.data.graph_builder:Loading airspace data from /mnt/cold_data/josh/processing/regions_switzerland_wkt.json. INFO:flight_processing.data.graph_builder:Initialising AirspaceHandler C++ object. INFO:flight_processing.data.graph_builder:Adding airspace data to AirspaceHandler C++ object. .. code:: ipython3 # Process one hour of flights graphbuilder.process_flights("2020-01-01 00:00") .. parsed-literal:: INFO:flight_processing.data.graph_builder:Processing downloaded flight data for time 2020-01-01 00:00:00. INFO:flight_processing.data.graph_builder:Calling AirspaceHandler C++ object to process file at /mnt/cold_data/josh/processing/flights/switzerland/20200101/0000.json. INFO:flight_processing.data.graph_builder:Retrieving result. INFO:flight_processing.data.graph_builder:Saving to file(s). INFO:flight_processing.data.data_utils:Converting graph to sparse matrix. INFO:flight_processing.data.data_utils:Saving graph as NPZ to /mnt/cold_data/josh/processing/graphs/switzerland/20200101/0000.npz. .. code:: ipython3 # Process 3 hours of flights graphbuilder.process_flights_bulk("2020-01-01 01:00", "2020-01-01 04:00") .. parsed-literal:: INFO:flight_processing.data.graph_builder:Processing downloaded flights in bulk between 2020-01-01 01:00:00 and 2020-01-01 04:00:00. INFO:flight_processing.utils:Executing function 3 times between 2020-01-01 01:00:00 and 2020-01-01 04:00:00 with time delta 1:00:00. INFO:flight_processing.data.graph_builder:Processing downloaded flight data for time 2020-01-01 01:00:00. INFO:flight_processing.data.graph_builder:Calling AirspaceHandler C++ object to process file at /mnt/cold_data/josh/processing/flights/switzerland/20200101/0100.json. INFO:flight_processing.data.graph_builder:Retrieving result. INFO:flight_processing.data.graph_builder:Saving to file(s). INFO:flight_processing.data.data_utils:Converting graph to sparse matrix. INFO:flight_processing.data.data_utils:Saving graph as NPZ to /mnt/cold_data/josh/processing/graphs/switzerland/20200101/0100.npz. INFO:flight_processing.data.graph_builder:Processing downloaded flight data for time 2020-01-01 02:00:00. INFO:flight_processing.data.graph_builder:Calling AirspaceHandler C++ object to process file at /mnt/cold_data/josh/processing/flights/switzerland/20200101/0200.json. INFO:flight_processing.data.graph_builder:Retrieving result. INFO:flight_processing.data.graph_builder:Saving to file(s). INFO:flight_processing.data.data_utils:Converting graph to sparse matrix. INFO:flight_processing.data.data_utils:Saving graph as NPZ to /mnt/cold_data/josh/processing/graphs/switzerland/20200101/0200.npz. INFO:flight_processing.data.graph_builder:Processing downloaded flight data for time 2020-01-01 03:00:00. INFO:flight_processing.data.graph_builder:Calling AirspaceHandler C++ object to process file at /mnt/cold_data/josh/processing/flights/switzerland/20200101/0300.json. INFO:flight_processing.data.graph_builder:Retrieving result. INFO:flight_processing.data.graph_builder:Saving to file(s). INFO:flight_processing.data.data_utils:Converting graph to sparse matrix. INFO:flight_processing.data.data_utils:Saving graph as NPZ to /mnt/cold_data/josh/processing/graphs/switzerland/20200101/0300.npz. .. code:: ipython3 # Cleanup del graphbuilder Example 2: new dataset from (Geo)DataFrame ------------------------------------------ In this example we directly load a (Geo)DataFrame with the relevant columns rather than relying on already saved files. Note: in this case we are loading the same dataframe from a file, but the dataframe can be produced within python without the need to save it anywhere beforehand. We are also using a custom DataConfig as in example 2 of ``demo-export-flights.ipynb``. Note 2: GeoDataFrames require columns ``lower_limit``, ``upper_limit``, ``geometry``, and DataFrames require columns ``lower_limit``, ``upper_limit``, ``wkt``. .. code:: ipython3 dataset = DataConfig("switzerland-custom", minlon=5.3, maxlon=10.7, minlat=45.5, maxlat=48, detail=6) location = "/mnt/cold_data/josh/processing/regions_switzerland_wkt.json" .. code:: ipython3 gdf = geopandas.read_file(location) gdf .. raw:: html
name | lower_limit | upper_limit | wkt | geometry | |
---|---|---|---|---|---|
0 | A9.1 AIRWAY | 9000 | 19500 | MULTIPOLYGON (((8.982777777777779 47.254166666... | MULTIPOLYGON (((8.98278 47.25417, 8.93194 47.2... |
1 | A9.2 AIRWAY | 13000 | 19500 | MULTIPOLYGON (((8.94888888888889 47.0338888888... | MULTIPOLYGON (((8.94889 47.03389, 8.98278 46.8... |
2 | Aiguilles Rouges 300m AGL | 0 | 3300 | MULTIPOLYGON (((6.847222222222222 45.931944444... | MULTIPOLYGON (((6.84722 45.93194, 6.83028 45.9... |
3 | Alpen Mil off | 15000 | 19500 | MULTIPOLYGON (((6.813333333333333 46.372777777... | MULTIPOLYGON (((6.81333 46.37278, 7.05083 46.5... |
4 | Alpen Mil on | 13000 | 19500 | MULTIPOLYGON (((6.813333333333333 46.372777777... | MULTIPOLYGON (((6.81333 46.37278, 7.05083 46.5... |
... | ... | ... | ... | ... | ... |
147 | ZURICH 5 TMA 118.1 | 3500 | 19500 | MULTIPOLYGON (((8.915000000000001 47.491388888... | MULTIPOLYGON (((8.91500 47.49139, 8.89806 47.4... |
148 | ZURICH 6 TMA 118.1 | 5500 | 19500 | MULTIPOLYGON (((8.423611111111111 47.779444444... | MULTIPOLYGON (((8.42361 47.77944, 8.30500 47.7... |
149 | ZURICH 7 TMA 118.1 | 7500 | 19500 | MULTIPOLYGON (((8.372777777777777 47.305, 8.42... | MULTIPOLYGON (((8.37278 47.30500, 8.42361 47.2... |
150 | ZURICH 8 TMA 118.1 | 6500 | 19500 | MULTIPOLYGON (((8 47.64388888888889, 7.9997222... | MULTIPOLYGON (((8.00000 47.64389, 7.99972 47.5... |
151 | ZURICH 9 TMA 118.1 | 7500 | 19500 | MULTIPOLYGON (((8.779444444444444 47.864166666... | MULTIPOLYGON (((8.77944 47.86417, 8.66083 47.8... |
152 rows × 5 columns
count | ||
---|---|---|
icao24 | callsign | |
a63e46 | GJS4571 | 1572 |
a90aaa | PDT4960 | 428 |