Question: in Module to check violations for a flight lesson. This module processes the primary violations, which are violations of weather restrictions. Weather

in"""
Module to check violations for a flight lesson.
This module processes the primary violations, which are violations of weather restrictions.
Weather restrictions express the minimum conditions that a pilot is allowed to fly in.
So if a pilot has a ceiling minimum of 2000 feet, and there is cloud cover at 1500 feet,
the pilot should not fly.To understand weather minimums, you have to integrate three
different files: daycycle.json (for sunrise and sunset), weather.json (for hourly weather
observations at the airport), and minimums.csv (for the schools minimums set by agreement
with the insurance agency). You should look at those files BRIEFLY to familiarize yourself
with them.
This module can get overwhelming if you panic and think too much about the big picture.
Like a good software developer, you should focus on the specifications and do a little
at a time. While these functions may seem like they require a lot of FAA knowledge, all
of the information you need is in the specifications. They are complex specifications,
but all of the information you need is there. Combined with the provided unit tests
in tests.py, this assignment is very doable.
It may seem weird that these functions only check weather conditions at the time of
takeoff and not the entire time the flight is in the air. This is standard procedure
for this insurance company. The school is only liable if they let a pilot take off in
the wrong conditions. If the pilot stays up in adverse conditions, responsibility shifts
to the pilot.
The preconditions for many of these functions are quite messy. While this makes writing
the functions simpler (because the preconditions ensure we have less to worry about),
enforcing these preconditions can be quite hard. That is why it is not necessary to
enforce any of the preconditions in this module.
Author: YOUR NAME HERE
Date: THE DATE HERE
"""
import utils
import pilots
import os.path
import datetime
import pytz
import csv
import json
from datetime import datetime, timezone
from datetime import datetime, timedelta
from dateutil import parser
torcs, pilots.py, utils.py, violations.py
# FILES TO AUDIT
# Sunrise and sunset
DAYCYCLE = 'daycycle.json'
# Hourly weather observations
WEATHER = 'weather.json'
# The list of insurance-mandated minimums
MINIMUMS = 'minimums.csv'
# The list of all registered students in the flight school
STUDENTS = 'students.csv'
# The list of all take-offs (and landings)
LESSONS = 'lessons.csv'
def list_weather_violations(directory):
"""
Returns the (annotated) list of flight reservations that violate weather minimums.
This function reads the data files in the given directory (the data files are all
identified by the constants defined above in this module). It loops through the
list of flight lessons (in lessons.csv), identifying those takeoffs for which
get_weather_violation() is not the empty string.
This function returns a list that contains a copy of each violating lesson, together
with the violation appended to the lesson.
Example: Suppose that the lessons
S00687548QR I0612017-01-08T14:00:00-05:002017-01-08T16:00:00-05:00 VFR Pattern
S00758548QR I0722017-01-08T09:00:00-05:002017-01-08T11:00:00-05:00 VFR Pattern
S00971426JQ I0722017-01-12T13:00:00-05:002017-01-12T15:00:00-05:00 VFR Pattern
violate for reasons of 'Winds', 'Visibility', and 'Ceiling', respectively (and are the
only violations). Then this function will return the 2d list
[[S00687,548QR, I061,2017-01-08T14:00:00-05:00,2017-01-08T16:00:00-05:00, VFR, Pattern, Winds],
[S00758,548QR, I072,2017-01-08T09:00:00-05:00,2017-01-08T11:00:00-05:00, VFR, Pattern, Visibility],
[S00971,426JQ, I072,2017-01-12T13:00:00-05:00,2017-01-12T15:00:00-05:00, VFR, Pattern, Ceiling]]
REMEMBER: VFR flights are subject to minimums with VMC in the row while IFR flights
are subject to minimums with IMC in the row. The examples above are all VFR flights.
If we changed the second lesson to
S00758,548QR, I072,2017-01-08T09:00:00-05:00,2017-01-08T11:00:00-05:00, IFR, Pattern
then it is possible it is no longer a visibility violation because it is subject to
a different set of minimums.
Parameter directory: The directory of files to audit
Precondition: directory is the name of a directory containing the files 'daycycle.json',
'weather.json', 'minimums.csv', 'students.csv', and 'lessons.csv'
"""

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!