1+ # TEAM NAME:
2+ # TEAM NUMBER:
3+ # PARTICIPANT NAMES:
4+
5+ # SOURCE CODE
6+ # 2019 - Climatology - Weather Analyzer
7+ # DIVISION B/C
8+
9+ ''' INSTRUCTIONS
10+
11+ SCENARIO: Climatology - Weather Analyzer
12+ DESCRIPTION: Analyzing historic climate data can be used to generate trends, and predict future weather in specific areas.
13+ Your tasks will inlcude solving problems related to the weather. During the test, you will be asked to load daily weather
14+ statistics from JAN 1, 1960 to APR 1, 2019 for the Detroit Metro Airport weather station and answer questions based on that data set. Your code
15+ will be tested against a similar data set from Chicago OHare Airport.
16+ Climate data taken from https://www.ncdc.noaa.gov/cdo-web/
17+
18+ 1. TASK: For each question, write your code to solve each objective. (return the answer programmatically. ie. via variables)
19+ 2. TOTAL POINTS: 103
20+ 3. WINNER: High Score
21+ 4. TIE BREAKER: Question 18. If there is still a tie, question 17, 16 and so on will break the tie.
22+
23+ TIPS:
24+ * Some questions may ask you to call functions from previous questions.
25+ * The main function (at bottom) will call and run all of the questions and print the answers. Do not modify this function.
26+ * Programs that do not run/compile will not be eligible to receive full points as determined by the Source Code rules.
27+ * Run your program often to test and check for errors.
28+
29+ INFORMATION: The majority of questions will use a list of dictionaries (weather) which you will load from a file
30+ in one of the questions. Each line of the file will represent weather attributes for one day. The structure for each
31+ day (dictionary( is listed below:
32+
33+ [
34+ {
35+ 'DATE':'1960-01-01', # (STRING) Date in format year-month-day
36+ 'TAVG':-4.8, # (NUMBER) Average Temperature (celsius)
37+ 'TMAX':1.1, # (NUMBER) Maximum Temperature (celsis us)
38+ 'TMIN':-10.6, # (NUMBER) Minimum Temperature (celsisus)
39+ 'PRCP':0.0, # (NUMBER) Percipitation Total (millimeters)
40+ 'SNOW':0.0, # (NUMBER) Snow Fall Total (millimeters)
41+ 'SNWD':25.0, # (NUMBER) Snow Depth (millimeters)
42+ 'AWND':0, # (NUMBER) Average Wind Speed (meters per second))
43+ },
44+ ...
45+ ]
46+
47+ GOOD LUCK! '''
48+
49+ # QUESTION 0: WEATHER TEAM NAME
50+ # OBJECTIVE A (2): Build a string for the name of your weather team.
51+ # Include your school name followed by any text you like. Append the
52+ # parameter date to the end of your string. Return the string.
53+ # Output example: Bath High School Weather Warriors 04/27/2019
54+ def getName (date ):
55+
56+ return ''
57+
58+ # QUESTION 1: AVERAGE CALCULATOR
59+ # OBJECTIVE A (2): A list of numbers is passed into the function below. Calculate
60+ # the average of the numbers and return the result.
61+ #OBJECTIVE B (2): Format/round the number to two decimal places.
62+ def getAverage (numbers ):
63+ total = 0 ;
64+
65+ return total
66+
67+ # QUESTION 2: CELSISUS TO FAHRENHEIT CONVERSION
68+ # OBJECTIVE A (2): A number temp, is passed into the function below
69+ # representing a temperature. If the other parameter conversion equals 'F'
70+ # convert the temperature from Celsius to Fahrenheit.
71+ # OBJECTIVE B (2): If conversion equals 'C' convert the temperature from
72+ # Fahrenheit to Celisus.
73+ # OBJECTIVE C (2) If conversion equals neither 'F' or 'C' return None (Python's null type)
74+ # Do not round.
75+ def convertTemp (temp , conversion ):
76+
77+ return ''
78+
79+ # QUESTION 3: DATE COMPARATOR
80+ # OBJECTIVE A (2): Two dates are passed into the function below.
81+ # Import the datetime library. If date1 is before date2 return -1.
82+ # OBJECTIVE B (2): If date1 equals date2 return 0.
83+ # OBJECTIVE C (2): If date1 is after date2 return 1.
84+ def compareDates (date1 , date2 ):
85+
86+ return ''
87+
88+ # QUESTION 4: LOAD WEATHER DATA
89+ # OBJECTIVE A (4): Using the given text file name, where each line represents
90+ # a dictionary containing weather data for one day, convert each line to a
91+ # dictionary and add the dictionary as an item in the list weather. The count
92+ # of items in the list will be output. (It should be 21641).
93+ # The resulting list of this function will be used in later questions.
94+ # HINT: Uncomment the JSON library that has been imported. For each line in the file, it
95+ # can be converted to a dictionary with the code: json.loads(line)
96+ def loadWeatherData (fileName ):
97+ #import json
98+ #json.loads(line)
99+ weather = []
100+
101+ return weather
102+
103+ # QUESTION 5: RETURN THE WEATHER
104+ # OBJECTIVE A (5): Using the data set, weather, passed into the function below,
105+ # find the dictionary in the weather list for the date given by the parameter date.
106+ # (format is year-month-day YYYY-mm-dd). Return the dictionary
107+ def getWeather (weather , date ):
108+
109+ return ''
110+
111+ # QUESTION 6: AVERAGE TEMP 1960 - 2019
112+ # OBJECTIVE A (4): Using the data set you loaded in question 4, which is passed into the
113+ # function below as the parameter, weather, calculate and return the average temperature
114+ # for the entire data set. (ie. Detroit Metro's average temperature) Do not round.
115+ # Use the dictionary keys in the instructions to determine what each value means.
116+ def getAverageTemperature (weather ):
117+ total = 0 ;
118+
119+ return total
120+
121+ # QUESTION 7: TOTAL PERCIPITATION FOR A YEAR
122+ # OBJECTIVE A (5): Using the data set, weather, passed into the function below,
123+ # calculate and return the total percipitation for the given year, year (a String).
124+ # Do not round your answer.
125+ # The data weather is ordered by date. Oldest to Newest
126+ def getYearlyPercipitation (weather , year ):
127+ total = 0 ;
128+
129+ return total
130+
131+ # QUESTION 8: DAYS WITH SNOW
132+ # OBJECTIVE A (5): Using the data set, weather, calculate how many days in the data
133+ # set had snow on the ground. Return the count.
134+ # HINT: Use 'SNWD'
135+ def getDaysWithSnow (weather ):
136+ total = 0
137+
138+ return total
139+
140+ # QUESTION 9: WINDY DAYS
141+ # OBJECTIVE A (5): Using the data set, weather, find the days that had a
142+ # wind speed greater than or equal to 12 meters per second. Add each date to a list and return
143+ # the list of dates.
144+ def getWindyDays (weather ):
145+ days = []
146+
147+ return days
148+
149+ # QUESTION 10: METRIC CONVERSION
150+ # OBJECTIVE A (6): The below function accepts three parameters. number is a
151+ # metric number. fromType is the unit of number. toType is the metric unit
152+ # you are converting to. This function should be able to handle
153+ # units (mm,cm,dcm,m,dkm,hm,km) Return the reuslt. Do not round.
154+ def convertMetric (number , fromType , toType ):
155+
156+ return ''
157+
158+ # QUESTION 11: HIGHEST SNOW FALL YEAR
159+ # OBJECTIVE A (7): Using the data set, weather, passed into the function below,
160+ # determine which year had the highest snowfall (using 'SNOW' per day). If 2 or
161+ # more years have the same, return both years in a last. Otherwise return the
162+ # highest year as the first index of a list.
163+ def getHighestSnowFallYear (weather ):
164+ highestYears = []
165+
166+ return highestYears
167+
168+ # QUESTION 12: HIGHEST AVERAGE TEMP
169+ # OBJECTIVE A (6): Using the data set, weather, determine which year since
170+ # 1960 had the highest average temperature. Return multiple if two or more
171+ # years had the same amount. Put each year in an index of a list and return
172+ # the list.
173+ # HINT: Some years have 366 days.
174+ def getHighestAverageTemp (weather ):
175+ highestYears = []
176+
177+ return highestYears
178+
179+ # QUESTION 13: TEMPERATURE RANGE
180+ # OBJECTIVE A (6): Given the data set weather, count how many days had a temperature
181+ # range greater than or equal to 15 celsius (min to max) return the count
182+ def getTempRangeCount (weather ):
183+ total = 0
184+
185+ return total
186+
187+ # QUESTION 14: TOTAL PERCIPITATION
188+ # OBJECTIVE A (6): Given a start date, end date, and the weather
189+ # data set, calculate the total percipiation between and including
190+ # the dates.
191+ # OBJECTIVE B (2): Round your answer to the nearest whole number.
192+ def getTotalPercipitation (startDate , endDate , weather ):
193+ total = 0.0
194+
195+ return total
196+
197+ # QUESTION 15: THE RIGHT CONDITIONS
198+ # OBJECTIVE A (7): Using the data set, weather, count how many days
199+ # meet the following criteria: Wind Speed = 0, Average Temperature is above
200+ # 20, percipitation = 0 and the date is a Friday. Return the count.
201+ def getTheRightConditionsCount (weather ):
202+ total = 0 ;
203+
204+ return total
205+
206+ # QUESTION 16: PERFECT SQUARE AVERAGE TEMPS
207+ # OBJECTIVE A (7): A perfect square is the product of two equal integers.
208+ # For every day in the weather data, determine how many days had an
209+ # average temperature that was a perfect square.
210+ def getPerfectSqaures (weather ):
211+ total = 0
212+
213+ return total
214+
215+ # QUESTION 17: MEDIAN SNOW DEPTH
216+ # OBJECTIVE A (8): Given a start date and end date parameter,
217+ # and the weather data,
218+ # calculate the median snow depth for the days between and including
219+ # the given dates.
220+ def getMedianSnowDepth (startDate , endDate , weather ):
221+
222+ return ''
223+
224+
225+ # QUESTION 18: FREESTYLE
226+ # OBJECTIVE A (2): Using the weather data, calculate a statistic that has
227+ # not already been calculated in the before questions. Return the result.
228+ # OBJECTIVE B (1): Write at least 2 lines of comments explaining the function.
229+ # OBJECTIVE C (1): Do not use any math/statistical analysis libraries.
230+ def freestyle (weather ):
231+
232+ return ''
233+
234+ ###############################
235+ # MAIN FUNCTION
236+ # NOTE: It is in your best interest to not modify values in this function.
237+ # Input for the programming questions is test data. The supervisor will use
238+ # different values to grade your program.
239+ ###############################
240+ def main ():
241+
242+ # Print Question Answer
243+ print ('Source Code (MAIN) - Division B/C - Climatology - Weather Analyzer' )
244+
245+ print ('QUESTION 0 A (2): ' + getName ('04/27/2019' ))
246+ print ('QUESTION 1 A (2): ' + str (getAverage ([10 ,12.5 ,- 1.34 ,11 ,22.23456 ,7 ,- 9.3 ,1.113 ])))
247+ print ('QUESTION 1 B (2): ' + str (getAverage ([10 ,12.5 ,- 1.34 ,11 ,22.23456 ,7 ,- 9.3 ,1.113 ])))
248+ print ('QUESTION 2 A (2): ' + str (convertTemp (33 , 'F' )))
249+ print ('QUESTION 2 B (2): ' + str (convertTemp (127 , 'C' )))
250+ print ('QUESTION 2 C (2): ' + str (convertTemp (33 , 'Z' )))
251+ print ('QUESTION 3 A (2): ' + str (compareDates ('2018-04-28' , '2019-04-27' )))
252+ print ('QUESTION 3 B (2): ' + str (compareDates ('2019-04-27' , '2019-04-27' )))
253+ print ('QUESTION 3 C (2): ' + str (compareDates ('2019-05-27' , '2019-04-27' )))
254+
255+ # List containing weather information per day since 1960
256+ weather = loadWeatherData ('DetroitMetroData.txt' )
257+ print ('QUESTION 4 A (4): ' + str (len (weather )))
258+ print ('QUESTION 5 A (4): ' + str (getWeather (weather , '1977-07-07' )))
259+ print ('QUESTION 6 A (4): ' + str (getAverageTemperature (weather )))
260+ print ('QUESTION 7 A (5): ' + str (getYearlyPercipitation (weather , '1976' )))
261+ print ('QUESTION 8 A (5): ' + str (getDaysWithSnow (weather )))
262+ print ('QUESTION 9 A (5): ' + str (getWindyDays (weather )))
263+ print ('QUESTION 10 A (6): ' + str (convertMetric (437.377 , 'km' , 'cm' )))
264+ print ('QUESTION 11 A (6): ' + str (getHighestSnowFallYear (weather )))
265+ print ('QUESTION 12 A (6): ' + str (getHighestAverageTemp (weather )))
266+ print ('QUESTION 13 A (6): ' + str (getTempRangeCount (weather )))
267+
268+ print ('QUESTION 14 A (6): ' + str (getTotalPercipitation ('1990-03-02' , '1994-05-10' , weather )))
269+ print ('QUESTION 14 B (2): ' + str (getTotalPercipitation ('1990-03-02' , '1994-05-10' , weather )))
270+
271+ print ('QUESTION 15 A (7): ' + str (getTheRightConditionsCount (weather )))
272+ print ('QUESTION 16 A (7): ' + str (getPerfectSqaures (weather )))
273+ print ('QUESTION 17 A (8): ' + str (getMedianSnowDepth ('2008-12-01' , '2009-03-01' , weather )))
274+
275+ print ('QUESTION 18 A (2): ' + str (freestyle (weather )))
276+ print ('QUESTION 18 B (1): ' + '' )
277+ print ('QUESTION 18 C (1): ' + '' )
278+
279+ main ()
0 commit comments