Week 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

INFO1

DESCRIPTION OF THE PROJECT PROGRAMING TASKS


May 2022

Cristina Barrado, Ruben Hidalgo, Georgy Skorobogatov and Angélica Reyes


Computer Architecture Department, UPC
Table of contents

INTRODUCTION 3
WEEK 0 - Warm up 5
WEEK 1 8
WEEK 2 11
WEEK 3 13
WEEK 4 17
IV – Annexes 21
Annex A: Quality criteria 21
Annex B: Files format 22
Annex C: GoogleEarth and the KML format 25
INTRODUCTION

This document describes the tasks to do as part of the INFO1 project. You will build a program to
manage the assignment of gates at the Barcelona El Prat airport. The airport has two terminals (T1,
and T2), with a number of gates to be assigned to aircraft once landed. Characteristics such as the
airline and the international/european flight, have to be taken into account when assigning gates.
You will create plots to show the status of gates in each terminal, locate destinations on a map using
Google Earth, assign gates to aircraft, etc.
There is an initial week (Week 0 or warm-up week) in which you will start using the data structures
for a much simpler airport. The code of this week is not used for evaluation and the teachers will
lead you to the solution of the list of functions to be written.
The project work will last till the end of the course.

ORGANIZATION
The project shall be done in groups of 4 people. You will work during class, but also outside of the
class, to fill up 10 hours per person each week. You must agree at least on one suitable meeting
schedule and book 2 hours outside of the class to meet with your group. At the end of each meeting
(one in class and one outside) one person in the group has to write the minutes (or summary) of the
meeting indicating:

The minutes of the project have to be delivered immediately after the meeting in G1 (see below,
Group Deliverables).

DELIVERABLES
● Group
G1: contains all the information about the group meetings. Submit them as soon as you end each
meeting.
G2 and G3: contain the Week 2 and Week 4 code (all program_files.py)
Before the code delivery, test that the programs work fine and that they will execute also on the
teacher's computers. I.e. do not use absolute path names for the files. Do not include any
input/output data file. Only the python programs.
● Individual1
At the end of each of the weeks 1-4, and before the next class (deadline is Monday midnight) each
individual shall deliver in ATENEA, a compressed ZIP file with their self code contribution.
At the end of the project, three more additional deliverables will be due, as shown in the figure
below:

EVALUATION
Grades of the project (40%) are divided as follows:

5% individual written test (surprise date, short exercise during class, with computer)

25% project deliverables (mainly G3)

10% individual extension exam (last class, 2h exercise, with computer)

Check evaluation criteria of Annex A to obtain a good mark.

1
NOTE: to count for the Deliverables grade, not for the project grade
WEEK 0 - Warm up

The airport of Lleida-Alguaire (LEDA) is a small facility with only 2 gates. We will assume that
only 5 aircraft land in LEDA and will write a code to manage the assignment of aircraft to gates.

The code will consist of 5 files:


● airport.py - to manage the information of all airports with connection flights with LEDA
● aircraft.py - to manage the aircraft landing and taking-off to and from LEDA
● terminal.py - to manage the information about the terminal and its gates
● functions.py - to hold the functions that relate aircraft, airports and gates
● main.py - to hold the test program

• Airport

Create a file airport.py and define the class Airport and the __init__() method.
The Airport is a class that holds information about one airport. This is:
​ - ICAO code of the airport
​ - The official name
Write also a function that finds an Airport in a vector of airports
- find_airport (AP, ICAO_code):
finds an airport with the given ICAO_code in a vector of Airports and returns the airport or
None if not found.
Then add a code to create an instance of class Airport for LEDA, LYBE, EGCC, EBBR, EDDK and
LGSR2. Append them into a vector of Airports and test the function.

• Aircraft

