1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _interp_erai_ws_1989_2009.pro: |
---|
4 | ; |
---|
5 | ; ============================ |
---|
6 | ; interp_erai_ws_1989_2009.pro |
---|
7 | ; ============================ |
---|
8 | ; |
---|
9 | ; DESCRIPTION |
---|
10 | ; =========== |
---|
11 | ; |
---|
12 | ; Interpolation of u10 and v10 from ERA-I grid to OAFLUX grid |
---|
13 | ; |
---|
14 | ; :file:`${PROJECT_ID}/20c3m_erai_u10_TROP_1989_2009.nc` containing u10 from ERA-I have been produced |
---|
15 | ; by :ref:`compute_erai_daily_region_2d.sh`. |
---|
16 | ; |
---|
17 | ; :file:`${PROJECT_ID}/20c3m_erai_v10_TROP_1989_2009.nc` containing u10 from ERA-I have been produced |
---|
18 | ; |
---|
19 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`. |
---|
20 | ; |
---|
21 | ; Interpolated u10 and v10 is written in |
---|
22 | ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` if this file not already exists. |
---|
23 | ; |
---|
24 | ; This output file :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`ws_correction_ncdf.pro`. |
---|
25 | ; |
---|
26 | ; .. graphviz:: |
---|
27 | ; |
---|
28 | ; digraph interp_erai_ws_1989_2009 { |
---|
29 | ; graph [ |
---|
30 | ; rankdir="LR", |
---|
31 | ; ] |
---|
32 | ; file_u10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_u10_TROP_1989_2009.nc"]; |
---|
33 | ; file_v10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_v10_TROP_1989_2009.nc"]; |
---|
34 | ; |
---|
35 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
36 | ; |
---|
37 | ; ncfile [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"]; |
---|
38 | ; |
---|
39 | ; interp_erai_ws_1989_2009 [shape=box, |
---|
40 | ; fontname=Courier, |
---|
41 | ; color=blue, |
---|
42 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_ws_1989_2009.pro", |
---|
43 | ; label="${PROJECT}/src/interp_erai_ws_1989_2009.pro"]; |
---|
44 | ; |
---|
45 | ; {file_u10 file_v10 mask} -> {interp_erai_ws_1989_2009} -> {ncfile} |
---|
46 | ; |
---|
47 | ; } |
---|
48 | ; |
---|
49 | ; SEE ALSO |
---|
50 | ; ======== |
---|
51 | ; |
---|
52 | ; :ref:`project_profile.sh` |
---|
53 | ; |
---|
54 | ; :func:`report <saxo:report>` |
---|
55 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
56 | ; :func:`isafile <saxo:isafile>` |
---|
57 | ; :func:`initncdf <saxo:initncdf>` |
---|
58 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
59 | ; :func:`domdef <saxo:domdef>` |
---|
60 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
61 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
62 | ; |
---|
63 | ; :ref:`ws_correction_ncdf.pro` |
---|
64 | ; |
---|
65 | ; EXAMPLES |
---|
66 | ; ======== |
---|
67 | ; |
---|
68 | ; :: |
---|
69 | ; |
---|
70 | ; IDL> .compile file_interp |
---|
71 | ; IDL> interp_erai_ws_1989_2009 |
---|
72 | ; |
---|
73 | ; TODO |
---|
74 | ; ==== |
---|
75 | ; |
---|
76 | ; make it work : pb on loholt1:: |
---|
77 | ; |
---|
78 | ; Variable is undefined: OUTMASK_IND. |
---|
79 | ; |
---|
80 | ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call |
---|
81 | ; |
---|
82 | ; use real output of :ref:`compute_erai_daily_region_2d.sh`. |
---|
83 | ; |
---|
84 | ; coding rules |
---|
85 | ; |
---|
86 | ; KNOWN ISSUES |
---|
87 | ; ============ |
---|
88 | ; |
---|
89 | ; test of existence of fullfilename_msk not very efficient because |
---|
90 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
91 | ; |
---|
92 | ; EVOLUTIONS |
---|
93 | ; ========== |
---|
94 | ; |
---|
95 | ; $Id$ |
---|
96 | ; |
---|
97 | ; $URL$ |
---|
98 | ; |
---|
99 | ; - fplod 20110808T094156Z cratos (Linux) |
---|
100 | ; |
---|
101 | ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call |
---|
102 | ; |
---|
103 | ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
104 | ; |
---|
105 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
106 | ; |
---|
107 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
108 | ; |
---|
109 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
110 | ; |
---|
111 | ; - fplod 20101215T112657Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
112 | ; |
---|
113 | ; * add graph in header |
---|
114 | ; |
---|
115 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
116 | ; |
---|
117 | ; * minimal header |
---|
118 | ; |
---|
119 | ; - pbk 2008 |
---|
120 | ; |
---|
121 | ; * creation |
---|
122 | ; |
---|
123 | ;- |
---|
124 | pro interp_erai_ws_1989_2009 |
---|
125 | ; |
---|
126 | @cm_4cal |
---|
127 | @cm_4data |
---|
128 | @cm_4mesh |
---|
129 | @cm_4data |
---|
130 | @cm_project |
---|
131 | ; |
---|
132 | ; check for input directory |
---|
133 | ; |
---|
134 | ; test if ${PROJECT_ID} defined |
---|
135 | CASE project_id_env OF |
---|
136 | '' : BEGIN |
---|
137 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
138 | ras = report(msg) |
---|
139 | STOP |
---|
140 | END |
---|
141 | ELSE: BEGIN |
---|
142 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
143 | ras = report(msg) |
---|
144 | END |
---|
145 | ENDCASE |
---|
146 | ; |
---|
147 | iodirin = isadirectory(project_id_env) |
---|
148 | ; |
---|
149 | ; existence and protection of ${PROJECT_ID} |
---|
150 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
151 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
152 | ras = report(msg) |
---|
153 | STOP |
---|
154 | ENDIF |
---|
155 | ; |
---|
156 | ; build mask filename |
---|
157 | filename_msk='mask_oaflux_30N30S.nc' |
---|
158 | ; |
---|
159 | ; check if this file exists |
---|
160 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
161 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
162 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
163 | ras = report(msg) |
---|
164 | STOP |
---|
165 | ENDIF |
---|
166 | ; |
---|
167 | st=19880101 & en=20100930 |
---|
168 | ; |
---|
169 | ; build u10 data filename |
---|
170 | filename='20c3m_erai_u10_TROP_1989_2009.nc' |
---|
171 | ; |
---|
172 | ; check if this file exists |
---|
173 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
174 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
175 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
176 | ras = report(msg) |
---|
177 | STOP |
---|
178 | ENDIF |
---|
179 | ; |
---|
180 | ; test if ${PROJECT_OD} defined |
---|
181 | CASE project_od_env OF |
---|
182 | '' : BEGIN |
---|
183 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
184 | ras = report(msg) |
---|
185 | STOP |
---|
186 | END |
---|
187 | ELSE: BEGIN |
---|
188 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
189 | ras = report(msg) |
---|
190 | END |
---|
191 | ENDCASE |
---|
192 | ; |
---|
193 | ; check if output data will be possible |
---|
194 | iodirout = isadirectory(project_od_env) |
---|
195 | ; |
---|
196 | ; existence and protection |
---|
197 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
198 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
199 | ras = report(msg) |
---|
200 | STOP |
---|
201 | ENDIF |
---|
202 | ; |
---|
203 | ; build output filename |
---|
204 | filename_out = 'erai_ws_19890101_20091231_oafluxgrid.nc' |
---|
205 | fullfilename_out = iodirout + filename_out |
---|
206 | ; in order to avoid unexpected overwritten |
---|
207 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
208 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
209 | ras = report(msg) |
---|
210 | STOP |
---|
211 | ENDIF |
---|
212 | ; |
---|
213 | initncdf, fullfilename |
---|
214 | u10in=read_ncdf("u10",st, en,file=fullfilename,/nostr) |
---|
215 | |
---|
216 | ; build v10 data filename |
---|
217 | filename='20c3m_erai_v10_TROP_1989_2009.nc' |
---|
218 | ; |
---|
219 | ; check if this file exists |
---|
220 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
221 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
222 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
223 | ras = report(msg) |
---|
224 | STOP |
---|
225 | ENDIF |
---|
226 | initncdf, fullfilename |
---|
227 | v10in=read_ncdf("v10",st, en,file=fullfilename,/nostr) |
---|
228 | |
---|
229 | initncdf, fullfilename |
---|
230 | domdef |
---|
231 | latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0)) |
---|
232 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
233 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
234 | |
---|
235 | timein=time & jptin=jpt |
---|
236 | tab=u10in(*,*,0) |
---|
237 | mskin=glamt*0.+1. |
---|
238 | |
---|
239 | initncdf, fullfilename_msk |
---|
240 | domdef |
---|
241 | latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0)) |
---|
242 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
243 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
244 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
245 | |
---|
246 | help, u10in, v10in,lonin,latin,mskin,lonout,latout,mskout |
---|
247 | |
---|
248 | si=size(u10in) |
---|
249 | u10out=fltarr(jpi,jpj,jptin) |
---|
250 | v10out=fltarr(jpi,jpj,jptin) |
---|
251 | |
---|
252 | for jt=0,jptin-1 do begin |
---|
253 | print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
254 | tab=reform(u10in(*,*,jt)) |
---|
255 | u10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
256 | , lonout,latout,method='bilinear' $ |
---|
257 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
258 | u10out(*,*,jt)=u10out(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
259 | |
---|
260 | tab=reform(v10in(*,*,jt)) |
---|
261 | v10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
262 | , lonout,latout,method='bilinear' $ |
---|
263 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
264 | v10out(*,*,jt)=v10out(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
265 | |
---|
266 | endfor |
---|
267 | |
---|
268 | time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) |
---|
269 | tt=time & jptin=jpt |
---|
270 | cda0=string(jul2date(tt(0)),format='(i8.8)') |
---|
271 | cda1=string(jul2date(tt(jpt-1)),format='(i8.8)') |
---|
272 | tt=tt-julday(1,1,1950,00,00,00) |
---|
273 | xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*)) |
---|
274 | |
---|
275 | initncdf, fullfilename_msk |
---|
276 | valmask=1.e20 |
---|
277 | |
---|
278 | ylat=latout |
---|
279 | xlon=lonout |
---|
280 | ncfile='!' + fullfilename_out |
---|
281 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
282 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
283 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} |
---|
284 | |
---|
285 | u10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre u wind component',short_name:'u10',axis:'TYX'} |
---|
286 | v10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre v wind component',short_name:'v10',axis:'TYX'} |
---|
287 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} |
---|
288 | globattr={source:'Tropical ocean winds obtained from ERA Interim',timerange:cda0+' - '+cda1} |
---|
289 | |
---|
290 | help, u10out,v10out,tt,xlon,ylat |
---|
291 | |
---|
292 | ncfields = 'u10[longitude,latitude,time]=u10out:u10_attr; ' $ |
---|
293 | +'v10[longitude,latitude,time]=v10out:v10_attr; ' $ |
---|
294 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
295 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
296 | + 'tt[*time]=tt:time_attr ' $ |
---|
297 | + ' @ globattr' |
---|
298 | |
---|
299 | @ncdf_quickwrite |
---|
300 | |
---|
301 | return |
---|
302 | end |
---|