flight_processing.data.FlightDownloader¶
-
class
flight_processing.data.
FlightDownloader
(dataset)¶ Download flight data from the OpenSky impala shell using the traffic library.
Requires traffic to be correctly configured with valid impala credentials, see the traffic documentation for more details.
Summary:
initialisation: __init__
downloading: download_flights, save_traffic, dump_flights, dump_flights_bulk
-
__init__
(dataset)¶ Initialise the downloader with a given dataset.
- Parameters
dataset (str or DataConfig) – dataset name or specification
- Returns
object
- Return type
-
download_flights
(time_start, time_end, limit=None)¶ Download flights within the specified time interval, returning the flights as an object
- Parameters
time_start (datetime.datetime or str) – start time
time_end (datetime.datetime or str) – end time
limit (int, optional) – maximum number of position values to return - note that each flight may contain thousands of position values
- Returns
flights
- Return type
traffic.core.traffic.Traffic
-
dump_flights
(time_start, time_end)¶ Download flights within the specified time interval, saving the flights to a file.
Flights will be saved to {data_prefix}/flights/{dataset}/{date}/{time}.json, where: - data_prefix is specified by the DataConfig object passed in on construction, or the data_location config value is used by default, - dataset is the name of the dataset as specified on construction, - date and time are determined by time_start.
- Parameters
time_start (datetime.datetime or str) – start time
time_end (datetime.datetime or str) – end time
-
dump_flights_bulk
(time_start, time_end)¶ Download flights within the specified time interval, saving the flights to a file.
Behaves the same as dump_flights but flight data is split into new files for each hour.
- Parameters
time_start (datetime.datetime or str) – start time
time_end (datetime.datetime or str) – end time
-
save_traffic
(traffic, location)¶ Save the passed in flights to the specified location.
This function is intended for the use case in which a user does not have access to the OpenSky Impala shell. The user can instead download traffic from another source, such as the OpenSky REST API, and save it to disk using this function.
- Parameters
traffic (traffic.core.traffic.Traffic) – flights to save
location (pathlib.Path or str) – location to save the flights to