source: trunk/src/interp_erai_msl_1989_2009.pro @ 153

Last change on this file since 153 was 153, checked in by pinsard, 12 years ago

pro oaflux_mask_30n30s is now a function

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