|
1 ; *********************************************** |
|
2 ; interpolate into model grids (T42) |
|
3 ; output: lat: S->N lon: 0->360 |
|
4 ; input : lat: N->S lon: -180->180 |
|
5 ; *********************************************** |
|
6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
|
7 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
|
8 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
|
9 ;************************************************ |
|
10 begin |
|
11 |
|
12 nclass = 20 |
|
13 |
|
14 ;************************************************ |
|
15 ; output data |
|
16 ;************************************************ |
|
17 diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/" |
|
18 filo = "land_class_T31.nc" |
|
19 c = addfile(diro+filo,"c") |
|
20 |
|
21 ;************************************************ |
|
22 ; read in observed data |
|
23 ;************************************************ |
|
24 diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/" |
|
25 fili = "land_class_0.25deg_new.nc" |
|
26 g = addfile (diri+fili,"r") |
|
27 bi = g->LAND_CLASS |
|
28 xi = g->lon |
|
29 yi = g->lat |
|
30 |
|
31 ;************************************************ |
|
32 ; change into 0-360E, 90S-90N |
|
33 ;************************************************ |
|
34 |
|
35 yi = (/ yi(::-1) /) |
|
36 bi = (/ bi(::-1,:) /) |
|
37 printVarSummary(bi) |
|
38 |
|
39 b2 = bi |
|
40 x2 = xi |
|
41 |
|
42 nx = dimsizes(xi) |
|
43 nx2 = nx/2 |
|
44 |
|
45 do i= 0,nx-1 |
|
46 if (i .lt. nx2) then |
|
47 p = i + nx2 |
|
48 xi(p) = x2(i) + 360. |
|
49 else |
|
50 p = i - nx2 |
|
51 xi(p) = x2(i) |
|
52 end if |
|
53 bi(:,p)= b2(:,i) |
|
54 end do |
|
55 |
|
56 bi&lat = yi |
|
57 bi&lon = xi |
|
58 |
|
59 print (xi) |
|
60 print (yi) |
|
61 ;exit |
|
62 |
|
63 ;************************************************ |
|
64 ; read in model data |
|
65 ;************************************************ |
|
66 diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/" |
|
67 fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc" |
|
68 f = addfile (diri2+fili2,"r") |
|
69 |
|
70 lon = f->lon |
|
71 lat = f->lat |
|
72 nlon = dimsizes(lon) |
|
73 nlat = dimsizes(lat) |
|
74 |
|
75 ; print (xi) |
|
76 ; print (yi) |
|
77 ; print (xo) |
|
78 ; print (yo) |
|
79 |
|
80 bo = new((/nlat,nlon/),integer) |
|
81 count = new((/nclass/),integer) |
|
82 |
|
83 do j=0,nlat-1 |
|
84 if (j.eq.0 .or. j.eq.nlat-1) then |
|
85 if (j.eq.0) then |
|
86 LATS = -90. |
|
87 LATN = lat(j)+0.5*(lat(j+1)-lat(j)) |
|
88 end if |
|
89 if (j.eq.nlat-1) then |
|
90 LATS = lat(j)-0.5*(lat(j)-lat(j-1)) |
|
91 LATN = 90. |
|
92 end if |
|
93 else |
|
94 LATS = lat(j)-0.5*(lat(j)-lat(j-1)) |
|
95 LATN = lat(j)+0.5*(lat(j+1)-lat(j)) |
|
96 end if |
|
97 |
|
98 do i=0,nlon-1 |
|
99 if (i.eq.0 .or. i.eq.nlon-1) then |
|
100 if (i.eq.0) then |
|
101 LONL = 0. |
|
102 LONR = lon(i)+0.5*(lon(i+1)-lon(i)) |
|
103 end if |
|
104 if (i.eq.nlon-1) then |
|
105 LONL = lon(i)-0.5*(lon(i)-lon(i-1)) |
|
106 LONR = 360. |
|
107 end if |
|
108 else |
|
109 LONL = lon(i)-0.5*(lon(i)-lon(i-1)) |
|
110 LONR = lon(i)+0.5*(lon(i+1)-lon(i)) |
|
111 end if |
|
112 |
|
113 ;print (LATS) |
|
114 ;print (LATN) |
|
115 ;print (LONL) |
|
116 ;print (LONR) |
|
117 |
|
118 count = 0 |
|
119 |
|
120 do n = 0,nclass-1 |
|
121 count(n) = num (bi({LATS:LATN},{LONL:LONR}).eq.n) |
|
122 end do |
|
123 |
|
124 bo(j,i) = maxind(count) |
|
125 end do |
|
126 end do |
|
127 |
|
128 bo!0 = "lat" |
|
129 bo!1 = "lon" |
|
130 bo&lat = lat |
|
131 bo&lon = lon |
|
132 bo@units = bi@units |
|
133 bo@long_name = bi@long_name |
|
134 bo@_FillValue = bi@_FillValue |
|
135 |
|
136 print (min(bo) + "/" + max(bo)) |
|
137 |
|
138 c->LAND_CLASS = bo |
|
139 end |