Create a file aircraft.py and define the class Aircraft and the __init__() method.
The Aircraft is a class that holds information about one aircraft. This is:
​ - AC identification
​ - The owner airline (3 characters with the ICAO code)
​ - The origin airport name (ICAO code)
Write also a function that finds an Aircraft in a vector of aircraft
- find_aircraft (AV, aircraft_id):
finds an aircraft with the given aircraft_id in a vector of aircraft and returns the aircraft or
None if not found.
Then add a code to create a vector with 5 aircraft and to test the find_aircraft function with the
following 5 flights:
AIRCRAFT AIRLINE ORIGIN
ECMKV VLG LYBE
ECJGM VLG EGCC
DALEC BCS EBBR
N327UP UPS EDDK
ECMKN VLG LGSR

2
Search in the Internet the name of these ICAO airports code
• Terminal

Create a file terminal.py and define the class Gate and Terminal, each with the respective __init__()
method.
The Terminal is a class that holds a list of gates.
The Gate is a class that holds the status of each gate. This is:
- Identification
- A boolean identifying if the gate is occupied
- The AC identification that is occupying the gate (or empty string if is free)
Then write the test code to create an instance of class Terminal with 2 free gates named “A1” and
“A2”.

See in the following chart a schematic view of the four classes presented above

Additionally:

• Functions

Create a file functions.py with the following functions:


​ - assign_gate(terminal, aircraft_id)
​ finds a free gate for the aircraft, updates the information in the variable terminal and returns
the identification of the assigned gate in the terminal. If all gates are occupied the function
returns an empty string. If the aircraft is already in a gate the function returns the
identification of that gate with no further modifications.

- where_is_assigned (terminal, aircraft_id):


that searches for the AC_id in all the gates of the terminal and returns the gate identification
of the empty string ("") if not found

​ - free_gate(terminal, aircraft_id)
​ updates the terminal variable, setting to free the status of the gate assigned to the aircraft
with identification aircraft_id.

- show_occupancy(terminal, ACV, APV)


given a terminal (with its gates), aa vector of aircraft and a vector of airports the function
prints the list of gates with their status: empty if no aircraft is assigned or the Airline and the
name of the origin airport if assigned.
• Main

Create a file main.py with the code that interacts with the end-user. The program will create the
variable of the LEDA airport, the LEDA terminal with 2 gates, and the 5 aircraft.

The main program then enters a loop with the following options for the user:
​ a - shows airport information
​ t - shows terminal status (including gates and any parked aircraft)
​ f - shows the flights of arrival aircraft

m AC_Id - assigns a gate to aircraft AC_Id
d AC_Id - frees the gate with identification AC_Id

e - exit the loop and end the program


WEEK 1

During the first week of the project you will have to define Airport, a basic structure of the
program, initialize it by reading airport data from an input file and do some initial processing with
the list of airports (See file formats at Annex B).

Airport structure will be defined together with its __init__ method. Then follows the list of
functions that shall be developed. Write also a main program to test the functions. Work in group to
define the structure and then divide the functions between the group components. Always check
correct execution by cross check, this is, in the meetings run the functions done by your peers on a
different computer to test they work fine before delivering them.

Create a file airport.py and define a structure Airport


• Airport

The structure Airport is a class that holds information about one airport. This is:
​ - ICAO code of the airport (4 characters, ie. LEBL for Barcelona El Prat)
​ - coordinates (2 real numbers containing airport latitude and longitude in degrees, ie.
20.6543)
​ - Schengen (1 boolean that is True if the airport is in a country belonging to Schengen)

Write the method to initialize class Airport with an empty ICAO code, 0.0 coordinates, and
Schengen set to False:

def __init__(self)
Description: Sets an empty Airport structure

Functions to write related with Airport:

def is_schengen_airport(ap_name)
Description: This function receives the ICAO code of an airport and checks if the airport is
in a Schengen country. The countries which signed the Schengen agreement are Austria,
Belgium, CzechRep, Cyprus, Denmark, Estonia, Finland, France, Germany, Greece,
Netherlands, Hungary, Iceland, Italy, Latvia, Lithuania, Luxemburg, Malta, Norway, Poland,
Portugal, Slovakia, Slovenia, Spain, Sweden, and Switzerland. To know if an airport belongs
to any of these countries you have to check if the first 2 characters of the ICAO code are
within one of the following codes which correspond to the above list of countries:
'LO', 'EB', 'LK', 'LC', 'EK', 'FO', 'EE', 'EF', 'LF', 'ED', 'LG', 'EH', 'LH', 'BI',
'LI', 'EV', 'EY', 'EL', 'LM', 'EN', 'EP', 'LP', 'LZ', 'LJ', 'GC', 'LE', 'ES', 'LS'
The function returns a boolean that is True if the airport belongs to a Schengen country, and
False otherwise. If the input parameter is empty, in addition to returning False, also an error
message is displayed.

