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