source: trunk/src/paper01/fig3/read_variables_v2.pro @ 182

Last change on this file since 182 was 182, checked in by pinsard, 12 years ago

fix some svn propset

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 6.2 KB
Line 
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;-
90pro 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;
96jda1=date2jul(date1)
97jda2=date2jul(date2)
98jpt=(jda2-jda1+1l)
99time=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
106fi=project_id_env+'rad'+csite+'_dy.cdf'
107f=file_test(fi)
108sw=fltarr(jpt)+!values.f_nan
109sw_q=fltarr(jpt)+!values.f_nan
110;tt=fltarr(jpt)+!values.f_nan
111if (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
121endif else begin
122  print, fi, ' not found'
123endelse
124;
125ind_sw=where(sw_q ne 1. and sw_q ne 2.)
126;
127;LHF
128fi=project_id_env+'qlat'+csite+'_dy.cdf'
129f=file_test(fi)
130lh=fltarr(jpt)+!values.f_nan
131lh_q=fltarr(jpt)+!values.f_nan
132if (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
142endif else begin
143  print, fi, ' not found'
144endelse
145;
146;POSITION
147fi=project_id_env+'pos'+csite+'_dy.cdf'
148f=file_test(fi)
149lat=fltarr(jpt)+!values.f_nan
150lon=fltarr(jpt)+!values.f_nan
151if (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
161endif else begin
162  print, fi, ' not found'
163endelse
164;
165;MET PARAMETERS
166fi=project_id_env+'met'+csite+'_dy.cdf'
167f=file_test(fi)
168wu=fltarr(jpt)+!values.f_nan
169wv=fltarr(jpt)+!values.f_nan
170ws=fltarr(jpt)+!values.f_nan
171ws_q=fltarr(jpt)+!values.f_nan
172at=fltarr(jpt)+!values.f_nan
173at_q=fltarr(jpt)+!values.f_nan
174rh=fltarr(jpt)+!values.f_nan
175rh_q=fltarr(jpt)+!values.f_nan
176sst=fltarr(jpt)+!values.f_nan
177sst_q=fltarr(jpt)+!values.f_nan
178;
179if (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
205endif else begin
206  print, fi, ' not found'
207endelse
208;
209ind_at=where(at_q ne 1 and at_q ne 2)
210ind_ws=where(ws_q ne 1 and ws_q ne 2)
211ind_rh=where(rh_q ne 1 and rh_q ne 2)
212ind_sst=where(sst_q ne 1 and sst_q ne 2)
213ind_lh=where(lh_q ne 1 and lh_q ne 2)
214;
215ind=union(ind_at, union(ind_rh, union(ind_ws, union(ind_lh, ind_sst))))
216;
217if (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
226endif
227;
228; Replace missing values by "NaN"
229;
230tsvars=['at','sw','rh','sst','wu','wv','ws','lat','lon']
231vars=[tsvars]
232nn=n_elements(vars)
233for 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)
238endfor
239;
240nsmooth=nsmooth
241at=smooth(at,nsmooth,/nan)
242sst=smooth(sst,nsmooth,/nan)
243lh=smooth(lh,nsmooth,/nan)
244rh=smooth(rh,nsmooth,/nan)
245wu=smooth(wu,nsmooth,/nan)
246wv=smooth(wv,nsmooth,/nan)
247ws=smooth(ws,nsmooth,/nan)
248sw=smooth(sw,nsmooth,/nan)
249;
250end
Note: See TracBrowser for help on using the repository browser.