def set_schengen(AP)
Description: Given a vector of airports, AP, this function updates the information about
Schengen of each airport and returns the updated vector. To check if an airport belongs to a
Schengen country use the previous function. If the vector is empty nothing is done and an
empty vector is returned.
def read_airports(filename)
Description: This function opens the file with name received as input and with the format
described in Annex B, and returns a vector of airports with the data found in the file.
Convert the format of latitude and longitude from string to decimal degrees (float that will
be negative for West and South coordinates). In the file you will not find any data about
Schengen, so do not update this field of the structure. If the file does not exist the function
returns an empty vector and displays an error message on the screen.

def write_schengen_airports(AP)
Description: Given a vector of airports, AP, this function writes the information of the
airports that are Schengen into a file named “SchengenAirports.txt”. If the vector is empty
no file is created and an error message is displayed on the screen. The file should contain the
ICAO code and the coordinates of the airports.

def map_airports(AP)
Description: Given a vector of airports, AP, this function writes Airports.kml, a KML file
with the location of all the airports in the vector. Each airport is a KML Placemark of type
Point. See in Annex C the information about the KML format used by GoogleEarth. Note
that your code only has to create a file. You can check the KML file content by opening it
with your program editor. To obtain a map similar to the image below you need to download
GoogleEarth into your computer and, once you have created the KML file, double click on
the file.
Optional: mark in blue the Schengen airports and in yellow (default) the rest.

