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