|
1 ;************************************************ |
|
2 ; Read half-hourly data and write monthly data |
|
3 ; input data is : half-hourly |
|
4 ; |
|
5 ; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX |
|
6 ; date, lat, lon |
|
7 ;************************************************ |
|
8 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
|
9 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
|
10 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
|
11 ;************************************************ |
|
12 begin |
|
13 |
|
14 dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/" |
|
15 station_name = "Kaamanen" |
|
16 file_name_add = "carboeurope" |
|
17 year_start = 2000 |
|
18 year_end = 2003 |
|
19 |
|
20 ; final output |
|
21 diro = dir_root + station_name + "/" |
|
22 filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc" |
|
23 c = addfile(diro+filo,"c") |
|
24 print (filo) |
|
25 |
|
26 ; input dir |
|
27 diri = dir_root + station_name + "/" |
|
28 |
|
29 nyear = year_end - year_start + 1 |
|
30 nmon = 12 |
|
31 nlat = 1 |
|
32 nlon = 1 |
|
33 |
|
34 ; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./) |
|
35 end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./) |
|
36 end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./) |
|
37 |
|
38 data_out1 = new((/nyear,nmon/),float) |
|
39 data_out2 = new((/nyear,nmon/),float) |
|
40 data_out3 = new((/nyear,nmon/),float) |
|
41 data_out4 = new((/nyear,nmon/),float) |
|
42 time_out = new((/nyear,nmon/),integer) |
|
43 lat_out = new((/nlat/),float) |
|
44 lon_out = new((/nlon/),float) |
|
45 |
|
46 do m = 0,nyear-1 |
|
47 year = year_start + m |
|
48 |
|
49 ; if (mod(year,4) .eq. 0) then |
|
50 if (year .eq. 2000) then |
|
51 hour_of_month = end_of_month2 * 24. |
|
52 else |
|
53 hour_of_month = end_of_month1 * 24. |
|
54 end if |
|
55 ; print (hour_of_month) |
|
56 |
|
57 ; input file |
|
58 fili = file_name_add+"."+station_name+"."+year+".nc" |
|
59 b = addfile(diri+fili,"r") |
|
60 print (fili) |
|
61 |
|
62 ; co2 flux unit: umol m-2 s-1 |
|
63 data1 = b->FCO2M |
|
64 ; net radiation flux unit: W m-2 |
|
65 data2 = b->RN |
|
66 ; sensible heat flux unit: W m-2 |
|
67 data3 = b->H |
|
68 ; latent heat flux unit: W m-2 |
|
69 data4 = b->LE |
|
70 |
|
71 ; time unit: hour since 01-01 (mm-dd) |
|
72 time = b->time |
|
73 |
|
74 do n= 0,nmon-1 |
|
75 if (n.eq.0) then |
|
76 timeL = 0. |
|
77 timeR = hour_of_month(0) |
|
78 else |
|
79 timeL = hour_of_month(n-1) |
|
80 timeR = hour_of_month(n) |
|
81 end if |
|
82 ; print (timeL) |
|
83 ; print (timeR) |
|
84 |
|
85 i = ind(time.ge.timeL .and. time.lt.timeR) |
|
86 ; print (i) |
|
87 |
|
88 data_out1(m,n) = avg(data1(i)) |
|
89 data_out2(m,n) = avg(data2(i)) |
|
90 data_out3(m,n) = avg(data3(i)) |
|
91 data_out4(m,n) = avg(data4(i)) |
|
92 |
|
93 time_out(m,n) = year*100 + n + 1 |
|
94 ; print (time_out(m,n)) |
|
95 |
|
96 delete (i) |
|
97 end do |
|
98 if (m.lt.nyear-1) then |
|
99 delete (data1) |
|
100 delete (data2) |
|
101 delete (data3) |
|
102 delete (data4) |
|
103 delete (time) |
|
104 end if |
|
105 end do |
|
106 |
|
107 lat_out = 69.1407 |
|
108 lon_out = 27.2950 |
|
109 |
|
110 data_out1!0 = "year" |
|
111 data_out1!1 = "month" |
|
112 data_out1@long_name = data1@long_name |
|
113 data_out1@units = data1@units |
|
114 data_out1@_FillValue = 1.e+36 |
|
115 ; print (data_out1) |
|
116 |
|
117 data_out2!0 = "year" |
|
118 data_out2!1 = "month" |
|
119 data_out2@long_name = data2@long_name |
|
120 data_out2@units = data2@units |
|
121 data_out2@_FillValue = 1.e+36 |
|
122 ; print (data_out2) |
|
123 |
|
124 data_out3!0 = "year" |
|
125 data_out3!1 = "month" |
|
126 data_out3@long_name = data3@long_name |
|
127 data_out3@units = data3@units |
|
128 data_out3@_FillValue = 1.e+36 |
|
129 ; print (data_out3) |
|
130 |
|
131 data_out4!0 = "year" |
|
132 data_out4!1 = "month" |
|
133 data_out4@long_name = data4@long_name |
|
134 data_out4@units = data4@units |
|
135 data_out4@_FillValue = 1.e+36 |
|
136 ; print (data_out4) |
|
137 |
|
138 time_out!0 = "year" |
|
139 time_out!1 = "month" |
|
140 time_out@long_name = "current date as yyyymm" |
|
141 time_out@units = "current date as yyyymm" |
|
142 print (time_out) |
|
143 |
|
144 lat_out!0 = "lat" |
|
145 lon_out!0 = "lon" |
|
146 lat_out@units = "degrees_north" |
|
147 lat_out@long_name = "Latitude" |
|
148 lon_out@units = "degrees_east" |
|
149 lon_out@long_name = "Longitude" |
|
150 print (lat_out) |
|
151 print (lon_out) |
|
152 |
|
153 c->lat = lat_out |
|
154 c->lon = lon_out |
|
155 c->date = time_out |
|
156 c->CO2_FLUX = data_out1 |
|
157 c->RAD_FLUX = data_out2 |
|
158 c->SH_FLUX = data_out3 |
|
159 c->LH_FLUX = data_out4 |
|
160 |
|
161 end |