source: trunk/src/interp_erai_ws_1989_2009.pro @ 70

Last change on this file since 70 was 70, checked in by pinsard, 13 years ago

fix call_interp2d call

  • Property svn:keywords set to URL
File size: 8.4 KB
Line 
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;-
124pro 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
135CASE 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
145ENDCASE
146;
147iodirin = isadirectory(project_id_env)
148;
149; existence and protection of ${PROJECT_ID}
150IF (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
154ENDIF
155;
156; build mask filename
157filename_msk='mask_oaflux_30N30S.nc'
158;
159; check if this file exists
160fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
161IF fullfilename_msk[0] EQ '' THEN BEGIN
162   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
163   ras = report(msg)
164   STOP
165ENDIF
166;
167st=19880101 & en=20100930
168;
169; build u10 data filename
170filename='20c3m_erai_u10_TROP_1989_2009.nc'
171;
172; check if this file exists
173fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
174IF fullfilename[0] EQ '' THEN BEGIN
175   msg = 'eee : the file ' + fullfilename + ' was not found.'
176   ras = report(msg)
177   STOP
178ENDIF
179;
180; test if ${PROJECT_OD} defined
181CASE 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
194iodirout = isadirectory(project_od_env)
195;
196; existence and protection
197IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
198    msg = 'eee : the directory' + iodirout  + ' was not found.'
199    ras = report(msg)
200    STOP
201ENDIF
202;
203; build output filename
204filename_out = 'erai_ws_19890101_20091231_oafluxgrid.nc'
205fullfilename_out = iodirout + filename_out
206; in order to avoid unexpected overwritten
207IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
208   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
209   ras = report(msg)
210   STOP
211ENDIF
212;
213initncdf, fullfilename
214u10in=read_ncdf("u10",st, en,file=fullfilename,/nostr)
215
216; build v10 data filename
217filename='20c3m_erai_v10_TROP_1989_2009.nc'
218;
219; check if this file exists
220fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
221IF fullfilename[0] EQ '' THEN BEGIN
222   msg = 'eee : the file ' + fullfilename + ' was not found.'
223   ras = report(msg)
224   STOP
225ENDIF
226initncdf, fullfilename
227v10in=read_ncdf("v10",st, en,file=fullfilename,/nostr)
228
229initncdf, fullfilename
230domdef
231latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
232print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
233print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
234
235timein=time & jptin=jpt
236tab=u10in(*,*,0)
237mskin=glamt*0.+1.
238
239initncdf, fullfilename_msk
240domdef
241latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
242print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
243print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
244mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
245
246help, u10in, v10in,lonin,latin,mskin,lonout,latout,mskout
247
248si=size(u10in)
249u10out=fltarr(jpi,jpj,jptin)
250v10out=fltarr(jpi,jpj,jptin)
251
252for 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
266endfor
267
268time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
269tt=time & jptin=jpt
270cda0=string(jul2date(tt(0)),format='(i8.8)')
271cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
272tt=tt-julday(1,1,1950,00,00,00)
273xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
274
275initncdf, fullfilename_msk
276valmask=1.e20
277
278ylat=latout
279xlon=lonout
280ncfile='!' + fullfilename_out
281lon_attr={units:'degrees_east',long_name:'Longitude'}
282lat_attr={units:'degrees_north',long_name:'Latitude'}
283time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
284
285u10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre u wind component',short_name:'u10',axis:'TYX'}
286v10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre v wind component',short_name:'v10',axis:'TYX'}
287time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
288globattr={source:'Tropical ocean winds obtained from ERA Interim',timerange:cda0+' - '+cda1}
289
290help, u10out,v10out,tt,xlon,ylat
291
292ncfields = '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
301return
302end
Note: See TracBrowser for help on using the repository browser.