1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _ws_correction_ncdf.pro: |
---|
4 | ; |
---|
5 | ; ====================== |
---|
6 | ; ws_correction_ncdf.pro |
---|
7 | ; ====================== |
---|
8 | ; |
---|
9 | ; Correction of ws on OAFLUX grid |
---|
10 | ; |
---|
11 | ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` |
---|
12 | ; containing |
---|
13 | ; ++ |
---|
14 | ; have been produced by |
---|
15 | ; :ref:`interp_erai_ws_1989_2009.pro`. |
---|
16 | ; |
---|
17 | ; Corrected ws on OAFLUX grid |
---|
18 | ; is written in |
---|
19 | ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` |
---|
20 | ; if this file not already exists. |
---|
21 | ; |
---|
22 | ; This output file |
---|
23 | ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` |
---|
24 | ; will be used by |
---|
25 | ; :ref:`TropFlux_19890101_20091231.pro`. |
---|
26 | ; |
---|
27 | ; .. only:: man |
---|
28 | ; |
---|
29 | ; Figure is visible on PDF and HTML documents only. |
---|
30 | ; |
---|
31 | ; .. only:: html or latex |
---|
32 | ; |
---|
33 | ; .. graphviz:: |
---|
34 | ; |
---|
35 | ; digraph ws_correction_ncdf { |
---|
36 | ; |
---|
37 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"]; |
---|
38 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"]; |
---|
39 | ; |
---|
40 | ; ws_correction_ncdf [shape=box, |
---|
41 | ; fontname=Courier, |
---|
42 | ; color=blue, |
---|
43 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_correction_ncdf.pro", |
---|
44 | ; label="${PROJECT}/src/ws_correction_ncdf.pro"]; |
---|
45 | ; |
---|
46 | ; {file_in} -> {ws_correction_ncdf} -> {file_out} |
---|
47 | ; |
---|
48 | ; } |
---|
49 | ; |
---|
50 | ; SEE ALSO |
---|
51 | ; ======== |
---|
52 | ; |
---|
53 | ; :ref:`project_profile.sh` |
---|
54 | ; |
---|
55 | ; :ref:`mooring_corrections` |
---|
56 | ; |
---|
57 | ; :ref:`interp_erai_vs_1989_2009.pro` |
---|
58 | ; |
---|
59 | ; :func:`initncdf <saxo:initncdf>` |
---|
60 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
61 | ; :func:`grossemoyenne <saxo:grossemoyenne>` |
---|
62 | ; :func:`julday <saxo:julday>` |
---|
63 | ; :func:`caldat <saxo:caldat>` |
---|
64 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
65 | ; |
---|
66 | ; EXAMPLES |
---|
67 | ; ======== |
---|
68 | ; |
---|
69 | ; :: |
---|
70 | ; |
---|
71 | ; IDL> ws_correction_ncdf |
---|
72 | ; |
---|
73 | ; TODO |
---|
74 | ; ==== |
---|
75 | ; |
---|
76 | ; coding rules |
---|
77 | ; |
---|
78 | ; hard coded correction |
---|
79 | ; |
---|
80 | ; KNOWN ISSUES |
---|
81 | ; ============ |
---|
82 | ; |
---|
83 | ; test of existence of fullfilename_in not very efficient because |
---|
84 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
85 | ; |
---|
86 | ; EVOLUTIONS |
---|
87 | ; ========== |
---|
88 | ; |
---|
89 | ; $Id: ws_correction_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
90 | ; |
---|
91 | ; $URL$ |
---|
92 | ; |
---|
93 | ; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
94 | ; |
---|
95 | ; * usage of ${PROJECT_OD} |
---|
96 | ; * complete description |
---|
97 | ; * remove v20 in output filename |
---|
98 | ; |
---|
99 | ; - fplod 20101215T115916Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
100 | ; |
---|
101 | ; * add graph in header |
---|
102 | ; |
---|
103 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
104 | ; |
---|
105 | ; * minimal header |
---|
106 | ; |
---|
107 | ; - pbk 2008 |
---|
108 | ; |
---|
109 | ; * creation |
---|
110 | ; |
---|
111 | ;- |
---|
112 | pro ws_correction_ncdf |
---|
113 | ; |
---|
114 | @cm_4cal |
---|
115 | @cm_4data |
---|
116 | @cm_4mesh |
---|
117 | @cm_4data |
---|
118 | @cm_project |
---|
119 | ; |
---|
120 | ; test if ${PROJECT_OD} defined |
---|
121 | CASE project_od_env OF |
---|
122 | '' : BEGIN |
---|
123 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
124 | ras = report(msg) |
---|
125 | STOP |
---|
126 | END |
---|
127 | ELSE: BEGIN |
---|
128 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
129 | ras = report(msg) |
---|
130 | END |
---|
131 | ENDCASE |
---|
132 | ; |
---|
133 | ; check if output data will be possible |
---|
134 | iodirout = isadirectory(project_od_env) |
---|
135 | ; |
---|
136 | ; existence and protection for reading |
---|
137 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
138 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
139 | ras = report(msg) |
---|
140 | STOP |
---|
141 | ENDIF |
---|
142 | ; |
---|
143 | ; existence and protection for writing |
---|
144 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
145 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
146 | ras = report(msg) |
---|
147 | STOP |
---|
148 | ENDIF |
---|
149 | ; |
---|
150 | da1=19880101 |
---|
151 | da2=20101231 |
---|
152 | ; |
---|
153 | ; build data filename |
---|
154 | filename='erai_ws_19890101_20091231_oafluxgrid.nc' |
---|
155 | ; |
---|
156 | ; check if this file exists |
---|
157 | msg='iii : looking for ' + filename |
---|
158 | ras = report(msg) |
---|
159 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
160 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
161 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
162 | ras = report(msg) |
---|
163 | STOP |
---|
164 | ENDIF |
---|
165 | ; |
---|
166 | ; build output filename |
---|
167 | filename_out = 'TropFlux_ws_19890101_20091231.nc' |
---|
168 | fullfilename_out = iodirout + filename_out |
---|
169 | ; in order to avoid unexpected overwritten |
---|
170 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
171 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
172 | ras = report(msg) |
---|
173 | STOP |
---|
174 | ENDIF |
---|
175 | ; |
---|
176 | initncdf, fullfilename |
---|
177 | u=read_ncdf('u10',da1,da2,file=fullfilename,/nostr) |
---|
178 | v=read_ncdf('v10',da1,da2,file=fullfilename,/nostr) |
---|
179 | w=sqrt(u*u+v*v) |
---|
180 | ; |
---|
181 | help, w |
---|
182 | ; |
---|
183 | w_mean=grossemoyenne(w,'t',/nan) |
---|
184 | help, w_mean |
---|
185 | ; |
---|
186 | jpt=n_elements(time) |
---|
187 | caldat, time,mon,day,yea |
---|
188 | w_m=w*0. |
---|
189 | ; |
---|
190 | for jt=0,jpt-1 do begin |
---|
191 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
192 | q=reform(w_mean(*,*)) |
---|
193 | w_m(*,*,jt)=q |
---|
194 | endfor |
---|
195 | help, w_m |
---|
196 | ; |
---|
197 | w_ano=w-w_m |
---|
198 | ; |
---|
199 | ; correction for mean based on scatter |
---|
200 | ;w_m=w_m+0.282667 ; (2000-2008) |
---|
201 | w_m=w_m+0.276739 ; (2000-2009) |
---|
202 | ; |
---|
203 | help, w_ano |
---|
204 | ; |
---|
205 | ; applying the correction for varyability based on the scatter |
---|
206 | ;w_ano=w_ano*(1/0.897667) ; (2000-2008) |
---|
207 | w_ano=w_ano*(1/0.903587) ; (2000-2009) |
---|
208 | ; |
---|
209 | w_new=w_m+w_ano |
---|
210 | help, w_new |
---|
211 | ; |
---|
212 | ;writing field |
---|
213 | lat=reform(gphit(0,0:jpj-1)) |
---|
214 | lon=reform(glamt(0:jpi-1,0)) |
---|
215 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
216 | jpt=n_elements(time) |
---|
217 | ; |
---|
218 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
219 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
220 | ; |
---|
221 | time=time-julday(1,1,1950) |
---|
222 | jpt=n_elements(time) |
---|
223 | ; |
---|
224 | ncfile='!' + fullfilename_out |
---|
225 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
226 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
227 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
228 | globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1} |
---|
229 | w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'} |
---|
230 | ; |
---|
231 | ncfields = 'ws[longitude,latitude,time]=w_new:w_attr; ' $ |
---|
232 | + 'longitude[]=lon:lon_attr; ' $ |
---|
233 | + 'latitude[]=lat:lat_attr; ' $ |
---|
234 | + 'time[*time]=time:time_attr ' $ |
---|
235 | + ' @ globattr' |
---|
236 | ; |
---|
237 | @ncdf_quickwrite |
---|
238 | ; |
---|
239 | end |
---|