source: trunk/src/interp_erai_msl_1989_2009.pro @ 81

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

progress on humidity processing

File size: 7.4 KB
Line 
1;+
2;
3; .. _interp_erai_msl_1989_2009.pro:
4;
5; =============================
6; interp_erai_msl_1989_2009.pro
7; =============================
8;
9; DESCRIPTION
10; ===========
11;
12; Interpolation of msl from ERA-I grid to OAFLUX grid
13;
14; :file:`${PROJECT_ID}/20c3m_erai_msl_TROP_1989_2009.nc` containing msl 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 msl is written in
20; :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` if this file not already exists.
21;
22; This output file :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`d2m_to_q2m_erai.pro`.
23;
24;
25;     .. graphviz::
26;
27;        digraph interp_erai_msl_1989_2009 {
28;           graph [
29;           rankdir="LR",
30;           ]
31;
32;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_msl_TROP_1989_2009.nc"];
33;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
34;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc"];
35;
36;           interp_erai_msl_1989_2009 [shape=box,
37;           fontname=Courier,
38;           color=blue,
39;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_msl_1989_2009.pro",
40;           label="${PROJECT}/src/interp_erai_msl_1989_2009.pro"];
41;
42;           {file_in mask} -> {interp_erai_msl_1989_2009} -> {file_out}
43;
44;          }
45;
46; SEE ALSO
47; ========
48;
49; :ref:`project_profile.sh`
50;
51; :ref:`interpolate_data`
52;
53; :func:`report <saxo:report>`
54; :func:`isadirectory <saxo:isadirectory>`
55; :func:`isafile <saxo:isafile>`
56; :func:`initncdf <saxo:initncdf>`
57; :func:`read_ncdf <saxo:read_ncdf>`
58; :func:`domdef <saxo:domdef>`
59; :func:`call_interp2d <saxo:call_interp2d>`
60; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
61;
62; :ref:`d2m_to_q2m_erai.pro`
63;
64; EXAMPLES
65; ========
66;
67; ::
68;
69;  IDL> .compile file_interp
70;  IDL> interp_erai_msl_1989_2009
71;
72; TODO
73; ====
74;
75; msl_attr={units:'milibars' .. millibar at least, hPa will be probably
76; more SI
77;
78; why 19880101,20100930 as dates
79;
80; first step time 14245.5 (days since 1950-01-01 00:00:00) : correct ?
81;
82; KNOWN ISSUES
83; ============
84;
85; test of existence of fullfilename_msk not very efficient because
86; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
87;
88; EVOLUTIONS
89; ==========
90;
91; $Id$
92;
93; $URL$
94;
95; - fplod 20110811T113646Z aedon.locean-ipsl.upmc.fr (Darwin)
96;
97;   * check for units in original file before conversion
98;
99; - fplod 20110809T145539Z aedon.locean-ipsl.upmc.fr (Darwin)
100;
101;   * remove v1 from pro name and file
102;   * header
103;   * usage of ${PROJECT_ID} and ${PROJECT_OD}
104;   * remove return statement
105;   * add test on IO files
106;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
107;
108; - pbk 2008
109;
110;   * creation
111;
112;-
113pro interp_erai_msl_1989_2009
114;
115@cm_4cal
116@cm_4data
117@cm_4mesh
118@cm_4data
119@cm_project
120;
121; check for input directory
122;
123; test if ${PROJECT_ID} defined
124CASE project_id_env OF
125    ''  :  BEGIN
126     msg = 'eee : ${PROJECT_ID} is not defined'
127     ras = report(msg)
128     STOP
129           END
130 ELSE: BEGIN
131     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
132     ras = report(msg)
133       END
134ENDCASE
135;
136iodirin = isadirectory(project_id_env)
137;
138; existence and protection of ${PROJECT_ID}
139IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
140   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
141   ras = report(msg)
142   STOP
143ENDIF
144;
145; build mask filename
146filename_msk='mask_oaflux_30N30S.nc'
147;
148; check if this file exists
149msg='iii : looking for ' + filename_msk
150ras = report(msg)
151fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
152IF fullfilename_msk[0] EQ '' THEN BEGIN
153   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
154   ras = report(msg)
155   STOP
156ENDIF
157;
158; build data filename
159filename='20c3m_erai_msl_TROP_1989_2009.nc'
160;
161; check if this file exists
162msg='iii : looking for ' + filename
163ras = report(msg)
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; test if ${PROJECT_OD} defined
172CASE project_od_env OF
173  '' : BEGIN
174         msg = 'eee : ${PROJECT_OD} is not defined'
175         ras = report(msg)
176       STOP
177       END
178  ELSE: BEGIN
179          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
180          ras = report(msg)
181        END
182 ENDCASE
183;
184; check if output data will be possible
185iodirout = isadirectory(project_od_env)
186;
187; existence and protection
188IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
189    msg = 'eee : the directory' + iodirout  + ' was not found.'
190    ras = report(msg)
191    STOP
192ENDIF
193;
194; build output filename
195filename_out = 'erai_msl_19890101_20091231_oafluxgrid.nc'
196fullfilename_out = iodirout + filename_out
197; in order to avoid unexpected overwritten
198IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
199   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
200   ras = report(msg)
201   STOP
202ENDIF
203
204initncdf, fullfilename
205domdef
206latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
207print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
208print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
209mslin=read_ncdf("msl",19880101,20100930,file=fullfilename,/nostr)
210
211timein=time & jptin=jpt
212tab=mslin(*,*,0)
213mskin=glamt*0.+1.
214
215initncdf, fullfilename_msk
216domdef
217latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
218print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
219print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
220mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
221
222; conversion to hPa
223ncdf_getatt, fullfilename, 'msl', units=units
224CASE units OF
225    'Pascal': BEGIN
226        mslin=mslin/100
227    END
228    ELSE: BEGIN
229        msg = 'eee : ' + units + ' unknown'
230        ras = report(msg)
231        STOP
232    END
233ENDCASE
234
235help, mslin,lonin,latin,mskin,lonout,latout,mskout
236
237si=size(mslin)
238mslout=fltarr(jpi,jpj,jptin)
239for jt=0,jptin-1 do begin
240  print, 'Interpolation jt=',jt,' / ',jptin-1
241  tab=reform(mslin(*,*,jt))
242  mslout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
243      , lonout,latout,method='bilinear' $
244      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
245  mslout(*,*,jt)=mslout(*,*,jt)*mskout+(1.-mskout)*1.e20
246endfor
247
248timein=timein & jptin=jpt
249
250initncdf, fullfilename_msk
251;time=julday(1,2,1989)+lindgen(7516)
252time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
253cda0=string(jul2date(time(0)),format='(i8.8)')
254cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
255timein=time-julday(1,1,1950,00,00)
256
257lat=latout
258lon=lonout
259ncfile='!' + fullfilename_out
260lon_attr={units:'degrees_east',long_name:'Longitude'}
261lat_attr={units:'degrees_north',long_name:'Latitude'}
262time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
263msl_attr={units:'milibars',missing_value:1e20,long_name:'Mean Sea leval pressure',short_name:'msl',axis:'TYX'}
264globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
265
266ncfields = 'msl[longitude,latitude,time]=mslout:msl_attr; ' $
267                      + 'longitude[]=lon:lon_attr; ' $
268                      + 'latitude[]=lat:lat_attr; ' $
269                      + 'time[*time]=timein:time_attr ' $
270                      + ' @ globattr'
271
272@ncdf_quickwrite
273
274end
Note: See TracBrowser for help on using the repository browser.