source: trunk/src/interp_erai_ws_1989_2009.pro @ 152

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

start to homogenize (to be cont.)

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