-
Notifications
You must be signed in to change notification settings - Fork 319
/
hurricane.py
80 lines (62 loc) · 2.24 KB
/
hurricane.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#YOUR NAME HERE
#YOUR EMAIL HERE
#Inspired by 2018 Nifty Program by Phil Ventura:
# This program uses his turtle setup but processing
# of data is with Pandas.
import turtle
import pandas as pd
def setup(windowTitle):
"""Creates the Turtle and the Screen with the map background
and coordinate system set to match latitude and longitude.
:return: a tuple containing the Turtle and the Screen
DO NOT CHANGE THE CODE IN THIS FUNCTION!
"""
screen = turtle.Screen()
screen.title(windowTitle)
# this assures that the size of the screen will match the map image:
screen.setup(800, 404)
#Set coordinates for latitude and longitude:
screen.setworldcoordinates(-180,-90,180,90)
# ... which is the same size as our image
# now set the background to our space image
screen.bgpic("mapNASA.gif")
t = turtle.Turtle()
t.pensize(1)
t.color('red')
t.penup()
return t,screen
def animate(t,lat,lon,wind):
"""
Takes as input: a turtle, the location (as latitude and longitude) and
the wind speed. The turtle moves to the location, changes color & pensize
(see below).
* Red for Category 5 (windspeed > 157 mph)
* Orange for Category 4 (windspeed in 130-156 mph)
* Yellow for Category 3 (windspeed in 111-129 mph)
* Green for Category 2 (windspeed in 96-110 mph)
* Blue for Category 1 (windspeed in 74-95 mph)
* White if not hurricane strength
The thickness of the line should change in proportion to the hurricane category
(i.e. pensize(5) for Category 5, pensize(4) for Category 4, etc.).
"""
###################################
### FILL IN YOUR CODE HERE ###
### Other thanname/email above, ###
### this is the only section ###
### you change in this program. ###
###################################
return(t)
def main():
"""Animates the path of hurricane from file:
"""
hFile = input('Enter file name: ')
t, wn = setup(hFile)
df = pd.read_csv(hFile)
for index,row in df.iterrows():
lat = int(row["Lat"])
lon = int(row["Lon"])
wind = row["Wind"]
print(lat,lon,wind)
animate(t,lat,lon,wind)
if __name__ == "__main__":
main()