source: trunk/src/interp_erai_ws_1989_2009.pro @ 67

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

fix for doc

File size: 8.0 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; coding rules
81;
82; KNOWN ISSUES
83; ============
84;
85; test of existence of fullfilename_msk not very efficient because
86; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
87;
88; EVOLUTIONS
89; ==========
90;
91; $Id$
92;
93; $URL$
94;
95; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux)
96;
97;   * usage of $PROJECT_ID and $PROJECT_OD
98;
99; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
100;
101;   * remove hard coded directory for mask_oaflux_30N30S.nc
102;
103; - fplod 20101215T112657Z aedon.locean-ipsl.upmc.fr (Darwin)
104;
105;   * add graph in header
106;
107; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
108;
109;   * minimal header
110;
111; - pbk 2008
112;
113;   * creation
114;
115;-
116pro interp_erai_ws_1989_2009
117;
118@cm_4cal
119@cm_4data
120@cm_4mesh
121@cm_4data
122@cm_project
123;
124; check for input directory
125;
126; test if ${PROJECT_ID} defined
127CASE project_id_env OF
128    ''  :  BEGIN
129     msg = 'eee : ${PROJECT_ID} is not defined'
130     ras = report(msg)
131     STOP
132           END
133 ELSE: BEGIN
134     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
135     ras = report(msg)
136       END
137ENDCASE
138;
139iodirin = isadirectory(project_id_env)
140;
141; existence and protection of ${PROJECT_ID}
142IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
143   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
144   ras = report(msg)
145   STOP
146ENDIF
147;
148; build mask filename
149filename_msk='mask_oaflux_30N30S.nc'
150;
151; check if this file exists
152fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
153IF fullfilename_msk[0] EQ '' THEN BEGIN
154   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
155   ras = report(msg)
156   STOP
157ENDIF
158;
159st=19880101 & en=20100930
160;
161; build u10 data filename
162filename='20c3m_erai_u10_TROP_1989_2009.nc'
163;
164; check if this file exists
165fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
166IF fullfilename[0] EQ '' THEN BEGIN
167   msg = 'eee : the file ' + fullfilename + ' was not found.'
168   ras = report(msg)
169   STOP
170ENDIF
171;
172; test if ${PROJECT_OD} defined
173CASE project_od_env OF
174  '' : BEGIN
175         msg = 'eee : ${PROJECT_OD} is not defined'
176         ras = report(msg)
177       STOP
178       END
179  ELSE: BEGIN
180          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
181          ras = report(msg)
182        END
183 ENDCASE
184;
185; check if output data will be possible
186iodirout = isadirectory(project_od_env)
187;
188; existence and protection
189IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
190    msg = 'eee : the directory' + iodirout  + ' was not found.'
191    ras = report(msg)
192    STOP
193ENDIF
194;
195; build output filename
196filename_out = 'erai_ws_19890101_20091231_oafluxgrid.nc'
197fullfilename_out = iodirout + filename_out
198; in order to avoid unexpected overwritten
199IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
200   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
201   ras = report(msg)
202   STOP
203ENDIF
204;
205initncdf, fullfilename
206u10in=read_ncdf("u10",st, en,file=fullfilename,/nostr)
207
208; build v10 data filename
209filename='20c3m_erai_v10_TROP_1989_2009.nc'
210;
211; check if this file exists
212fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
213IF fullfilename[0] EQ '' THEN BEGIN
214   msg = 'eee : the file ' + fullfilename + ' was not found.'
215   ras = report(msg)
216   STOP
217ENDIF
218initncdf, fullfilename
219v10in=read_ncdf("v10",st, en,file=fullfilename,/nostr)
220
221initncdf, fullfilename
222domdef
223latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
224print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
225print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
226
227timein=time & jptin=jpt
228tab=u10in(*,*,0)
229mskin=glamt*0.+1.
230
231initncdf, fullfilename_msk
232domdef
233latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
234print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
235print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
236mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
237
238help, u10in, v10in,lonin,latin,mskin,lonout,latout,mskout
239
240si=size(u10in)
241u10out=fltarr(jpi,jpj,jptin)
242v10out=fltarr(jpi,jpj,jptin)
243
244for jt=0,jptin-1 do begin
245  print, 'Interpolation jt=',jt,' / ',jptin-1
246  tab=reform(u10in(*,*,jt))
247  u10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
248  u10out(*,*,jt)=u10out(*,*,jt)*mskout+(1.-mskout)*1.e20
249
250  tab=reform(v10in(*,*,jt))
251  v10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
252  v10out(*,*,jt)=v10out(*,*,jt)*mskout+(1.-mskout)*1.e20
253
254endfor
255
256time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
257tt=time & jptin=jpt
258cda0=string(jul2date(tt(0)),format='(i8.8)')
259cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
260tt=tt-julday(1,1,1950,00,00,00)
261xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
262
263initncdf, fullfilename_msk
264valmask=1.e20
265
266ylat=latout
267xlon=lonout
268ncfile='!' + fullfilename_out
269lon_attr={units:'degrees_east',long_name:'Longitude'}
270lat_attr={units:'degrees_north',long_name:'Latitude'}
271time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
272
273u10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre u wind component',short_name:'u10',axis:'TYX'}
274v10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre v wind component',short_name:'v10',axis:'TYX'}
275time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
276globattr={source:'Tropical ocean winds obtained from ERA Interim',timerange:cda0+' - '+cda1}
277
278help, u10out,v10out,tt,xlon,ylat
279
280ncfields = 'u10[longitude,latitude,time]=u10out:u10_attr; ' $
281          +'v10[longitude,latitude,time]=v10out:v10_attr; ' $
282                      + 'longitude[]=xlon:lon_attr; ' $
283                      + 'latitude[]=ylat:lat_attr; ' $
284                      + 'tt[*time]=tt:time_attr ' $
285                      + ' @ globattr'
286
287@ncdf_quickwrite
288
289return
290end
Note: See TracBrowser for help on using the repository browser.