forked from NOAA-GFDL/MDTF-diagnostics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_composite_all_OBS.ncl
192 lines (139 loc) · 4.94 KB
/
plot_composite_all_OBS.ncl
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
;****************************************************
;
;
;*******************************************************
begin
;; select the cmin, cmax, cint
;;; need the two rows El Nino/La Nina
cmin = (/ (/ -3.2, -8, -60, -40, -32, -8, -60 /) , \
(/ -3.2, -3.6, -50, -32, -28, -7, -50 /) /)
cmax = (/ (/ 3.2, 8, 60, 40, 32, 8, 60 /) , \
(/ 3.2, 3.6, 50, 32, 28, 7, 50 /) /)
cint = (/ (/ 0.4, 1, 10, 5, 4, 1, 10 /), \
(/ 0.4, 0.4, 10, 4, 4, 1, 10 /) /)
modes = (/ "ELNINO", "LANINA" /)
variname2 = (/ "TS", "SW", "LW", "LHF", "SHF", "PR", "FRAD" /)
variables = (/ "ts" , "sw", "lw", "hfls", "hfss", "pr", "frad" /)
varinames = (/ "SST" , "SW~B~net~N", "LW~B~net~N", "LHF", "SHF", "PRECIP", "F~B~rad~N" /)
varunits = (/ "[deg. C]", "[W/m2]", "[W/m2]", "[W/m2]", "[W/m2]", "[mm/day]", "[W/m2]" /)
title_mode = (/ "El Nino", "La Nina" /)
outdir2 = getenv("ENSO_MSE_WKDIR") +"/obs/"
obsdir = getenv("OBS_DATA") +"/DATA/" ; envvar set in ENSO_MSE.py
outdir = getenv("ENSO_MSE_WKDIR_COMPOSITE") +"/obs/"
varcode = getenv("POD_HOME")
model = " " ;;;; leave blank for observations getenv( "CASENAME")
parameter_name = varcode + "/shared/parameters.txt"
nameclima = obsdir + "/netCDF/"
tt0 = 0
xlon1 = 0
xlon2 = 360
xcenter = (xlon1 + xlon2)/2
;;; construct the main title based on model, season and region
season = "XXX"
lon1 = -9999.
lon2 = -9999.
lat1 = -9999.
lat2 = -9999.
undef2 = 1.1E+20
data = asciiread(parameter_name,-1,"string")
season = str_get_field(data(10), 3," ")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
do n = 0, 1
mode = modes(n)
do iv = 0, 6
ff = 1.
if( iv .eq. 5) then
ff = 24. * 60. * 60.
end if
;; read in the data from
namein = obsdir + "/netCDF/" + mode
nameout = outdir2 + "/PS/composite_" + mode
;;; read in various variables then plot
;;
variable = variables(iv) ;;;;
units = varunits(iv) ;;;
colormap = "BlueWhiteOrangeRed" ;;
if( iv .eq. 5 ) then
colormap = "precip4_diff_19lev"
end if
;; the title
namein1 = namein + "/" + variable + ".nc" ;;
namein2 = nameclima + variable + "_clim.nc" ;;;
nameout12 = nameout + "_" + variname2(iv)
;; read in the data and dimensions lon/lat
fin1 = addfile( namein1, "r")
fin2 = addfile( namein2, "r")
lon = fin1->lon
lat = fin1->lat
xmax = dimsizes( lon)
ymax = dimsizes( lat)
dims = (/ ymax, xmax /)
datain1 = new( dims, "float")
datain2 = new( dims, "float")
datain1@_FillValue = undef2
datain2@_FillValue = undef2
datain1 = fin1->$variables(iv)$
datain2 = fin2->$variables(iv)$
;; make the anomaly for plotting
datain = new( dims, "float")
datain@_FillValue = undef2
datain!0="lat"
datain!1="lon"
datain&lat = lat
datain&lon = lon
datain = ff *( datain1 - datain2)
wks_type = "eps"
wks = gsn_open_wks( wks_type, nameout12)
gsn_define_colormap(wks, colormap)
res = True
res@mpMinLonF = xlon1
res@mpMaxLonF = xlon2
res@mpCenterLonF = xcenter ; This is necessary to get the correct map
res@cnFillOn = True
res@cnFillMode = "AreaFill"
res@cnLinesOn = False
res@cnLevelSelectionMode = "ManualLevels"
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = False
res@cnMinLevelValF = cmin( n, iv)
res@cnMaxLevelValF = cmax( n, iv)
res@cnLevelSpacingF = cint( n, iv)
res@gsnMaximize = True
;; title
res@tiMainFontHeightF = 0.025
res@tiMainFont = "helvetica"
;;; title separate as two texts on the top
txres1 = True
txres1@txFontColor = "black"
txres1@txFont = "helvetica"
txres1@txFontHeightF = 0.025
txres1@txJust = "CenterLeft"
txres1@txFuncCode = "~"
xs1 = 0.08
ys1 = 0.84
dy2 = 0.0
dx2 = 0.65
label2 = varinames(iv)
gsn_text_ndc (wks, label2, xs1, ys1, txres1)
label2 = title_mode(n) + " (" + season + ")"
xs1 = xs1 + dx2
gsn_text_ndc (wks, label2, xs1, ys1, txres1)
;; legend - variable mode and season
txres2 = True
txres2@txFontColor = "black"
txres2@txFont = "helvetica"
txres2@txFontHeightF = 0.016
txres2@txJust = "CenterLeft"
txres2@txFuncCode = "~"
xs1 = 0.1
ys1 = 0.18
dy2 = 0.0
dx2 = 0.3
label4 = " Months/Season= " + season + " " + "units:" + units
gsn_text_ndc (wks, label4, xs1, ys1, txres2)
;;;;;
plot = gsn_csm_contour_map(wks, datain, res)
;; frame(wks)
end do ; over variables
end do ; over modes
end