source: trunk/src/interp_erai_dewt_1989_2009.pro @ 71

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

try to interp ERA-I on climserv (not ok yet); minimize diffreneces between sources

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