Modifications to scoring and graphics production for the final version of code for the C-LAMP paper in GCB.
1 ; ***********************************************
3 ; ***********************************************
4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
7 load "/fis/cgd/cseg/people/jeff/clamp/co2/taylor_metrics_table.ncl"
8 ;************************************************
10 ;************************************************
11 ; read in data: observed
12 ;************************************************
13 diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
14 fili = "co2_globalView_98.nc"
15 g = addfile (diri+fili,"r")
19 sta = chartostring(g->STATION)
27 ;**************************************************************
28 ; get only the lowest level at each station
29 ;**************************************************************
31 lat_tmp@_FillValue = 1.e+36
34 if (.not. ismissing(lat_tmp(n))) then
35 indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
36 if (dimsizes(indexes) .gt. 1) then
37 lat_tmp(indexes(1:)) = lat_tmp@_FillValue
43 indexes = ind(.not. ismissing(lat_tmp))
44 ;print (dimsizes(indexes))
49 val_ob = val(indexes,:)
50 ;printVarSummary (val_ob)
51 ;print (lat_ob +"/"+lon_ob)
53 ;************************************************
55 ;************************************************
56 diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
57 ; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
58 fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
60 g = addfile(diri2+fili2,"r")
69 ; get the co2 at the lowest level
72 ; change to unit of observed (u mol/mol)
73 ; Model_units [=] kgCO2 / kgDryAir
74 ; 28.966 = molecular weight of dry air
75 ; 44. = molecular weight of CO2
78 factor = (28.966/44.) * 1e6
83 ; y = where(y0 .lt. 287.,y@_FillValue,y)
85 ; print (min(y)+"/"+max(y))
87 ; interpolate into observed station
88 ; note: model is 0-360E, 90S-90N
90 ; to be able to handle observation at (-89.98,-24.80)
94 i = ind(lon_ob .lt. 0.)
95 lon_ob(i) = lon_ob(i) + 360.
97 yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
99 val_model = yo(pts|:,time|:)
100 ; printVarSummary (val_model)
101 ; print (min(val_model)+"/"+max(val_model))
104 val_model = val_model - conform(val_model,dim_avg(val_model),0)
105 ; print (min(val_model)+"/"+max(val_model))
111 ; maximum score for the zone, 60N-90N
113 ; index of stations in this zone
114 ind_z = ind(lat_ob .ge. 60.)
116 ; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
117 ; print (val_ob(ind_z,:))
118 ; print (val_model(ind_z,:))
122 ; maximum score for the zone, 30N-60N
124 ; index of stations in this zone
125 ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
127 ; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
128 ; print (val_ob(ind_z,:))
129 ; print (val_model(ind_z,:))
133 ; maximum score for the zone, EQ-30N
135 ; index of stations in this zone
136 ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
138 ; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
139 ; print (val_ob(ind_z,:))
140 ; print (val_model(ind_z,:))
144 ; maximum score for the zone, 90S-EQ
146 ; index of stations in this zone
147 ind_z = ind(lat_ob .lt. 0. )
149 ; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
150 ; print (val_ob(ind_z,:))
151 ; print (val_model(ind_z,:))
154 npts = dimsizes(ind_z)
157 amp_ob = new((/npts/),float)
158 amp_model = new((/npts/),float)
160 amp_ratio_sta = new((/npts/),float)
161 ccr_sta = new((/npts/),float)
162 M_sta = new((/npts/),float)
163 score_sta = new((/npts/),float)
166 amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
167 amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
169 amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
170 ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
171 M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
172 score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
174 print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
177 amp_ratio_zone = avg(amp_ratio_sta)
178 ccr_zone = avg(ccr_sta)
179 M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
180 score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
182 print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
183 ;****************************************************************************
185 case = (/ "Lat", "Lon", "AR" /)
186 nCase = dimsizes(case ) ; # of Cases [Cases]
190 nVar = dimsizes(var) ; # of Variables
193 CA_ratio = (/lat(ind_z)/)
196 CB_ratio = (/lon(ind_z)/)
199 CC_ratio = (/amp_ratio_sta/)
202 ; arrays to be passed to taylor_diagram. It will calculate the x xnd y coordinates.
203 ratio = new ((/nCase, nVar/),typeof(CA_ratio) )
205 ratio(0,:) = CA_ratio
206 ratio(1,:) = CB_ratio
207 ratio(2,:) = CC_ratio
209 ;**************************************************
210 ; fill an array for a "taylor metrics table"
211 ;**************************************************
213 ; season = (/ "ANN" /)
214 ; nSeason = dimsizes(season)
216 nSeason = dimsizes(season)
218 table = new ( (/nCase,nSeason,nVar/), typeof(ratio) )
219 table(0,0,:) = CA_ratio
220 table(1,0,:) = CB_ratio
221 table(2,0,:) = CC_ratio
224 tt_opt@pltType= "ps" ; "eps" [default], "pdf", "ps"
225 ; "png", "gif" [if you have ImageMajik 'convert']
227 tt_opt@tableTitle = "Station in 60N_90N"
231 taylor_metrics_table("metrics", varSource, case ,season, table, tt_opt)
236 delete (amp_ratio_sta)