Update the class chart of week 0 to represent the new fields that you have to add this week.
Write a main program in a different file to test all the functions, one by one, and with different
conditions as shown below. Write it incrementally, every time a new function is written. To avoid
too long outputs you can always comment out (using character ‘#’) the lines of code that you have
already tested.

To DELIVER before the next class (Thursday/Friday):

Add the name of your group to the filenames:

● Minutes of at least 2 group meetings3.


● Individual contributions to the code

Do not add any text file containing input/output data of the programs.

3
Look in the introduction (page 3) what data the minutes must contain
WEEK 2

During the second week of the project you will process the flights arriving to Barcelona El Prat in
one day.

You will define a new structure with its __init__ function. Then follows the list of functions that
you must develop. Write also a main program to test the functions. Work with your group to define
the structure and then divide the functions between the group components. Always check correct
execution by cross check, this is, in the meetings run the functions done by your peers on a different
computer to test they work fine before delivering them.

Create a file aircraft.py and define a structure Aircraft


• Aircraft

The structure Aircraft is a class that holds information about one flight arriving to Barcelona, this is:
​ - aircraft id (a string)
​ - airline company (3 characters with the ICAO code of the airline)
​ - origin airport (4 characters with the ICAO code of the airport the aircraft is coming from)
​ - time of landing in Barcelona (with format h:mm or hh:mm)
​ - schengen (boolean indicating if the aircraft has to board on a Schengen gate)

Write the function to initialize class Aircraft with empty values:

def __init__(self)
Description: Sets an empty Aircraft structure (empty strings, zeros, Falses, ...)

Functions to write related to Aircraft:

def assign_schengen(vac)
Description: Given a vector of structures Aircraft, this function updates the information
about Schengen of each aircraft and returns the updated vector. An aircraft is classified as
Schengen if its origin airport is Schengen (use function of week 1). If the vector vac is
empty nothing has to be done and an empty vector is returned.

def read_arrivals(filename)
Description: This function opens the file with the name received as input and with the
format described in Annex B, and returns a vector of aircraft initialized with the data found
in the file. In the file, you will not find all data defined in the structure Aircraft, so update
only the fields of the structure you can. If the file does not exist the function returns an
empty vector and displays an error message on the screen. In case some of the aircraft lines
do not have a correct time or the expected structure, then the function must skip this aircraft
and proceed with the rest of the lines in the file. Note that the arrivals file is sorted by
landing time.

def write_flights(vac)
Description: Given a vector of structures Aircraft, this function writes the information of
those aircraft into a file named “Movements.txt”. Be aware that some parts of the Aircraft
structure can be empty field values. Write them as a string with '-'. If the vector is empty no
file is created and an error message is displayed on the screen.

def map_flights(vac)
Description: Given a vector of structures Aircraft, this function creates a KML file named
“Movements.kml” with all flights in the vector vac. Each flight is a KML Placemark of type
LineString from the departure airport to LEBL. The coordinates of the departure airports can
be obtained from the Airports.txt file from Week1. See in Annex C an example of the use of
the LineString Placemark. You can check the KML file content by opening it with your
program editor. You should obtain a map similar to the second one in Annex C. If the vector
is empty no file is created and an error message is displayed on the screen.

Remember that your code only has to create a file. To obtain a map similar to the image
below you need to download GoogleEarth into your computer and, once you have created
the KML file, double click on the file.

def plot_flights_type(vac)
Description: This function receives a vector of aircraft and shows a bar plot of the number of
flights arriving from Schengen countries and the number of non-Schengen. If the vector is
empty an error message shall be displayed on the screen and no plot is shown.

def plot_airlines(vac)
Description: This function receives a vector of Aircraft and shows a bar plot of the number
of flights per airline. If the vector is empty an error message shall be displayed on the screen
and no plot is shown.

def plot_arrivals(vac)
Description: This function receives a vector of aircraft and shows a plot of the landing
frequency of one day, this is the number of landing aircraft per hour. If the vector is empty
an error message shall be displayed on the screen and the function will end.

Update the class chart of last week to represent the new fields that you have to add this week.

Write a main program in a different file to test all the functions of the week, one by one, and with
different conditions (correct/incorrect) as the one of week 1. Write it incrementally, every time a
new function is finished. To avoid too long outputs you can always comment out (using character
‘#’) the lines of code that you have already tested.

To DELIVER before the next class (Thursday/Friday):

Add the name of your group to the filenames:

● Minutes of at least 2 group meetings4.


● Individual contributions to the code.

Do an Intermediate Project Delivery (G2). Create GROUP#.ZIP file with all the files.PY of the
project up to Week 2. Do not add any text file containing input/output data of the programs.

4
Look in the introduction (page 3) what data the minutes must contain
WEEK 3
In the file Terminals.txt you have the basic information on how the boarding gates of Barcelona El
Prat airport are organized.

LEBL 2 terminals
Terminal T1 5 boarding areas
Area A Schengen Gates 1 - 11
Area B Schengen Gates 1 - 57
Area C Schengen Gates 1 - 11
Area D non-Schengen Gates 1 - 11
Area E non-Schengen Gates 1 - 11
Terminal T2 6 boarding areas
Area M Schengen Gates 1 - 8
Area R Schengen Gates 9 - 19
Area S Schengen Gates 20 - 30
Area U Schengen Gates 30 - 39
Area W non-Schengen Gates 40 - 49
Area Y non-Schengen Gates 50 - 59

This information is structured in lines: the first line has the ICAO code of the airport and the
number of terminals. Then for each terminal, there is a line with the name of the terminal and the
number of boarding areas of this terminal. Following this terminal header line, there are as many
lines as boarding areas, each line describing a boarding area. The lines describing the boarding
areas have the name of the area, a description of the type of arrival/departures (Schengen or
non-Schengen), and the initial and final gate numbers found in this boarding area.

Additionally, you have 2 more files: T1_Airlines.txt and T2_Airlines.txt. They both have a list of
airlines, on separate lines and sorted in alphabetical order. An airline can appear only in one of the
files and indicates the terminal in which the airlines have to board their passengers.

In week 3 you will assign arrival flights to gates according to the airline and the origin airport type
(Schengen/non-Schengen).
Four new classes will be defined together with their __init__ methods. Then follows the list of
functions that shall be developed. Write also a main program to test the functions. Work with your
group to define the structure and then divide the functions between the group components. Always
check correct execution by cross-checking, this is, in the meetings run the functions done by your
peers on a different computer to test they work fine before delivering them.

Create a file LEBL.py and define the following classes related to the airport boarding gates:

• BarcelonaAP
• Terminal
• BoardingArea
• Gate

The BarcelonaAP class will have two attributes: code – a string value containing the code of the
airport of Barcelona, and terminals – a list of objects of type Terminal.
The Terminal class will have three attributes: name – a string value containing its name,
boarding_areas – a list of objects of type BoardingArea, and airlines – a list with the names of the
airline companies which work in the terminal.
The BoardingArea class will have three attributes: name – a string value containing its name, type_
– a string value containing the type (either “Schengen” or “nonSchengen”), and gates – a list of
objects of type Gate.
The Gate class will contain three attributes: code – a string value, is_occupied – a boolean that
shows if the gate is occupied, and aircraft_id – a string value containing an aircraft id in case the
gate is occupied.
Below is the class chart for this week. Notice that there are a number of important differences from
previous class charts.

Write the __init__ methods for all the classes above to initialize all their fields with empty values.
Note that setting a default value of a parameter to an empty list inside a signature of a function, can
result in unexpected behavior (more information here: https://stackoverflow.com/q/366422)
Then write the following functions related to these classes:

def set_gates(area, init_gate, end_gate, prefix)


Description: Given a parameter area of type BoardingArea, two integer values init_gate and
end_gate, and a string prefix, the function creates a list of gates and sets it as the attribute of
the boarding area. The code for each gate is created by concatenating the prefix with a
number from the given range [init_gate, end_gate]. If the end_gate number is not greater or
equal to the init_gate, an error is displayed and the vector of gates remains unchanged.

def show_occupancy(bcn)
Description: Given a parameter bcn of type BarcelonaAP, this function shows on the screen
the gates occupancy. The output shall consist of the list of gate names, their status, and the
aircraft id when the gate is occupied.

def is_airline_in_terminal(terminal, name)


Description: Given a parameter terminal of type Terminal and name containing the name of
one airline, this function returns a boolean indicating if the airline is in the list of airlines
boarding in this terminal. If the terminal has an empty list of airlines, the return value shall
be False. If the name of the airline is an empty string then an error message shall be
displayed and False is returned.

def read_airlines(terminal, t_name)


Description: Given a parameter terminal of type Terminal and t_name containing the name
of the terminal, this function reads the information from the file named
{terminal_name}_Airlines.txt and updates the list of airlines of the terminal using the
information obtained from the file. If the terminal had a previous list of airlines, the old list
will be replaced with the new one. If the file does not exist, an error message shall be
displayed on the screen and no modification of the terminal should be done. See Annex B
for the format of the T#_Airlines.txt files.

def read_barcelona(bcn)
Description: Given a parameter bcn of type BarcelonaAP, this function reads the
information from the file Terminals.txt and updates the data of the bcn parameter using the
information obtained from the file. This function should call the set_gates and the
read_airlines functions defined above in order to complete the structure of the gates in
Barcelona. When calling set_gates() use different prefixes for each boarding area to easily
locate a gate by its prefix. If the Terminals.txt file does not exist, an error message should be
displayed and no modification of bcn should be done.

def plot_occupancy(bcn)
Description: Given a parameter bcn of type BarcelonaAP, this function shows on the screen
a stacked-bar plot with the number of free and busy gates per boarding area.

def find_terminal(bcn, name)


Description: Given a parameter bcn of type BarcelonaAP and name containing the name of
an airline, this function returns the terminal where the airline can board its passengers. Use
the function is_airline_in_terminal(). If the airline is not found in any of the terminals, the
function should return None.

def assign_gate(bcn, aircraft)


Description: Given a parameter bcn of type BarcelonaAP and a parameter aircraft of type
Aircraft, this function looks for the first gate that is not occupied in the correct boarding
area, assigns it to the aircraft, and returns the gate identification.
To decide the correct boarding area the function must check the airline-terminal assignment
(using the find_terminal function defined above) and the Schengen/non-Schengen type of
flight-boarding area. The gate assignment consists in updating the occupancy boolean and
the aircraft field of the chosen gate inside the bcn. If there are no more free gates of the
correct type, an error message shall be displayed and no modification of the bcn object shall
be done.
Write a main program to test all the functions of week 3, using an interactive menu for the
end-user. The menu will consist of a 2-steps loop:
1. informs the user about the available functionalities and
2. executes the selected option.
The loop finishes when the user selects to end with option (e)
The program options are the following:
(c) create an empty structure of class BarcelonaAP
(r) test function read_arrivals (from week 2)
(i) test function read_barcelona
(o) test function show_occupancy
(p) test plot functions
(a) test function assign_gate using one flight of the list of arrivals (use consecutive flights
each time)
(e) end program
The main program will execute the functions according to the letter entered by the user. It must
check that the selected option is correct. For instance, selecting a letter 'x' shall produce an error
message “Option not valid” and a new letter shall be requested. Moreover selecting an option that
needs a previous one (ie. 'a' without a previous 'r') shall be detected and informed.

To DELIVER before next Thursday:

Add the name of your group to the filenames:

● Minutes of at least 2 group meetings5.


● Individual contributions to the code.

5
Look in the introduction (page 3) what data the minutes must contain
WEEK 4
In week 4 you will deal with departing flights and do the final gate assignment. The departing
aircraft must be matched with the arrival aircraft through the aircraft identification. They can also
be aircraft that have spent the night at the airport. At the moment of departure they free the gate. All
this management will be processed this last week.

The Airport structure will be redefined together with its __init__ method. Then follows the list of
functions that shall be developed. Write also a main program to test the functions. Work with your
group to define the structure and then divide the functions between the group components. Always
check correct execution by cross check, this is, in the meetings run the functions done by your peers
on a different computer to test they work fine before delivering them.

Edit the file aircraft.py and modify the structure Aircraft:

• Aircraft (extend)

The structure Aircraft shall be enlarged with the following fields related to departures:
​ ...
​ - destination airport (4 characters with the ICAO code of the airport) the aircraft will depart
to after its stay in Barcelona)
​ - time of departure from Barcelona (5 characters with format hh:mm)

Update the class chart from the previous week to add the new fields of class Aircraft

Update the method to initialize class Aircraft with the new fields:
def __init__(self)

And update the function map_flights


def map_flights(vac)
To mark in blue the arrival flights and in green the departures.

Then write the following new function related with the new Aircraft:
def read_departures(filename)
Description: This function opens the file with name received as input and with the format
described in Annex B, and returns a list of aircraft initialized with the data found in the file.
In the file, you will not find all data defined in the structure Aircraft, so update only the
fields of the structure related to departures. If the file does not exist the function returns an
empty vector and displays an error message on the screen. Note that the departure file is
sorted by take-off time.

def plot_movements(v1, v2)


Description: This function receives two vectors of aircraft, v1 with the arrivals and v2 with
the departures, and shows a plot of the take-off and landing frequencies for each hour of the
day. Number of aircraft that land and take-off are given in separated bars. If some of the
vectors are empty an error message shall be displayed on the screen.

def merge_movements(v1, v2)


Description: This function receives two vectors of aircraft, v1 with the arrivals and v2 with
the departures, and returns a new vector in which the data of the aircraft with the same id
and with compatible times are merged into the same Aircraft structure. Times are compatible
when the arrival time is previous to the departure time. If some of the vectors are empty an
error message shall be displayed on the screen and the returned list will be the non-empty
vector. If both input vectors are empty the returned vector is also empty.

def night_aircraft(vac)
Description: This function receives a vector of aircraft, vac, and returns a new vector with
the aircraft that have not an arrival but only the departure information set. If the vector is
empty an error message shall be displayed on the screen and the returned list is also an
empty vector.

And write the new functions that also relate the aircraft vectors with the LEBL airport structure:
def assign_night_gates(bcn, vac)
Description: This function receives a parameter of type BarcelonaAP, bcn, and a vector of
aircraft, vac, and updates the bcn parameter by assigning a gate to each of the aircraft in the
vector vac. Use the function assign_gate from above. Check that the aircraft in vac are only
departure flights, with empty data related to arrival. In case any aircraft does not meet the
condition then show an error message on the screen and skip to the following aircraft in vac.
If the vector is empty the bcn parameter is not changed.

def free_gate(bcn, ac_id)


Description: This function receives a parameter of type BarcelonaAP, bcn, and identification
of an aircraft, ac_id, and updates the bcn structure setting to free the status of the gate
assigned to the aircraft. In case the ac_id does not exist an error message shall be displayed.

def set_time(bcn, vac, tsim)


Description: This function receives a parameter of type BarcelonaAP, bcn, a vector of
aircraft, vac, and a string with a time of the day, tsim, and updates the bcn structure to
provide the status of the airport gates at that time. The input parameter bcn will have the
gates occupied during the night assigned to the overnight aircraft. The vac has the
information of arrivals and departures already merged. The function must loop over the vac
vector and update only the gates that are occupied during time tsim. If vac is empty or time
is '00:00' the bcn structure will not be modified.

[OPTIONAL] def plot_day_occupancy(bcn, vac, [filename])


Description: This function receives a parameter of type BarcelonaAP, bcn, a vector of
aircraft, vac, with the status of the airport at midnight and the list of aircraft arriving and
departing from Barcelona El Prat airport in one day and shows a plot of each boarding area
occupancy (as in function plot_occupancy) but for every hour of the day. The third
parameter, filename, is optional. If given then the plot shall be also saved in a file with the
indicated file name.
Write a main program to test all the functionalities of the project as a menu for the end user. The
menu will enter in a 2 steps loop:
● informs the user about the available functionalities and
● executes the selected option.
The loop finishes when the user selects option (e).
The menu options are the following, according to the letters entered by the user. When a menu
option has more parameters (such as 't'), the new values will be requested to the user in the
keyboard before asking for a new menu option:

The main program must check that the selected option is correct. For instance, selecting a letter 'x'
shall produce an error message “Option not valid”. Moreover, selecting an option that requires a
previous one not executed yet (such as 'p' before 'i') shall be detected and informed.
To DELIVER before the last class:

Add the name of your group to the filenames:

● Minutes of at least 2 group meetings6.


● Individual contributions to the code

FINAL: Create GROUP#.ZIP file with the following content:


● main_final.py – file with the main program
● and all the files .py needed for the execution of the project

Please, clean up the ZIP file and do not include any input/output data files.

6
Look in the introduction (page 3) what data the minutes must contain
IV – Annexes
Annex A: Quality criteria
Project Assessment Criteria
Quality Level
Quality Item Good Fair Low
(all points) (half of the points) (0 points)
Functionality The program implements One of the mandatory Two or more functions
(4 points) correctly ALL the functions is not are not implemented, OR
mandatory functions. implemented, OR two or the program fails more
A wide range of tests more tests have failed. frequently than it
have worked fine or only succeeds. It is not
one minor failure has working as supposed.
been found.
Code organization The code of the program The code is reasonably Code organization is
(2 points) is organized in a clean well organized and messy and there is a clear
way, has useful commented. In some lack of comments (or if
comments, global cases, though, these present, they don't clarify
constants and variable aspects could be anything). Code uses
names have a clear improved. Additional hardcoded constant and it
meaning. In case of comments would clarify would be very hard to
needing a code certain parts of the modify this code in order
modification, it is easy to program. fix a bug or add some
implement. piece of functionality.
Robustness The program is able to The program is fairly The program is not robust
(2 points) deal with unexpected robust. Only strange at all. It crashes
situations and unexpected situations frequently and fails to
non-conforming data make the program crash properly deal with typical
files. It never crashes. errors.
Friendliness The user has no doubts In general, the The user constantly
(2 points) regarding how to interact information and doubts with regard to
with the application. The messages provided by what the inputs are that
expected inputs are clear the application are clear the program expects or
and the results and enough. Nevertheless, how to interpret its
output messages are easy there are occasions when results.
to understand. it is not easy to know
what to do or how to
interpret its outputs.


Annex B: Files format
​ Airports.txt
The file Airport.txt contains the list of all the airports that have a flight connecting with Barcelona
El Prat airport. The format is shown below, having a header row that should be self-explanatory.
Latitude starts with N or S for the North/South hemisphere respectively and then 2 digits for
degrees, 2 for minutes, and 2 for seconds. Longitude is similar except that coordinates can be East
or West (E/W) and that degrees need 3 digits. Separators are blank spaces. Before using the whole
file (174 lines), consider starting with an easy version of the file by copying only the short list
shown (for instance 10 airports).

​ Arrivals.txt
The file Arrivals.txt contains the list of flights arriving to Barcelona El Prat airport in one day. The
format is shown below, having a header row that should be self-explanatory. Separators are blank
spaces. Landing flights are sorted by time of arrival. Before using the whole file, consider starting
with an easy version of the file by copying only the short list shown.

​ Terminals.txt
The file Terminals.txt contains the terminals and gates of the Barcelona El Prat airport. The first line
contains the ICAO code of the airport and the number of terminals. Then for each terminal, there is
a line with the name of the terminal and the number of boarding areas of this terminal. Following
this terminal header line, there are as many lines as boarding areas, each describing a boarding area.
The lines describing the boarding areas have first the name of the area, then a description of the
type of flights (Schengen or non-Schengen), and the initial and final gate numbers of the boarding
area.
In the listing below you have the content of the Terminals.txt file:

​ T1_Airlines.txt and T2_Airlines.txt


The files T1_Airlines.txt and T2_Airlines.txt each contain the list of airlines that are assigned to the
specific terminal. There is no header line and each line has the name of the airline followed by its
ICAO code of the airline. Separator between name and ICAO code is a <tab> character. Airlines are
given in alphabetic order of their names (not the code). Find below the initial lines of both files.

T1_Airlines.txt T2_Airlines.txt
Adria Airways ADR Aer Lingus EIN
Aegean Airlines AEE Air Arabia Maroc MAC
Aeroflot AFL Air Moldova MLD
Aerolineas Argentinas ARG Air Transat TSC
Air Algerie DAH Atlantic Airways FLI
Air Baltic BTI Aigle Azur AAF
Air Berlin BER Blue Air BMS
Air Canada ACA Bulgaria AirLZB
Air China CCA Chalair Aviation CLG
Air Europa AEA Corendon Airlines CAI
Air France AFR Enter Air ENT
Air Nostrum ANE Evelop Airlines EVE
Alitalia AZA Gambia International Airlines GNR
Aliexpress SMX Germanwings GWI
...etc… ...etc…
​ Departures.txt
The file Departures.txt has exactly the same format than Arrivals.txt (see above)
Annex C: GoogleEarth and the KML format
KML is a formatting language used to display geographic data in GoogleEarth and other geographic
browsers. KML is based on the XML standard: this is a text file that uses a tag-based structure with
nested elements and attributes. Examples of a KML file are given below. The first example shows
how to place a Point in a map. The second shows how to draw a route given by a sequence of three
positions.
For details on KML properties see https://developers.google.com/kml/documentation/kml_tut
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>LEBL</name>
<description>BCN Airport</description>
<Point>
<coordinates>2.07833,41.29694</coordinates>
</Point>
</Placemark>
<Placemark>
<name>LEMD</name>
<description>MAD Airport</description>
<Point>
<coordinates>-3.700346,40.41669</coordinates>
</Point>
</Placemark>
</Document>
</kml>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Route</name>
<LineString>
<extrude>1</extrude>
<coordinates>
2.047294803225334,41.59214218550531
2.088878363983381,41.92651557803026
2.368986084009612,42.29370150905972
</coordinates>
</LineString>
</Placemark>
</Document>
</kml>

You can try both KML codes by writing them in a file using a text editor (for instance, the PyCharm
editor) and saving them with the “.kml” extension. Then, install GoogleEarth on your computer
from http://www.google.com/earth/download/ge/ . When double-clicking the KML file, or by
opening it from the File Menu of GoogleEarth you will obtain the images on the screen.

You might also like