source: trunk/src/interp_erai_dewt_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: 7.2 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; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
76;
77; use real output of :ref:`compute_erai_daily_region_2d.sh`.
78;
79; coding rules
80;
81; KNOWN ISSUES
82; ============
83;
84; test of existence of fullfilename_msk not very efficient because
85; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
86;
87; EVOLUTIONS
88; ==========
89;
90; $Id$
91;
92; $URL$
93;
94; - fplod 20110808T094156Z cratos (Linux)
95;
96;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
97;
98; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux)
99;
100;   * usage of $PROJECT_ID and $PROJECT_OD
101;
102; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
103;
104;   * remove hard coded directory for mask_oaflux_30N30S.nc
105;
106; - fplod 20101215T093710Z aedon.locean-ipsl.upmc.fr (Darwin)
107;
108;   * add graph in header
109;
110; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
111;
112;   * minimal header
113;
114; - pbk 2008
115;
116;   * creation
117;
118;-
119pro interp_erai_dewt_1989_2009
120;
121@cm_4cal
122@cm_4data
123@cm_4mesh
124@cm_4data
125@cm_project
126;
127; check for input directory
128;
129; test if ${PROJECT_ID} defined
130CASE project_id_env OF
131    ''  :  BEGIN
132     msg = 'eee : ${PROJECT_ID} is not defined'
133     ras = report(msg)
134     STOP
135           END
136 ELSE: BEGIN
137     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
138     ras = report(msg)
139       END
140ENDCASE
141;
142iodirin = isadirectory(project_id_env)
143;
144; existence and protection of ${PROJECT_ID}
145IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
146   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
147   ras = report(msg)
148   STOP
149ENDIF
150;
151; build mask filename
152filename_msk='mask_oaflux_30N30S.nc'
153;
154; check if this file exists
155fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
156IF fullfilename_msk[0] EQ '' THEN BEGIN
157   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
158   ras = report(msg)
159   STOP
160ENDIF
161;
162; build data filename
163filename='20c3m_erai_d2_TROP_1989_2009.nc'
164fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
165IF fullfilename[0] EQ '' THEN BEGIN
166   msg = 'eee : the file ' + fullfilename + ' was not found.'
167   ras = report(msg)
168   STOP
169ENDIF
170;
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_d2m_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
206domdef
207latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
208print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
209print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
210d2min=read_ncdf("d2",19881201,20101231,file=fullfilename,/nostr)
211
212timein=time & jptin=jpt
213tab=d2min(*,*,0)
214mskin=glamt*0.+1.
215
216initncdf, fullfilename_msk
217domdef
218latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
219print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
220print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
221mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
222
223help, d2min,lonin,latin,mskin,lonout,latout,mskout
224
225si=size(d2min)
226d2mout=fltarr(jpi,jpj,jptin)
227for jt=0,jptin-1 do begin
228  print, 'Interpolation jt=',jt,' / ',jptin-1
229  tab=reform(d2min(*,*,jt))
230  d2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
231      , lonout,latout,method='bilinear' $
232      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
233  d2mout(*,*,jt)=d2mout(*,*,jt)*mskout+(1.-mskout)*1.e20
234endfor
235
236
237timein=timein & jptin=jpt
238
239initncdf, fullfilename_msk
240cda0=string(jul2date(timein(0)),format='(i8.8)')
241cda1=string(jul2date(timein(jpt-1)),format='(i8.8)')
242
243time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
244cda0=string(jul2date(time(0)),format='(i8.8)')
245cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
246timein=time-julday(1,1,1950,00,00)
247
248lat=latout
249lon=lonout
250ncfile='!' + fullfilename_out
251lon_attr={units:'degrees_east',long_name:'Longitude'}
252lat_attr={units:'degrees_north',long_name:'Latitude'}
253time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
254d2m_attr={units:'degK',missing_value:1e20,long_name:'Dew Point Temperature at 2m',short_name:'d2m',axis:'TYX'}
255globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
256
257
258ncfields = 'd2m[longitude,latitude,time]=d2mout:d2m_attr; ' $
259                      + 'longitude[]=lon:lon_attr; ' $
260                      + 'latitude[]=lat:lat_attr; ' $
261                      + 'time[*time]=timein:time_attr ' $
262                      + ' @ globattr'
263
264@ncdf_quickwrite
265
266
267end
Note: See TracBrowser for help on using the repository browser.