-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_composites.eventStats.future-climo.ncl
214 lines (192 loc) · 8.48 KB
/
plot_composites.eventStats.future-climo.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
; #########################################################################
;
;#########################################################################
;
; #########################################################################
; BEGIN
; #########################################################################
begin
; Which RCM?
modelID = (/"erain","hadgem","mpi","gfdl"/)
nmods = dimsizes(modelID)
; Extreme parameters
ptile = (/"97.00","95.00"/)
np1 = dimsizes(ptile)
persistence = (/"24","36"/)
np2 = dimsizes(persistence)
; Composite location
dirIN="/data/dswales/NA-CORDEX/ARdet/composites/"
; Output location
dirOUT = "/home/dswales/Projects/NA-CORDEX/scripts/ARdet/plots/composites/"
; #########################################################################
; Plot configuration
; #########################################################################
wks_type = "png"
varName = "precip"
varRangeCumPrecip = (/-100.,100./)
varRangeFrac = (/0.,1./)
varRangedFrac = (/-50,50/)
ctable = "NCV_bright"
units = "mm"
; Variable spacing.
nLevels = 40.0
dVarCumPrecip = ((varRangeCumPrecip(1)-varRangeCumPrecip(0))/nLevels)
dVarFrac = ((varRangeFrac(1)-varRangeFrac(0))/nLevels)
dVardFrac = ((varRangedFrac(1)-varRangedFrac(0))/nLevels)
; Load colortables for plots
ctableD = "NCV_blue_red"
ctable = "NCV_bright"
cmap = read_colormap_file(ctable)
cmap(0,:) = namedcolor2rgba("white")
ncmap = dimsizes(cmap(:,0)) ; # colors
cmapD = read_colormap_file(ctableD)
cmapD = cmapD(::-1,:)
ncmapD = dimsizes(cmapD(:,0)) ; # colors
; Configuration for plot.
res = True
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnInfoLabelOn = False ; turn off cn info label
res@cnFillOn = True ; turn on color
res@lbLabelBarOn = False ; turn off individual cb's
res@cnLinesOn = False ; Turn off lines
res@cnLineLabelsOn = False ; Turn off line labels
res@tmYRLabelsOn = False ; no right labels
res@tmYROn = False ; no right tickmarks
res@tmXTOn = False ; no top tickmarks
res@cnLevelSelectionMode = "ManualLevels" ; Manually set levels
res@mpOutlineBoundarySets = "GeophysicalAndUSStates" ; Plot boundary set
res@gsnPaperOrientation = "landscape" ; orientation
res@mpMaxLatF = 75. ; specify the plot domain
res@mpMinLatF = 5. ;
res@mpMinLonF = 200. ;
res@mpMaxLonF = 270. ;
res@mpCenterLonF = 235. ;
res@cnMissingValFillPattern = 17 ; set the missing value fill pattern to 17
res@tmXBLabelFontHeightF = 0.015 ; resize tick labels
res@tmYLLabelFontHeightF = 0.015 ;
; Load variable specific configuration
res@cnFillPalette = cmap(:ncmap-3,:) ; skip last two colors
res@cnMinLevelValF = varRangeFrac(0) ; Lower range
res@cnMaxLevelValF = varRangeFrac(1) ; Uppermost level
res@cnLevelSpacingF = dVarFrac ; level spacing
;
resC = res
resC@cnFillPalette = cmapD(:ncmap-3,:) ; skip last two colors
resC@cnMinLevelValF = varRangeCumPrecip(0) ; Lower range
resC@cnMaxLevelValF = varRangeCumPrecip(1) ; Uppermost level
resC@cnLevelSpacingF = dVarCumPrecip ; level spacing
;
resD = res
resD@cnFillPalette = cmapD(:ncmapD-3,:) ; skip last two colors
resD@cnMinLevelValF = varRangedFrac(0) ; Lower range
resD@cnMaxLevelValF = varRangedFrac(1) ; Uppermost level
resD@cnLevelSpacingF = dVardFrac ; level spacing
; Loop over all thresholds
do ip1=0,np1-1
do ip2=0,np2-1
; #########################################################################
; Loop over all models and create plots.
; #########################################################################
plot1 = new(nmods,graphic)
plot2 = new(nmods*2,graphic)
fileOUT = dirOUT+"composite.eventStats.future-historical.MultiModel."+persistence(ip2)+"hrs."+ptile(ip1)+"ptile"
print(fileOUT+"."+wks_type)
wks = gsn_open_wks(wks_type,fileOUT); send graphics to PNG file
do ij=0,nmods-1
; ##########################################
; Read in data
; ##########################################
;fileIN = "data/composites/composite.frequency."+modelID(ij)+".nc"
fileIN = dirIN+"composite.frequency.eventStats."+persistence(ip2)+"hrs."+ptile(ip1)+"ptile."+modelID(ij)+".nc"
fileID = addfile(fileIN,"r")
lon = fileID->lon(5::,5::)
lat = fileID->lat(5::,5::)
precip_total_hist = fileID->total_precip_hist(5::,5::)
precip_event_hist = fileID->event_precip_hist(5::,5::)
precip_eventfrac_hist = fileID->frac_event_hist(5::,5::)
precip_total_future = fileID->total_precip_future(5::,5::)
precip_event_future = fileID->event_precip_future(5::,5::)
precip_eventfrac_future = fileID->frac_event_future(5::,5::)
; ##########################################
; Compute event fraction precipitation
; ##########################################
event_frac_hist = 100.*precip_event_hist/where(precip_total_hist .eq. 0,-999.,precip_total_hist)
event_frac_hist@lat2d = lat
event_frac_hist@lon2d = lon
event_frac_hist@units = " "
;
event_frac_future = 100.*precip_event_future/where(precip_total_future .eq. 0,-999.,precip_total_future)
event_frac_future@lat2d = lat
event_frac_future@lon2d = lon
event_frac_future@units = " "
; ##########################################
; Compute changes (future-historical)
; ##########################################
dTotalPrecip = (precip_total_future/(30.*6.))-(precip_total_hist/(31.*6.))
dTotalPrecip@lat2d = lat
dTotalPrecip@lon2d = lon
dTotalPrecip@units = " "
;
dEventFrac = event_frac_future - event_frac_hist
dEventFrac@lat2d = lat
dEventFrac@lon2d = lon
dEventFrac@units = " "
;
dExtremeFrac = 100.*(precip_eventfrac_future - precip_eventfrac_hist)
dExtremeFrac@lat2d = lat
dExtremeFrac@lon2d = lon
dEventFrac@units = " "
if (ij .eq. 0) then
dTotalPrecip = 0
dEventFrac = 0
dExtremeFrac = 0
end if
; ##########################################
; Make plots
; ##########################################
resD@tmYLLabelsOn = False
resD@tmXBLabelsOn = False
resC@tmYLLabelsOn = False
resC@tmXBLabelsOn = True
if (ij .eq. 0) then
resD@tmYLLabelsOn = True
resC@tmYLLabelsOn = True
end if
resC@tiMainString = modelID(ij)
plot1(ij) = gsn_csm_contour_map(wks,dTotalPrecip,resC)
plot2(ij) = gsn_csm_contour_map(wks,dEventFrac,resD)
resD@tmXBLabelsOn = True
plot2(ij+nmods) = gsn_csm_contour_map(wks,dExtremeFrac,resD)
end do
; #########################################################################
; Make panel plot (1 upper row, 2 lower row)
; #########################################################################
; Upper panel configuration
res_U = True
res_U@gsnFrame = False
res_U@gsnPanelTop = 0.999
res_U@gsnPanelBottom = 0.60
res_U@gsnPanelLabelBar = True
res_U@lbTitleString = "(mm/month)"
res_U@lbTitleFontHeightF= .01
res_U@pmLabelBarOrthogonalPosF = -0.015 ; move whole thing down a tad
; Lower panel configuration
res_L = True
res_L@gsnFrame = False
res_L@gsnPanelTop = 0.60
res_L@gsnPanelBottom = 0.1
res_L@gsnPanelLabelBar = True
res_L@lbTitleString = "Frequency (%)"
res_L@lbTitleFontHeightF= .01
res_L@pmLabelBarOrthogonalPosF = -0.015 ; move whole thing down a tad
; Panel upper and lower
gsn_panel(wks,plot1,(/1,nmods/),res_U)
gsn_panel(wks,plot2,(/2,nmods/),res_L)
frame(wks)
end do ; Loop over duration
end do ; Loop over persistence
; #########################################################################
; END PROGRAM
; #########################################################################
end