1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _read_variables_v2.pro: |
---|
4 | ; |
---|
5 | ; ===================== |
---|
6 | ; read_variables_v2.pro |
---|
7 | ; ===================== |
---|
8 | ; |
---|
9 | ; DESCRIPTION |
---|
10 | ; =========== |
---|
11 | ; |
---|
12 | ; .. graphviz:: |
---|
13 | ; |
---|
14 | ; digraph read_variables_v2 { |
---|
15 | ; |
---|
16 | ; rad [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/rad*_dy.cdf"]; |
---|
17 | ; qlat[shape=ellipse,fontname=Courier,label="${PROJECT_ID}/qlat*_dy.cdf"]; |
---|
18 | ; pos[shape=ellipse,fontname=Courier,label="${PROJECT_ID}/pos*_dy.cdf"]; |
---|
19 | ; met[shape=ellipse,fontname=Courier,label="${PROJECT_ID}/met*_dy.cdf"]; |
---|
20 | ; |
---|
21 | ; at [shape=tab,fontname=Courier,label="at"] |
---|
22 | ; sw [shape=tab,fontname=Courier,label="sw"] |
---|
23 | ; rh [shape=tab,fontname=Courier,label="rh"] |
---|
24 | ; sst [shape=tab,fontname=Courier,label="sst"] |
---|
25 | ; wu [shape=tab,fontname=Courier,label="wu"] |
---|
26 | ; wv [shape=tab,fontname=Courier,label="wv"] |
---|
27 | ; ws [shape=tab,fontname=Courier,label="ws"] |
---|
28 | ; lh [shape=tab,fontname=Courier,label="lh"] |
---|
29 | ; |
---|
30 | ; read_variables_v2 [shape=box, |
---|
31 | ; fontname=Courier, |
---|
32 | ; color=blue, |
---|
33 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/paper01/fig2/read_variables_v2.pro", |
---|
34 | ; label="${TROPFLUX}/src/paper01/fig2/read_variables_v2.pro"]; |
---|
35 | ; |
---|
36 | ; {qlat rad pos met} -> {read_variables_v2} -> {at sw rh sst wu wv ws lh} |
---|
37 | ; } |
---|
38 | ; |
---|
39 | ; SEE ALSO |
---|
40 | ; ======== |
---|
41 | ; |
---|
42 | ; :ref:`project_profile.sh` |
---|
43 | ; |
---|
44 | ; :ref:`air_validation_scatter_2000_2009_v50.pro` |
---|
45 | ; :ref:`q2m_validation_scatter_2000_2009_v50.pro` |
---|
46 | ; :ref:`sst_validation_scatter_2000_2009_v50.pro` |
---|
47 | ; :ref:`ws_validation_scatter_2000_2009_v50.pro` |
---|
48 | ; :ref:`air_validation_scatter_2000_2009_basin.pro` |
---|
49 | ; :ref:`q2m_validation_scatter_2000_2009_basin.pro` |
---|
50 | ; :ref:`sst_validation_scatter_2000_2009_basin.pro` |
---|
51 | ; :ref:`ws_validation_scatter_2000_2009_basin.pro` |
---|
52 | ; :ref:`lhf_validation_scatter_2000_2009.pro` |
---|
53 | ; :ref:`shf_validation_scatter_2000_2009.pro` |
---|
54 | ; |
---|
55 | ; EXAMPLES |
---|
56 | ; ======== |
---|
57 | ; |
---|
58 | ; :: |
---|
59 | ; |
---|
60 | ; csite = ++ |
---|
61 | ; ++ |
---|
62 | ; read_variables_v2, csite, date1, date2, nsmooth, at, sw, rh, sst, wu, wv, ws, lh |
---|
63 | ; |
---|
64 | ; TODO |
---|
65 | ; ==== |
---|
66 | ; |
---|
67 | ; make it work (missing data) |
---|
68 | ; |
---|
69 | ; EVOLUTIONS |
---|
70 | ; ========== |
---|
71 | ; |
---|
72 | ; $Id$ |
---|
73 | ; |
---|
74 | ; $URL$ |
---|
75 | ; |
---|
76 | ; - fplod 20110830T140518Z cratos (Linux) |
---|
77 | ; |
---|
78 | ; * remove function time_lec (already externalized) |
---|
79 | ; |
---|
80 | ; - fplod 20110412T110534Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
81 | ; |
---|
82 | ; * remove hard coding path |
---|
83 | ; * add graphviz |
---|
84 | ; |
---|
85 | ; - fplod 20110411T142955Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
86 | ; |
---|
87 | ; * minimal header |
---|
88 | ; |
---|
89 | ;- |
---|
90 | pro read_variables_v2, csite, date1, date2, nsmooth, $ |
---|
91 | at, sw, rh, sst, wu, wv, ws, lh |
---|
92 | @cm_project |
---|
93 | ; |
---|
94 | ; DEFINE THE OUTPUT TIME AXIS |
---|
95 | ; |
---|
96 | jda1=date2jul(date1) |
---|
97 | jda2=date2jul(date2) |
---|
98 | jpt=(jda2-jda1+1l) |
---|
99 | time=jda1+dindgen(jpt) |
---|
100 | ; |
---|
101 | ; FIRST READ ALL DATA FROM SITE |
---|
102 | ; - if file exists, extract correct time axis |
---|
103 | ; - if not, fill variable with missing values |
---|
104 | ; |
---|
105 | ;SHORTWAVE |
---|
106 | fi=project_id_env+'rad'+csite+'_dy.cdf' |
---|
107 | f=file_test(fi) |
---|
108 | sw=fltarr(jpt)+!values.f_nan |
---|
109 | sw_q=fltarr(jpt)+!values.f_nan |
---|
110 | ;tt=fltarr(jpt)+!values.f_nan |
---|
111 | if (f) then begin |
---|
112 | tt0=time_lec(fi) |
---|
113 | sw0=ncdf_lec(fi,var='RD_495') |
---|
114 | sw_q0=ncdf_lec(fi,var='QSW_5495') |
---|
115 | tt0=tt0-time(0) |
---|
116 | ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) |
---|
117 | if (ind(0) ne -1) then begin |
---|
118 | sw(tt0(ind))=sw0(ind) |
---|
119 | sw_q(tt0(ind))=sw_q0(ind) |
---|
120 | endif |
---|
121 | endif else begin |
---|
122 | print, fi, ' not found' |
---|
123 | endelse |
---|
124 | ; |
---|
125 | ind_sw=where(sw_q ne 1. and sw_q ne 2.) |
---|
126 | ; |
---|
127 | ;LHF |
---|
128 | fi=project_id_env+'qlat'+csite+'_dy.cdf' |
---|
129 | f=file_test(fi) |
---|
130 | lh=fltarr(jpt)+!values.f_nan |
---|
131 | lh_q=fltarr(jpt)+!values.f_nan |
---|
132 | if (f) then begin |
---|
133 | tt0=time_lec(fi) |
---|
134 | lh0=ncdf_lec(fi,var='QL_137') |
---|
135 | lh_q0=ncdf_lec(fi,var='QQL_5137') |
---|
136 | tt0=tt0-time(0) |
---|
137 | ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) |
---|
138 | if (ind(0) ne -1) then begin |
---|
139 | lh(tt0(ind))=lh0(ind) |
---|
140 | lh_q(tt0(ind))=lh_q0(ind) |
---|
141 | endif |
---|
142 | endif else begin |
---|
143 | print, fi, ' not found' |
---|
144 | endelse |
---|
145 | ; |
---|
146 | ;POSITION |
---|
147 | fi=project_id_env+'pos'+csite+'_dy.cdf' |
---|
148 | f=file_test(fi) |
---|
149 | lat=fltarr(jpt)+!values.f_nan |
---|
150 | lon=fltarr(jpt)+!values.f_nan |
---|
151 | if (f) then begin |
---|
152 | tt0=time_lec(fi) |
---|
153 | lat0=ncdf_lec(fi,var='LAT_500') |
---|
154 | lon0=ncdf_lec(fi,var='LON_502') |
---|
155 | tt0=tt0-time(0) |
---|
156 | ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) |
---|
157 | if (ind(0) ne -1) then begin |
---|
158 | lat(tt0(ind))=lat0(ind) |
---|
159 | lon(tt0(ind))=lon0(ind) |
---|
160 | endif |
---|
161 | endif else begin |
---|
162 | print, fi, ' not found' |
---|
163 | endelse |
---|
164 | ; |
---|
165 | ;MET PARAMETERS |
---|
166 | fi=project_id_env+'met'+csite+'_dy.cdf' |
---|
167 | f=file_test(fi) |
---|
168 | wu=fltarr(jpt)+!values.f_nan |
---|
169 | wv=fltarr(jpt)+!values.f_nan |
---|
170 | ws=fltarr(jpt)+!values.f_nan |
---|
171 | ws_q=fltarr(jpt)+!values.f_nan |
---|
172 | at=fltarr(jpt)+!values.f_nan |
---|
173 | at_q=fltarr(jpt)+!values.f_nan |
---|
174 | rh=fltarr(jpt)+!values.f_nan |
---|
175 | rh_q=fltarr(jpt)+!values.f_nan |
---|
176 | sst=fltarr(jpt)+!values.f_nan |
---|
177 | sst_q=fltarr(jpt)+!values.f_nan |
---|
178 | ; |
---|
179 | if (f) then begin |
---|
180 | tt0=time_lec(fi) |
---|
181 | wu0=ncdf_lec(fi,var='WU_422') |
---|
182 | wv0=ncdf_lec(fi,var='WV_423') |
---|
183 | ws0=ncdf_lec(fi,var='WS_401') |
---|
184 | ws_q0=ncdf_lec(fi,var='QWS_5401') |
---|
185 | at0=ncdf_lec(fi,var='AT_21') |
---|
186 | at_q0=ncdf_lec(fi,var='QAT_5021') |
---|
187 | rh0=ncdf_lec(fi,var='RH_910') |
---|
188 | rh_q0=ncdf_lec(fi,var='QRH_5910') |
---|
189 | sst0=ncdf_lec(fi,var='T_25') |
---|
190 | sst_q0=ncdf_lec(fi,var='QT_5025') |
---|
191 | tt0=tt0-time(0) |
---|
192 | ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) |
---|
193 | if (ind(0) ne -1) then begin |
---|
194 | wu(tt0(ind))=wu0(ind) |
---|
195 | wv(tt0(ind))=wv0(ind) |
---|
196 | ws(tt0(ind))=ws0(ind) |
---|
197 | ws_q(tt0(ind))=ws_q0(ind) |
---|
198 | at(tt0(ind))=at0(ind) |
---|
199 | at_q(tt0(ind))=at_q0(ind) |
---|
200 | rh(tt0(ind))=rh0(ind) |
---|
201 | rh_q(tt0(ind))=rh_q0(ind) |
---|
202 | sst(tt0(ind))=sst0(ind) |
---|
203 | sst_q(tt0(ind))=sst_q0(ind) |
---|
204 | endif |
---|
205 | endif else begin |
---|
206 | print, fi, ' not found' |
---|
207 | endelse |
---|
208 | ; |
---|
209 | ind_at=where(at_q ne 1 and at_q ne 2) |
---|
210 | ind_ws=where(ws_q ne 1 and ws_q ne 2) |
---|
211 | ind_rh=where(rh_q ne 1 and rh_q ne 2) |
---|
212 | ind_sst=where(sst_q ne 1 and sst_q ne 2) |
---|
213 | ind_lh=where(lh_q ne 1 and lh_q ne 2) |
---|
214 | ; |
---|
215 | ind=union(ind_at, union(ind_rh, union(ind_ws, union(ind_lh, ind_sst)))) |
---|
216 | ; |
---|
217 | if (ind(0) ne -1) then begin |
---|
218 | sw(ind)=!Values.f_nan |
---|
219 | at(ind)=!Values.f_nan |
---|
220 | rh(ind)=!Values.f_nan |
---|
221 | ws(ind)=!Values.f_nan |
---|
222 | sst(ind)=!Values.f_nan |
---|
223 | lh(ind)=!Values.f_nan |
---|
224 | wu(ind)=!Values.f_nan |
---|
225 | wv(ind)=!Values.f_nan |
---|
226 | endif |
---|
227 | ; |
---|
228 | ; Replace missing values by "NaN" |
---|
229 | ; |
---|
230 | tsvars=['at','sw','rh','sst','wu','wv','ws','lat','lon'] |
---|
231 | vars=[tsvars] |
---|
232 | nn=n_elements(vars) |
---|
233 | for n=0,nn-1 do begin |
---|
234 | var=vars(n) |
---|
235 | com='ind=where('+var+' ge 1.e20) |
---|
236 | if (ind(0) ne -1) then '+var+'(ind)=!values.f_nan' |
---|
237 | r=execute(com) |
---|
238 | endfor |
---|
239 | ; |
---|
240 | nsmooth=nsmooth |
---|
241 | at=smooth(at,nsmooth,/nan) |
---|
242 | sst=smooth(sst,nsmooth,/nan) |
---|
243 | lh=smooth(lh,nsmooth,/nan) |
---|
244 | rh=smooth(rh,nsmooth,/nan) |
---|
245 | wu=smooth(wu,nsmooth,/nan) |
---|
246 | wv=smooth(wv,nsmooth,/nan) |
---|
247 | ws=smooth(ws,nsmooth,/nan) |
---|
248 | sw=smooth(sw,nsmooth,/nan) |
---|
249 | ; |
---|
250 | end |
---|