forrest@0
|
1 |
; ***********************************************
|
forrest@0
|
2 |
; interpolate into model grids (T31)
|
forrest@0
|
3 |
; ***********************************************
|
forrest@0
|
4 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@0
|
5 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@0
|
6 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@0
|
7 |
;************************************************
|
forrest@0
|
8 |
begin
|
forrest@0
|
9 |
|
forrest@0
|
10 |
;************************************************
|
forrest@0
|
11 |
; read in model data
|
forrest@0
|
12 |
;************************************************
|
forrest@0
|
13 |
;fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
|
forrest@0
|
14 |
;model_grid = "T31"
|
forrest@0
|
15 |
;fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
|
forrest@0
|
16 |
;model_grid = "T42"
|
forrest@0
|
17 |
fili2 = "newcn05_ncep_1i_ANN_climo_lnd.nc"
|
forrest@0
|
18 |
model_grid = "1.9"
|
forrest@0
|
19 |
|
forrest@0
|
20 |
diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
|
forrest@0
|
21 |
f = addfile (diri2+fili2,"r")
|
forrest@0
|
22 |
|
forrest@0
|
23 |
lon = f->lon
|
forrest@0
|
24 |
lat = f->lat
|
forrest@0
|
25 |
nlon = dimsizes(lon)
|
forrest@0
|
26 |
nlat = dimsizes(lat)
|
forrest@0
|
27 |
|
forrest@0
|
28 |
; print (xi)
|
forrest@0
|
29 |
; print (yi)
|
forrest@0
|
30 |
;************************************************
|
forrest@0
|
31 |
; output data
|
forrest@0
|
32 |
;************************************************
|
forrest@0
|
33 |
diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
|
forrest@0
|
34 |
filo = "amazon_biomass_"+model_grid+".nc"
|
forrest@0
|
35 |
c = addfile(diro+filo,"c")
|
forrest@0
|
36 |
;************************************************
|
forrest@0
|
37 |
; read in observed data
|
forrest@0
|
38 |
;************************************************
|
forrest@0
|
39 |
diri = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
|
forrest@0
|
40 |
fili = "amazon_biomass.nc"
|
forrest@0
|
41 |
g = addfile (diri+fili,"r")
|
forrest@0
|
42 |
bi = g->BIOMASS
|
forrest@0
|
43 |
xi = g->lon
|
forrest@0
|
44 |
yi = g->lat
|
forrest@0
|
45 |
;************************************************
|
forrest@0
|
46 |
; from class to value:
|
forrest@0
|
47 |
; Biomass map has 11 classes: (unit= Mg/ha)
|
forrest@0
|
48 |
; 0: (_FillValue)
|
forrest@0
|
49 |
; 1: 0-25 (12.5)
|
forrest@0
|
50 |
; 2: 25-50 (37.5)
|
forrest@0
|
51 |
; 3: 50-75 (62.5)
|
forrest@0
|
52 |
; 4: 75-100 (87.5)
|
forrest@0
|
53 |
; 5: 100-150 (125)
|
forrest@0
|
54 |
; 6: 150-200 (175)
|
forrest@0
|
55 |
; 7: 200-250 (225)
|
forrest@0
|
56 |
; 8: 250-300 (275)
|
forrest@0
|
57 |
; 9: 300-350 (325)
|
forrest@0
|
58 |
; 10: 350-400 (375)
|
forrest@0
|
59 |
; 11: >400 (425)
|
forrest@0
|
60 |
;--------------------------
|
forrest@0
|
61 |
|
forrest@0
|
62 |
bi@_FillValue = 1.e+36
|
forrest@0
|
63 |
|
forrest@0
|
64 |
bi = where(bi.eq.0., bi@_FillValue,bi)
|
forrest@0
|
65 |
bi = where(bi.eq.1., 12.5,bi)
|
forrest@0
|
66 |
bi = where(bi.eq.2., 37.5,bi)
|
forrest@0
|
67 |
bi = where(bi.eq.3., 62.5,bi)
|
forrest@0
|
68 |
bi = where(bi.eq.4., 87.5,bi)
|
forrest@0
|
69 |
bi = where(bi.eq.5., 125.,bi)
|
forrest@0
|
70 |
bi = where(bi.eq.6., 175.,bi)
|
forrest@0
|
71 |
bi = where(bi.eq.7., 225.,bi)
|
forrest@0
|
72 |
bi = where(bi.eq.8., 275.,bi)
|
forrest@0
|
73 |
bi = where(bi.eq.9., 325.,bi)
|
forrest@0
|
74 |
bi = where(bi.eq.10.,375.,bi)
|
forrest@0
|
75 |
bi = where(bi.eq.11.,425.,bi)
|
forrest@0
|
76 |
|
forrest@0
|
77 |
;print("min/max = " + min(bi) + "/" + max(bi))
|
forrest@0
|
78 |
|
forrest@0
|
79 |
;************************************************
|
forrest@0
|
80 |
; Observed factor_aboveground = 0.5
|
forrest@0
|
81 |
;************************************************
|
forrest@0
|
82 |
|
forrest@0
|
83 |
factor_aboveground = 0.5
|
forrest@0
|
84 |
;bi = bi * factor_aboveground
|
forrest@0
|
85 |
|
forrest@0
|
86 |
|
forrest@0
|
87 |
;************************************************
|
forrest@0
|
88 |
; find model grids that is inside observed grids
|
forrest@0
|
89 |
;************************************************
|
forrest@0
|
90 |
ind_lonL = min(ind(lon .ge. xi(0)))
|
forrest@0
|
91 |
ind_lonR = max(ind(lon .le. xi(dimsizes(xi)-1)))
|
forrest@0
|
92 |
|
forrest@0
|
93 |
print (ind_lonL)
|
forrest@0
|
94 |
;print (xi(0))
|
forrest@0
|
95 |
;print (lon(ind_lonL))
|
forrest@0
|
96 |
|
forrest@0
|
97 |
print (ind_lonR)
|
forrest@0
|
98 |
;print (xi(dimsizes(xi)-1))
|
forrest@0
|
99 |
;print (lon(ind_lonR))
|
forrest@0
|
100 |
|
forrest@0
|
101 |
ind_latS = min(ind(lat .ge. yi(0)))
|
forrest@0
|
102 |
ind_latN = max(ind(lat .le. yi(dimsizes(yi)-1)))
|
forrest@0
|
103 |
|
forrest@0
|
104 |
print (ind_latS)
|
forrest@0
|
105 |
;print (yi(0))
|
forrest@0
|
106 |
;print (lat(ind_latS))
|
forrest@0
|
107 |
|
forrest@0
|
108 |
print (ind_latN)
|
forrest@0
|
109 |
;print (yi(dimsizes(yi)-1))
|
forrest@0
|
110 |
;print (lat(ind_latN))
|
forrest@0
|
111 |
|
forrest@0
|
112 |
nlat_out = ind_latN - ind_latS + 1
|
forrest@0
|
113 |
nlon_out = ind_lonR - ind_lonL + 1
|
forrest@0
|
114 |
|
forrest@0
|
115 |
print (nlat_out)
|
forrest@0
|
116 |
print (nlon_out)
|
forrest@0
|
117 |
|
forrest@0
|
118 |
bo = new((/nlat_out,nlon_out/),float)
|
forrest@0
|
119 |
lat_out = new((/nlat_out/),float)
|
forrest@0
|
120 |
lon_out = new((/nlon_out/),float)
|
forrest@0
|
121 |
|
forrest@0
|
122 |
do jj=0,nlat_out-1
|
forrest@0
|
123 |
j = ind_latS + jj
|
forrest@0
|
124 |
lat_out(jj) = lat(j)
|
forrest@0
|
125 |
if (j.eq.0 .or. j.eq.nlat-1) then
|
forrest@0
|
126 |
if (j.eq.0) then
|
forrest@0
|
127 |
LATS = -90.
|
forrest@0
|
128 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@0
|
129 |
end if
|
forrest@0
|
130 |
if (j.eq.nlat-1) then
|
forrest@0
|
131 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@0
|
132 |
LATN = 90.
|
forrest@0
|
133 |
end if
|
forrest@0
|
134 |
else
|
forrest@0
|
135 |
LATS = lat(j)-0.5*(lat(j)-lat(j-1))
|
forrest@0
|
136 |
LATN = lat(j)+0.5*(lat(j+1)-lat(j))
|
forrest@0
|
137 |
end if
|
forrest@0
|
138 |
do ii=0,nlon_out-1
|
forrest@0
|
139 |
i = ind_lonL + ii
|
forrest@0
|
140 |
if (jj.eq.0) then
|
forrest@0
|
141 |
lon_out(ii) = lon(i)
|
forrest@0
|
142 |
end if
|
forrest@0
|
143 |
if (i.eq.0 .or. i.eq.nlon-1) then
|
forrest@0
|
144 |
if (i.eq.0) then
|
forrest@0
|
145 |
LONL = 0.
|
forrest@0
|
146 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@0
|
147 |
end if
|
forrest@0
|
148 |
if (i.eq.nlon-1) then
|
forrest@0
|
149 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@0
|
150 |
LONR = 360.
|
forrest@0
|
151 |
end if
|
forrest@0
|
152 |
else
|
forrest@0
|
153 |
LONL = lon(i)-0.5*(lon(i)-lon(i-1))
|
forrest@0
|
154 |
LONR = lon(i)+0.5*(lon(i+1)-lon(i))
|
forrest@0
|
155 |
end if
|
forrest@0
|
156 |
|
forrest@0
|
157 |
print (LATS)
|
forrest@0
|
158 |
print (LATN)
|
forrest@0
|
159 |
print (LONL)
|
forrest@0
|
160 |
print (LONR)
|
forrest@0
|
161 |
|
forrest@0
|
162 |
bo(jj,ii) = avg(bi({LATS:LATN},{LONL:LONR}))
|
forrest@0
|
163 |
end do
|
forrest@0
|
164 |
end do
|
forrest@0
|
165 |
|
forrest@0
|
166 |
lon_out!0 = "lon"
|
forrest@0
|
167 |
lon_out@long_name = "longitude"
|
forrest@0
|
168 |
lon_out@units = "degrees_east"
|
forrest@0
|
169 |
lon_out&lon = lon_out
|
forrest@0
|
170 |
|
forrest@0
|
171 |
lat_out!0 = "lat"
|
forrest@0
|
172 |
lat_out@long_name = "latitude"
|
forrest@0
|
173 |
lat_out@units = "degrees_north"
|
forrest@0
|
174 |
lat_out&lat = lat_out
|
forrest@0
|
175 |
|
forrest@0
|
176 |
bo!0 = "lat"
|
forrest@0
|
177 |
bo!1 = "lon"
|
forrest@0
|
178 |
bo&lat = lat_out
|
forrest@0
|
179 |
bo&lon = lon_out
|
forrest@0
|
180 |
bo@units = bi@units
|
forrest@0
|
181 |
bo@long_name = bi@long_name
|
forrest@0
|
182 |
; bo@_FillValue = bi@_FillValue
|
forrest@0
|
183 |
bo@_FillValue = 1.e+36
|
forrest@0
|
184 |
|
forrest@0
|
185 |
c->BIOMASS = bo
|
forrest@0
|
186 |
c->lat = lat_out
|
forrest@0
|
187 |
c->lon = lon_out
|
forrest@0
|
188 |
end |