source: trunk/src/interp_erai_dewt_1989_2009.pro @ 66

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

no more hard coded path in iterp_erai*.pro

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