-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
60 lines (34 loc) · 1.24 KB
/
main.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
from funcs import *
weather = "weather-data\A2a\HADCM3_A2a_TEMP_2020.dif"
global temps_mat, fig
temps_mat = conv(weather)[0]
temps_df = conv(weather)[1]
fig = plt.figure(figsize=(10,12))
def plotter(month):
global cs
fig.canvas.draw()
fig.canvas.flush_events()
ax=plt.axes(projection=ccrs.PlateCarree())
data, lons = add_cyclic_point(temps_mat[month], coord = longitudes)
cs = ax.contourf(lons, latitudes, data,
transform = ccrs.PlateCarree(),cmap='Reds',extend='both')
ax.coastlines()
cb = fig.colorbar(cs, shrink = 0.35)
ax.set_xticks(np.arange(-180,181,15), crs=ccrs.PlateCarree())
lon_formatter = cticker.LongitudeFormatter()
ax.xaxis.set_major_formatter(lon_formatter)
ax.set_yticks(np.arange(-90,91,15), crs=ccrs.PlateCarree())
lat_formatter = cticker.LatitudeFormatter()
ax.yaxis.set_major_formatter(lat_formatter)
ax.grid()
return
axmonth = fig.add_axes([0.15, 0.08, 0.55, 0.03])
month_slider = Slider(ax=axmonth, label='Month',
valmin=0, valmax=11, valinit=5, valstep=1)
plotter(0)
def update(val):
plotter(month_slider.val)
fig.canvas.draw()
fig.canvas.flush_events()
month_slider.on_changed(update)
plt.show()