source: trunk/src/interp_olr_30n30s_1989_2009.pro @ 81

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

progress on swr and olr processing

File size: 7.6 KB
Line 
1;+
2;
3; .. _interp_olr_30n30s_1989_2009.pro:
4;
5; ===============================
6; interp_olr_30n30s_1989_2009.pro
7; ===============================
8;
9; DESCRIPTION
10; ===========
11;
12; Interpolation of OLR to OAFLUX grid
13;
14; :file:`${PROJECT_ID}/olr.day.mean.nc`
15; have been produced by
16; :ref:`get_olr.sh`
17;
18; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid
19; have been produced by
20; :ref:`oaflux_mask_30N30S.pro`.
21;
22; Interpolated OLR is written in
23; :file:`${PROJECT_OD}/${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc`
24; if this file not already exists.
25;
26; This output file will be used by
27; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`.
28;
29;     .. graphviz::
30;
31;        digraph interp_olr_30n30s_1989_2009{
32;
33;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/olr.day.mean_new.nc"];
34;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
35;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"];
36;
37;           interp_olr_30n30s_1989_2009 [shape=box,
38;           fontname=Courier,
39;           color=blue,
40;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_olr_30n30s_1989_2009.pro",
41;           label="${PROJECT}/src/interp_olr_30n30s_1989_2009.pro"];
42;
43;           {file_in mask} -> {interp_olr_30n30s_1989_2009} -> {file_out}
44;
45;         }
46;
47; SEE ALSO
48; ========
49;
50; :ref:`project_profile.sh`
51;
52; :ref:`interpolate_data`
53;
54; :ref:`data_in_olr`, :ref:`get_olr.sh`
55;
56; :func:`report <saxo:report>`
57; :func:`isadirectory <saxo:isadirectory>`
58; :func:`isafile <saxo:isafile>`
59; :func:`initncdf <saxo:initncdf>`
60; :func:`read_ncdf <saxo:read_ncdf>`
61; :func:`domdef <saxo:domdef>`
62; :func:`call_interp2d <saxo:call_interp2d>`
63; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
64;
65; EXAMPLES
66; ========
67;
68; ::
69;
70;  IDL> .compile file_interp
71;  IDL> interp_olr_30n30s_1989_2009
72;
73; TODO
74; ====
75;
76; how can we avoid this message ::
77;
78;   % initncdf: the zaxis was not found..., check the use of ZAXISNAME keyword if you want to find one...
79;
80; I think we do not need any zaxis
81;
82; strange second value (1) in the file produced on cratos idl 7 20110812::
83;
84;   $ ncdump $PROJECT_OD/olr_oafluxgrid_30n30s_19890101_20091231.nc
85;     olr =
86;     1e+20, 1, 258.15, 264.882, 271.614, 273.8116, 271.4748, 269.138, 266.6868,
87;
88; coding rules
89;
90; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
91;
92; pb with mixing interpolated and uninterpolated OLR data
93; check if the input file is the right one (interpolated with get_olr.sh vs non interpolated with get_olr_int.sh)
94;
95; uninterpolated OLR is more timely
96;
97; cf. pk and jv to solve this issue
98;
99; KNOWN ISSUES
100; ============
101;
102; test of existence of fullfilename_msk not very efficient because
103; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
104;
105; EVOLUTIONS
106; ==========
107;
108; $Id$
109;
110; $URL$
111;
112; - fplod 20110812T084449Z aedon.locean-ipsl.upmc.fr (Darwin)
113;
114;   * remove new from filename
115;   * usage of $PROJECT_ID and $PROJECT_OD
116;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
117;   * complete description
118;
119; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
120;
121;   * remove hard coded directory for mask_oaflux_30N30S.nc
122;
123; - fplod 20101215T113118Z aedon.locean-ipsl.upmc.fr (Darwin)
124;
125;   * add graph in header
126;
127; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
128;
129;   * minimal header
130;
131; - pbk 2008
132;
133;   * creation
134;
135;-
136pro interp_olr_30n30s_1989_2009
137;
138@cm_4cal
139@cm_4data
140@cm_4mesh
141@cm_4data
142@cm_project
143;
144; check for input directory
145;
146; test if ${PROJECT_ID} defined
147CASE project_id_env OF
148    ''  :  BEGIN
149     msg = 'eee : ${PROJECT_ID} is not defined'
150     ras = report(msg)
151     STOP
152           END
153 ELSE: BEGIN
154     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
155     ras = report(msg)
156       END
157ENDCASE
158;
159iodirin = isadirectory(project_id_env)
160;
161; existence and protection of ${PROJECT_ID}
162IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
163   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
164   ras = report(msg)
165   STOP
166ENDIF
167;
168; build mask filename
169filename_msk='mask_oaflux_30N30S.nc'
170;
171; check if this file exists
172msg='iii : looking for ' + filename_msk
173ras = report(msg)
174fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
175IF fullfilename_msk[0] EQ '' THEN BEGIN
176   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
177   ras = report(msg)
178   STOP
179ENDIF
180;
181; build data filename
182filename='olr.day.mean.nc'
183;
184; check if this file exists
185msg='iii : looking for ' + filename
186ras = report(msg)
187fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
188IF fullfilename[0] EQ '' THEN BEGIN
189   msg = 'eee : the file ' + fullfilename + ' was not found.'
190   ras = report(msg)
191   STOP
192ENDIF
193;
194; test if ${PROJECT_OD} defined
195CASE project_od_env OF
196  '' : BEGIN
197         msg = 'eee : ${PROJECT_OD} is not defined'
198         ras = report(msg)
199       STOP
200       END
201  ELSE: BEGIN
202          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
203          ras = report(msg)
204        END
205 ENDCASE
206;
207; check if output data will be possible
208iodirout = isadirectory(project_od_env)
209;
210; existence and protection
211IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
212    msg = 'eee : the directory' + iodirout  + ' was not found.'
213    ras = report(msg)
214    STOP
215ENDIF
216;
217; build output filename
218filename_out = 'olr_oafluxgrid_30n30s_19890101_20091231.nc'
219fullfilename_out = iodirout + filename_out
220; in order to avoid unexpected overwritten
221IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
222   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
223   ras = report(msg)
224   STOP
225ENDIF
226;
227initncdf, fullfilename
228domdef
229latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
230print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
231print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
232olrin=read_ncdf("olr",19881231, 20091231, file=fullfilename,/nostr)
233
234mskin=glamt*0.+1.
235
236timein=time & jptin=jpt
237
238initncdf, fullfilename_msk
239domdef
240latout=reform(gphit(0,*)) & lonout=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
245help, olrin,lonin,latin,mskin,lonout,latout,mskout
246
247olrout=fltarr(jpi,jpj,jptin)
248
249for jt=0,jptin-1 do begin
250
251  print, 'Interpolation jt=',jt,' / ',jptin-1
252  tab_olr=reform(olrin(*,*,jt))
253
254  olrout(*,*,jt)=call_interp2d(tab_olr,lonin,latin,mskin $
255      , lonout,latout,method='bilinear'  $
256      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
257  olrout(*,*,jt)=olrout(*,*,jt)*mskout+(1.-mskout)*1.e20
258
259endfor
260
261
262timein=timein & jptin=jpt
263
264timein=timein-julday(1,1,1950,00,00)
265
266lat=latout
267lon=lonout
268ncfile='!' + fullfilename_out
269lon_attr={units:'degrees_east',long_name:'Longitude'}
270lat_attr={units:'degrees_north',long_name:'Latitude'}
271time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
272olr_attr={units:'w/m^2',missing_value:1e20,long_name:'Outgoing Longwave Radiation',short_name:'olr',axis:'TYX'}
273olra_attr={units:'w/m^2',missing_value:1e20,long_name:'Outgoing Longwave Radiation Anomaly',short_name:'olra',axis:'TYX'}
274globattr={source:'NOAA OLR, cf http://www.cdc.noaa.gov/cdc/data.interp_OLR.html, interpolated to 1x1 degree grid and with oaflux mask'}
275
276ncfields = 'olr[longitude,latitude,time]=olrout:olr_attr; ' $
277                      + 'longitude[]=lon:lon_attr; ' $
278                      + 'latitude[]=lat:lat_attr; ' $
279                      + 'time[*time]=timein:time_attr ' $
280                      + ' @ globattr'
281
282@ncdf_quickwrite
283
284end
Note: See TracBrowser for help on using the repository browser.