1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _read_sw.pro: |
---|
4 | ; |
---|
5 | ; =========== |
---|
6 | ; read_sw.pro |
---|
7 | ; =========== |
---|
8 | ; |
---|
9 | ; DESCRIPTION |
---|
10 | ; =========== |
---|
11 | ; |
---|
12 | ; .. graphviz:: |
---|
13 | ; |
---|
14 | ; digraph read_sw { |
---|
15 | ; |
---|
16 | ; swnet [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/swnet*_dy.cdf"]; |
---|
17 | ; sw [shape=tab,fontname=Courier,label="sw"] |
---|
18 | ; |
---|
19 | ; read_sw [shape=box, |
---|
20 | ; fontname=Courier, |
---|
21 | ; color=blue, |
---|
22 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/paper01/fig2/read_sw.pro", |
---|
23 | ; label="${TROPFLUX}/src/paper01/fig2/read_sw.pro"]; |
---|
24 | ; |
---|
25 | ; {swnet} -> {read_sw} -> {sw} |
---|
26 | ; } |
---|
27 | ; |
---|
28 | ; SEE ALSO |
---|
29 | ; ======== |
---|
30 | ; |
---|
31 | ; :ref:`project_profile.sh` |
---|
32 | ; |
---|
33 | ; :func:`time_lec` |
---|
34 | ; |
---|
35 | ; :ref:`fig2_timeline_diagram.pro` |
---|
36 | ; |
---|
37 | ; EXAMPLES |
---|
38 | ; ======== |
---|
39 | ; |
---|
40 | ; :: |
---|
41 | ; |
---|
42 | ; IDL> csite='8s67e' |
---|
43 | ; IDL> date1=19890101L |
---|
44 | ; IDL> date2=20091231L |
---|
45 | ; IDL> box=++ |
---|
46 | ; IDL> read_sw, csite, date1, date2, box, sw |
---|
47 | ; |
---|
48 | ; TODO |
---|
49 | ; ==== |
---|
50 | ; |
---|
51 | ; make it work with a file : missing input file |
---|
52 | ; |
---|
53 | ; EVOLUTIONS |
---|
54 | ; ========== |
---|
55 | ; |
---|
56 | ; $Id$ |
---|
57 | ; |
---|
58 | ; $URL$ |
---|
59 | ; |
---|
60 | ; - pinsard 2011-04-20T15:15:12Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
61 | ; |
---|
62 | ; * typo |
---|
63 | ; |
---|
64 | ; - fplod 20110412T093325Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
65 | ; |
---|
66 | ; * externalize function |
---|
67 | ; * remove hard coding path |
---|
68 | ; * add graphviz |
---|
69 | ; * remove smooth call (unreacheable statement after end !!) |
---|
70 | ; |
---|
71 | ; - fplod 20110411T142955Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
72 | ; |
---|
73 | ; * minimal header |
---|
74 | ; |
---|
75 | ;- |
---|
76 | pro read_sw, csite, date1, date2, box, sw |
---|
77 | ; |
---|
78 | @cm_project |
---|
79 | ; |
---|
80 | ; DEFINE THE OUTPUT TIME AXIS |
---|
81 | ; |
---|
82 | jda1=date2jul(date1) |
---|
83 | jda2=date2jul(date2) |
---|
84 | jpt=(jda2-jda1+1l) |
---|
85 | time=jda1+dindgen(jpt) |
---|
86 | ; |
---|
87 | ; FIRST READ ALL DATA FROM SITE |
---|
88 | ; - if file exists, extract correct time axis |
---|
89 | ; - if not, fill variable with missing values |
---|
90 | ; |
---|
91 | ; SWR |
---|
92 | fi=project_id_env+'swnet'+csite+'_dy.cdf' |
---|
93 | f=file_test(fi) |
---|
94 | sw=fltarr(jpt)+!values.f_nan ; swr |
---|
95 | sw_q=fltarr(jpt)+!values.f_nan ; swr quality flag |
---|
96 | ; |
---|
97 | if (f) then begin |
---|
98 | tt0=time_lec(fi) |
---|
99 | sw0=ncdf_lec(fi,var='SWN_1495') |
---|
100 | sw_q0=ncdf_lec(fi,var='QSW_5495') |
---|
101 | tt0=tt0-time(0) |
---|
102 | ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) |
---|
103 | if (ind(0) ne -1) then begin |
---|
104 | sw(tt0(ind))=sw0(ind) |
---|
105 | sw_q(tt0(ind))=sw_q0(ind) |
---|
106 | endif |
---|
107 | endif else begin |
---|
108 | print, fi, ' not found' |
---|
109 | endelse |
---|
110 | ; |
---|
111 | ind1=where((sw_q ne 1) and (sw_q ne 2)) |
---|
112 | sw(ind1)=!Values.f_nan |
---|
113 | ; |
---|
114 | ; Replace missing values by "NaN" |
---|
115 | ; |
---|
116 | ;tsvars=['at','bf','bp','dyn','emp','evap','heat','iso','sw','swnet','qlat','qsen','sw', $ |
---|
117 | ; 'swnet','rain','rf','rh','ssd','sss','sst','swnet','tx','ty','wu','wv','ws','lat','lon'] |
---|
118 | ;depvars=['u','v','d','t','s'] |
---|
119 | vars=['sw'] |
---|
120 | ; |
---|
121 | nn=n_elements(vars) |
---|
122 | for n=0,nn-1 do begin |
---|
123 | var=vars(n) |
---|
124 | com='ind=where('+var+' ge 1.e20) |
---|
125 | if (ind(0) ne -1) then '+var+'(ind)=!values.f_nan' |
---|
126 | r=execute(com) |
---|
127 | endfor |
---|
128 | ; |
---|
129 | end |
---|