-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotseaiceconc_and_sst.py
132 lines (96 loc) · 3.79 KB
/
plotseaiceconc_and_sst.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
import numpy as np
import numpy.ma as ma
import scipy as sp # scientific python
import scipy.stats
import matplotlib.pyplot as plt
import platform as platform
import cccmaplots as cplt
import constants as con
import cccmautils as cutl
import cccmaNC as cnc
import matplotlib.font_manager as fm
cplt = reload(cplt)
con = reload(con)
cutl = reload(cutl)
cnc = reload(cnc)
plt.close("all")
plt.ion()
printtofile=1
casename = 'kemctl1'
timstr = '001-111'
timesel = '0002-01-01,0111-12-31'
casenamep2 = 'kem1pert2' # 2002-2012 sic, sit, adjusted sst
model = 'CanAM4'
plat = platform.system()
if plat == 'Darwin': # means I'm on my mac
basepath = '/Users/kelly/CCCma/CanSISE/RUNS/'
subdir = '/'
else: # on linux workstation in Vic
basepath = '/home/rkm/work/DATA/' + model + '/'
subdir = '/ts/'
fields = 'sicn'
unitss='%'
convs=100
cmincs = -100; cmaxcs = 100 # climo
cmins=-15; cmaxs=15
cminms=-30; cmaxms=30 # monthly anom
cmaps = 'red2blue_w20'
cmaps = 'bone'
fieldg = 'gt'
unitsg='C'
convg=1
#cmincg = 238; cmaxcg = 308
cmincg = -35; cmaxcg = 35
cmincnhg = -45; cmaxcnhg = 45 # polar NH
cming=-2; cmaxg=2
cminmg=-3; cmaxmg=3
cmapg = 'blue2red_20'
fnamecs = basepath + casename + subdir + casename + '_' + fields + '_' + timstr + '_ts.nc'
fnamep2s = basepath + casenamep2 + subdir + casenamep2 + '_' + fields + '_' + timstr + '_ts.nc'
fldcs = cnc.getNCvar(fnamecs,fields.upper(),timesel='0002-01-01,0111-12-31')*convs
fldp2s = cnc.getNCvar(fnamep2s,fields.upper(),timesel='0002-01-01,0111-12-31')*convs
fnamecg = basepath + casename + subdir + casename + '_' + fieldg + '_' + timstr + '_ts.nc'
fnamep2g = basepath + casenamep2 + subdir + casenamep2 + '_' + fieldg + '_' + timstr + '_ts.nc'
fldcg = cnc.getNCvar(fnamecg,fieldg.upper(),timesel='0002-01-01,0111-12-31')*convg
fldp2g = cnc.getNCvar(fnamep2g,fieldg.upper(),timesel='0002-01-01,0111-12-31')*convg
lat = cnc.getNCvar(fnamecs,'lat')
lon = cnc.getNCvar(fnamecs,'lon')
fldcsclim,fldcsstd = cutl.climatologize3d(fldcs)
fldpsclim,fldpsstd = cutl.climatologize3d(fldp2s)
fldcgclim,fldcgstd = cutl.climatologize3d(fldcg)
fldpgclim,fldpgstd = cutl.climatologize3d(fldp2g)
print fldcgclim.shape
lons,lats = np.meshgrid(lon,lat)
plotfldg = fldcgclim[2,:,:] # test Jan sst
plotflds = fldcsclim[2,:,:] # test Jan sicn
plotflds = ma.masked_where(plotflds<=0,plotflds)
#fig = plt.figure()
#cplt.kemmap(plotfldg,lat,lon,cmin=cmincg,cmax=cmaxcg,cmap=cmapg)
fig2 = plt.figure()
bm,pc = cplt.kemmap(plotfldg,lat,lon,cmin=cmincnhg,cmax=cmaxcnhg,cmap=cmapg,type='nh')
#cf = bm.contour(lons,lats,plotflds,colors='k',latlon=True)
cplt.kemmap(plotflds,lat,lon,cmin=cmincs,cmax=cmaxcs,cmap=cmaps,type='nh',suppcb=1)
cf2 = bm.contour(lons,lats,plotflds,colors='k',latlon=True,linewidths='2',levels=[15, 15])
#fig3 = plt.figure()
#cplt.kemmap(plotflds,lat,lon,cmin=cmincs,cmax=cmaxcs,cmap=cmaps,type='nh')
months=con.get_mon()
title = casename + ' ' + fields + ' and ' + fieldg
fig3, spax = plt.subplots(2,6)
fig3.set_size_inches(12,6)
fig3.subplots_adjust(hspace=0,wspace=0)
midx=0
for ax in spax.flat:
plotfldg = fldcgclim[midx,:,:]
plotflds = fldcsclim[midx,:,:]
plotflds = ma.masked_where(plotflds<=0,plotflds)
bm,pc = cplt.kemmap(plotfldg,lat,lon,cmin=cmincnhg,cmax=cmaxcnhg,cmap=cmapg,type='nh',suppcb=1,axis=ax)
#cf = bm.contour(lons,lats,plotflds,colors='k',latlon=True)
cplt.kemmap(plotflds,lat,lon,cmin=cmincs,cmax=cmaxcs,cmap=cmaps,type='nh',suppcb=1,axis=ax)
cf2 = bm.contour(lons,lats,plotflds,colors='k',latlon=True,linewidths='2',levels=[15, 15])
ax.set_title(months[midx])
midx = midx+1
cbar_ax = fig3.add_axes([.91,.25, .02,.5])
fig3.colorbar(pc,cax=cbar_ax) # or do bm.colorbar....
plt.suptitle(title)
if printtofile: # @@ pdf/eps/ps save doesn't work (errors), why?
fig3.savefig(fields + '_' + fieldg + '_' + casename + '_allmos_nh.png')