forked from ecjoliver/eddyTracking
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eddy_plot.py
195 lines (166 loc) · 7.76 KB
/
eddy_plot.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
'''
Plot eddy tracks
'''
# Load required modules
import numpy as np
from matplotlib import pyplot as plt
import mpl_toolkits.basemap as bm
import params
import experiments as exps
# Load eddy data
data_dir = './'
data_dir = exps.data_dir
#run = 'cb_AVISO'
#data = np.load(data_dir+'eddy_track_'+run+'.npz')
#eddies_AVISO = data['eddies']
run = 'cb_NEMO'
data = np.load(data_dir+'eddy_track_'+run+'.npz')
eddies_CTRL = data['eddies']
#run = 'CTRL'
#data = np.load(data_dir+'eddy_track_'+run+'.npz')
#eddies_CTRL = data['eddies']
#run = 'A1B'
#data = np.load(data_dir+'eddy_track_'+run+'.npz')
#eddies_A1B = data['eddies']
# Plot eddy tracks
age_min_weeks = [4, 16, 32]
#age_min_weeks = [8, 32]
domain = [134, 180, -55, 0]
#domain = [90, 180, -55, 0]
plt.figure()
cnt = 1
for age in age_min_weeks:
#
age_min = age*7 # [days]
#
plt.subplot(3, len(age_min_weeks), cnt)
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy age > ' + str(age) + ' weeks')
for ed in range(len(eddies_CTRL)):
#print ed
lon, lat = proj(eddies_CTRL[ed]['lon'], eddies_CTRL[ed]['lat'])
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'anticyclonic'):
plt.plot(lon, lat, 'r-')
plt.plot(lon[-1], lat[-1], 'ro')
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'cyclonic'):
plt.plot(lon, lat, 'b-')
plt.plot(lon[-1], lat[-1], 'bo')
plt.subplot(3, len(age_min_weeks), cnt+len(age_min_weeks))
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy age > ' + str(age) + ' weeks')
#
#for ed in range(len(eddies_A1B)):
#lon, lat = proj(eddies_A1B[ed]['lon'], eddies_A1B[ed]['lat'])
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'anticyclonic'):
#plt.plot(lon, lat, 'r-')
#plt.plot(lon[-1], lat[-1], 'ro')
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'cyclonic'):
#plt.plot(lon, lat, 'b-')
#plt.plot(lon[-1], lat[-1], 'bo')
#
plt.subplot(3, len(age_min_weeks), cnt+2*len(age_min_weeks))
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy age > ' + str(age) + ' weeks')
#
#for ed in range(len(eddies_AVISO)):
#lon, lat = proj(eddies_AVISO[ed]['lon'], eddies_AVISO[ed]['lat'])
#if (eddies_AVISO[ed]['age']*7 > age_min) & (eddies_AVISO[ed]['type'] == 'anticyclonic'):
#plt.plot(lon, lat, 'r-')
#plt.plot(lon[-1], lat[-1], 'ro')
#if (eddies_AVISO[ed]['age']*7 > age_min) & (eddies_AVISO[ed]['type'] == 'cyclonic'):
#plt.plot(lon, lat, 'b-')
#plt.plot(lon[-1], lat[-1], 'bo')
#
cnt += 1
#plt.show()
#plt.savefig('../../../documents/10_Tasman_Sea_Eddies/figures/eddies_OFAM_orig.pdf', bbox_inches='tight', pad_inches=0.5)
#plt.savefig('./eddies_OFAM_orig1.png', bbox_inches='tight', pad_inches=0.5)
plt.savefig(exps.plot_dir+'eddies_OFAM_orig1.png', bbox_inches='tight', pad_inches=0.5)
domain = [134, 180, -50, -25]
plt.figure()
cnt = 1
for age in age_min_weeks:
#
age_min = age*7 # [days]
#
plt.subplot(2, len(age_min_weeks), cnt)
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy age > ' + str(age) + ' weeks')
#
for ed in range(len(eddies_CTRL)):
lon, lat = proj(eddies_CTRL[ed]['lon'], eddies_CTRL[ed]['lat'])
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'anticyclonic'):
plt.plot(lon, lat, 'r-')
plt.plot(lon[-1], lat[-1], 'ro')
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'cyclonic'):
plt.plot(lon, lat, 'b-')
plt.plot(lon[-1], lat[-1], 'bo')
#
cnt += 1
#
plt.subplot(2, len(age_min_weeks), cnt)
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy age > ' + str(age) + ' weeks')
#
#for ed in range(len(eddies_A1B)):
#lon, lat = proj(eddies_A1B[ed]['lon'], eddies_A1B[ed]['lat'])
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'anticyclonic'):
#plt.plot(lon, lat, 'r-')
#plt.plot(lon[-1], lat[-1], 'ro')
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'cyclonic'):
#plt.plot(lon, lat, 'b-')
#plt.plot(lon[-1], lat[-1], 'bo')
#
cnt += 1
# plt.savefig('../../../documents/10_Tasman_Sea_Eddies/figures/eddies_OFAM_orig.pdf', bbox_inches='tight', pad_inches=0.5)
# plt.savefig('../../../documents/10_Tasman_Sea_Eddies/figures/eddies_OFAM_orig.png', bbox_inches='tight', pad_inches=0.5)
#plt.savefig('./eddies_OFAM_orig2.png', bbox_inches='tight', pad_inches=0.5)
plt.savefig(exps.plot_dir+'eddies_OFAM_orig2.png', bbox_inches='tight', pad_inches=0.5)
# Plot eddy generation locations
age_min = 32*7 # days
age_min = 16*7 # days
plt.figure()
plt.subplot(1, 2, 1)
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy generation locations (CTRL)')
for ed in range(len(eddies_CTRL)):
lon, lat = proj(eddies_CTRL[ed]['lon'], eddies_CTRL[ed]['lat'])
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'anticyclonic'):
plt.plot(lon[0], lat[0], 'ro')
plt.plot(lon[-1], lat[-1], 'rx')
if (eddies_CTRL[ed]['age'] > age_min) & (eddies_CTRL[ed]['type'] == 'cyclonic'):
plt.plot(lon[0], lat[0], 'bo')
plt.plot(lon[-1], lat[-1], 'bx')
plt.subplot(1, 2, 2)
proj = bm.Basemap(projection='merc', llcrnrlat=domain[2], llcrnrlon=domain[0], urcrnrlat=domain[3], urcrnrlon=domain[1], resolution='i')
proj.drawcoastlines()
proj.drawparallels(range(-50,0+1,10), labels=[True,False,False,False])
proj.drawmeridians(range(140,180+1,10), labels=[False,False,False,True])
plt.title('Eddy generation locations (A1B)')
#for ed in range(len(eddies_A1B)):
#lon, lat = proj(eddies_A1B[ed]['lon'], eddies_A1B[ed]['lat'])
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'anticyclonic'):
#plt.plot(lon[0], lat[0], 'ro')
#plt.plot(lon[-1], lat[-1], 'rx')
#if (eddies_A1B[ed]['age'] > age_min) & (eddies_A1B[ed]['type'] == 'cyclonic'):
#plt.plot(lon[0], lat[0], 'bo')
#plt.plot(lon[-1], lat[-1], 'bx')
plt.savefig(exps.plot_dir+'last.png')