source: trunk/src/interp_erai_t2m_1989_2009.pro @ 19

Last change on this file since 19 was 19, checked in by pinsard, 14 years ago

remove hard coded directory for mask_oaflux_30N30S.nc

File size: 4.7 KB
Line 
1;+
2;
3; .. _interp_erai_t2m_1989_2009.pro:
4;
5; =============================
6; interp_erai_t2m_1989_2009.pro
7; =============================
8;
9;
10;     .. graphviz::
11;
12;        digraph interp_erai_t2m_1989_2009 {
13;           graph [
14;           rankdir="LR",
15;           ]
16;           file_in [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/ERAI_global/20c3m_erai_t2_TROP_1989_2009.nc"];
17;           mask [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/mask_oaflux_30N30S.nc"];
18;
19;           ncfile [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc"];
20;
21;           interp_erai_t2m_1989_2009 [shape=box,
22;           fontname=Courier,
23;           color=blue,
24;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_t2m_1989_2009.pro"",
25;           label="${TROPFLUX}/src/interp_erai_t2m_1989_2009.pro"];
26;
27;           {file_in mask} -> {interp_erai_t2m_1989_2009} -> {ncfile}
28;
29;          }
30;
31;
32; SEE ALSO
33; ========
34;
35; :ref:`tropflux_profile.sh`
36;
37; EXAMPLES
38; ========
39;
40; ::
41;
42;  IDL> interp_erai_t2m_1989_2009
43;
44;
45; TODO
46; ====
47;
48; hard coded directory - usage of ${TROPFLUX_ID}
49;
50; coding rules
51;
52; KNOWN ISSUES
53; ============
54;
55; test of existence of fullfilename_msk not very efficient because
56; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
57;
58; EVOLUTIONS
59; ==========
60;
61; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
62;
63;   * remove hard coded directory for mask_oaflux_30N30S.nc
64;
65; - fplod 20101215T112140Z aedon.locean-ipsl.upmc.fr (Darwin)
66;
67;   * add graph in header
68;
69; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
70;
71;   * minimal header
72;
73; - pbk 2008
74;
75;   * creation
76;
77;-
78pro interp_erai_t2m_1989_2009
79@common
80;
81; check for input directory
82;
83; test if ${TROPFLUX_ID} defined
84tropflux_id_env=GETENV('TROPFLUX_ID')
85CASE tropflux_id_env OF
86    ''  :  BEGIN
87     msg = 'eee : ${TROPFLUX_ID} is not defined'
88     ras = report(msg)
89     STOP
90           END
91 ELSE: BEGIN
92     msg = 'iii : ${TROPFLUX_ID} is ' + tropflux_id_env
93     ras = report(msg)
94       END
95ENDCASE
96;
97iodirin = isadirectory(tropflux_id_env)
98;
99; existence and protection of ${TROPFLUX_ID}
100IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
101   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
102   ras = report(msg)
103   STOP
104ENDIF
105;
106; build mask filename
107filename_msk='mask_oaflux_30N30S.nc'
108;
109; check if this file exists
110fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
111IF fullfilename_msk[0] EQ '' THEN BEGIN
112   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
113   ras = report(msg)
114   STOP
115ENDIF
116
117filein='/Volumes/PRAVEEN/ERAI_global/20c3m_erai_t2_TROP_1989_2009.nc'
118
119initncdf, filein
120domdef
121latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
122print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
123print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
124t2min=read_ncdf("t2",19880101,20100930,file=filein,/nostr)
125
126timein=time & jptin=jpt
127tab=t2min(*,*,0)
128mskin=glamt*0.+1.
129
130initncdf, fullfilename_msk
131domdef
132latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
133print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
134print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
135mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
136
137help, t2min,lonin,latin,mskin,lonout,latout,mskout
138si=size(t2min)
139t2mout=fltarr(jpi,jpj,jptin)
140for jt=0,jptin-1 do begin
141  print, 'Interpolation jt=',jt,' / ',jptin-1
142  tab=reform(t2min(*,*,jt))
143  t2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
144  t2mout(*,*,jt)=t2mout(*,*,jt)*mskout+(1.-mskout)*1.e20
145endfor
146
147timein=timein & jptin=jpt
148
149initncdf, fullfilename_msk
150help, t2mout
151tt=timein
152time=julday(1,1,1989)+lindgen(7670)+0.5 & jpt=n_elements(time)
153;cda0=string(jul2date(time(0)),format='(i8.8)')
154;cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
155;cda0=string('19890101') & cda1=string('20091231')
156
157timein=time-julday(1,1,1950,00,00)
158
159lat=latout
160lon=lonout
161ncfile='!/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc'
162lon_attr={units:'degrees_east',long_name:'Longitude'}
163lat_attr={units:'degrees_north',long_name:'Latitude'}
164time_attr={units:'hours since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
165t2m_attr={units:'degK',missing_value:1e20,long_name:'Air Temperature at 2m',short_name:'t2m',axis:'TYX'}
166globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
167
168
169ncfields = 't2m[longitude,latitude,time]=t2mout:t2m_attr; ' $
170                      + 'longitude[]=lon:lon_attr; ' $
171                      + 'latitude[]=lat:lat_attr; ' $
172                      + 'time[*time]=timein:time_attr ' $
173                      + ' @ globattr'
174
175@ncdf_quickwrite
176
177
178end
Note: See TracBrowser for help on using the repository browser.