source: trunk/src/interp_erai_ws_1989_2009.pro @ 81

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

try (and failed) correction on climserv

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