forked from trondkr/model2roms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotData.py
145 lines (120 loc) · 5.09 KB
/
plotData.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import os
from mpl_toolkits.basemap import Basemap
from pylab import *
def contourMap(grdROMS, tlon, tlat, mydata, depthlevel, var):
map = Basemap(projection='ortho',lon_0=-20,lat_0=25, resolution='c', area_thresh=10000)
levels = np.arange(-2.0, 30.0, 0.5)
plt.figure(figsize=(10,10), frameon=False)
#mydata = np.ma.masked_where(mydata==grdROMS.fill_value,mydata)
if grdROMS.grdName=='GOM':
# Plot the Georges Bank region
map = Basemap(llcrnrlon=-78.5,llcrnrlat=32.5,urcrnrlon=-58,urcrnrlat=45.5,
resolution='i',projection='tmerc',lon_0=-70,lat_0=0,area_thresh=10.)
levels = np.arange(0.0, 26.0, 0.5)
if grdROMS.grdName=='Nordic' or grdROMS.grdName=='Nordic2':
map = Basemap(lon_0=25,boundinglat=50,
resolution='l',area_thresh=100.,projection='npstere')
levels = np.arange(-2.0, 20.0, 0.1)
if grdROMS.grdName=='Troms':
map = Basemap(projection='merc',llcrnrlat=68,urcrnrlat=72,\
llcrnrlon=15,urcrnrlon=24,lat_ts=70,resolution='h',area_thresh=0.)
levels = np.arange(-2.0, 8.0, 0.25)
if grdROMS.grdName=='NS8KM':
map = Basemap(llcrnrlon=-18.5,
llcrnrlat=43.5,
urcrnrlon=32.5,
urcrnrlat=67.7,
resolution='i',projection='tmerc',lon_0=0,lat_0=50,area_thresh=20.)
levels = np.arange(-2.0, 20.0, 0.5)
if grdROMS.grdName=='KINO':
print("KINO")
map = Basemap(llcrnrlon=-18.0,
llcrnrlat=46.0,
urcrnrlon=25.5,
urcrnrlat=67.5,
resolution='i',projection='tmerc',lon_0=0,lat_0=50,area_thresh=50.)
levels = np.arange(-2.0, 20.0, 0.5)
if grdROMS.grdName=='NA':
map = Basemap(lon_0=25,boundinglat=0,
resolution='l',area_thresh=2000.,projection='npstere')
levels = np.arange(-2.0, 25.0, 0.5)
if grdROMS.grdName=='NATL':
map = Basemap(lon_0=2,boundinglat=0,
resolution='l',area_thresh=2000.,projection='npstere')
levels = np.arange(-2.0, 30.0, 0.5)
if grdROMS.grdName=='REGSCEN':
# map = Basemap(projection='ortho',lon_0=-20,lat_0=25, resolution='c', area_thresh=10000)
map = Basemap(llcrnrlon=-50,
llcrnrlat=54,
urcrnrlon=1,
urcrnrlat=78,
resolution='i',projection='tmerc',lon_0=-25,lat_0=60,area_thresh=200.)
levels = np.arange(-2.0, 30.0, 0.5)
if grdROMS.grdName=='GREENLAND':
map = Basemap(llcrnrlon=-50,
llcrnrlat=54,
urcrnrlon=1,
urcrnrlat=78,
resolution='i',projection='tmerc',lon_0=-25,lat_0=60,area_thresh=200.)
levels = np.arange(-2.0, 20.0, 0.5)
x, y = list(map(tlon,tlat))
map.drawcoastlines()
map.fillcontinents(color='grey')
map.drawcountries()
if var=='temperature':
levels = np.arange(-2.0, 36.0, 1)
if var=='salinity':
levels = np.arange(25.0, 40.0, 0.3)
if var=='runoff':
levels = np.arange(1e-4, 1e-8, 1e-10)
if var=='ssh':
levels = np.arange(-1.5, 1.5, 0.1)
if var in ['uvel','vvel','urot','vrot','ubar','vbar']:
levels = np.arange(-1.0, 1.0, 0.1)
if var=='sodamask':
levels=np.arange(0,1,1)
if var=='hice':
levels=np.arange(0,100,0.1)
if var=='aice':
levels=np.arange(0,100,5)
if var=='uice' or var=="vice":
levels=np.arange(-100,100,5)
if var=='ageice':
levels=np.arange(0,12,1)
if var=='snow_thick':
levels=np.arange(0,2,0.1)
if var =='runoff':
CS1 = map.contourf(x, y, mydata)#,alpha=0.5)
plt.colorbar(orientation='horizontal')
else:
CS1 = map.contourf(x, y, mydata, levels, cmap=cm.get_cmap('RdYlBu_r',len(levels)-1) )#,alpha=0.5)
plt.colorbar(CS1, orientation='vertical', extend='both', shrink=0.5)
plt.title('Var:%s - depth:%s - time:%s'%(var,depthlevel,grdROMS.time))
plotfile='figures/'+str(var)+'_depth_ESMF_'+str(depthlevel)+'_time_'+str(grdROMS.time)+'.png'
if not os.path.exists('figures'):
os.makedirs('figure')
plt.savefig(plotfile)
print("Saved figure: %s"%(plotfile))
plt.show()
def contourStationData(data,timedata,datedata,depthdata,stationName):
x = timedata
y = flipud(depthdata)
X,Y = meshgrid(x, y)
data=rot90(data)
levels=np.arange(0, data.max(), 0.5)
plt.figure(figsize=(10,4))
cs1=contourf(X,Y,data,levels,cmap=cm.get_cmap('RdYlBu_r',len(levels)-1),alpha=1.0,extend='both')
cs2=contour(X,Y,data,cs1.levels[::4],colors = ('k',),hold='on',linewidths = (0.1,))
colorbar(cs1,extend='both')
sep=73; s=0; d=[]; t=[]
for i in range(len(timedata)):
if s==sep:
d.append(datedata[i])
t.append(timedata[i])
s=0
s+=1
locs, labels = plt.xticks(t, d)
plt.setp(labels, 'rotation', 'vertical')
plotfile='figures/station_'+str(stationName)+'.png'
plt.savefig(plotfile)
#plt.show()