-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure_cfsr_panels_4x2.py
94 lines (74 loc) · 2.44 KB
/
figure_cfsr_panels_4x2.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
'''
Plot CFSR analyses for given dates
Raul Valenzuela
'''
import plotCFSR as cfsr
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from datetime import datetime
from matplotlib import rcParams
rcParams['xtick.direction'] = 'in'
rcParams['ytick.direction'] = 'in'
rcParams['axes.labelsize'] = 11
rcParams['mathtext.default'] = 'sf'
dates = [
datetime(2003, 1, 12, 12, 0),
datetime(2003, 1, 22, 12, 0),
datetime(2003, 2, 15, 18, 0),
datetime(2004, 1, 9, 12, 0),
datetime(2004, 2, 2, 6, 0),
datetime(2004, 2, 16, 6, 0),
datetime(2004, 2, 25, 6, 0)
]
scale=1.5
fig = plt.figure(figsize=(8*scale, 8*scale))
grid = ImageGrid(fig, 111,
nrows_ncols=(4, 2),
axes_pad=0,
add_all=True,
share_all=True,
label_mode="L",
cbar_location="top",
cbar_mode="single",
cbar_size='2%',
aspect=True)
# homedir = '/media/raul/RauLdisk'
#homedir = '/Volumes/RauLdisk'
homedir = '/localdata'
''' set tile '''
title = 'Integrated water vapor transport $[kg m^{-1} s^{-1}]$\n '
title += 'Mean sea level pressure [hPa]\n'
title += 'Equivalent potential temperature [K] at 1000 hPa'
cfsr.plot(ax = grid,
field = ['iwv_flux',range(250, 1500, 250)],
contour = ['thetaeq',None],
dates = dates,
homedir = homedir,
title = title)
''' turn off last axis '''
grid.axes_all[-1].axis('off')
''' adjust y and x labels '''
axes = grid.axes_all[::2]
for ax in axes:
yticks = ax.yaxis.get_major_ticks()
yticks[0].label1.set_visible(False)
yticks[-1].label1.set_visible(False)
ylabs = [str(n)+'$^\circ$' for n in range(20,55,5)]
ylabs[-1] = ylabs[-1]+'N'
ax.set_yticklabels(ylabs)
for tk in yticks:
tk.label1.set_rotation(90)
xticks = ax.xaxis.get_major_ticks()
xlabs = [str(n)+'$^\circ$' for n in range(150,115,-5)]
xlabs[-1] = xlabs[-1]+'W'
ax.set_xticklabels(xlabs)
''' add units to some contours '''
ax = grid.axes_all[0]
ax.text(0.38,0.81,'hPa',transform=ax.transAxes,rotation=-40,weight='bold')
ax.text(0.35,0.38,'K',transform=ax.transAxes,rotation=30,
color='r',weight='bold')
plt.show()
#fname='/home/raul/Desktop/fig_cfsr_panels.png'
#plt.savefig(fname, dpi=300, format='png',papertype='letter',
# bbox_inches='tight')