source: trunk/src/interp_erai_lwr_1989_2009.pro @ 66

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

no more hard coded path in iterp_erai*.pro

File size: 7.2 KB
Line 
1;+
2;
3; .. _interp_erai_lwr_1989_2009.pro:
4;
5; ===============================================================================
6; interp_erai_lwr_1989_2009.pro - Interpolation of str from ERA-I grid to OAFLUX
7; ===============================================================================
8;
9; Interpolation of str from ERA-I grid to OAFLUX grid
10;
11; :file:`${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc` containing str from ERA-I have been produced
12; by :ref:`compute_erai_daily_region_2d.sh`.
13;
14; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`.
15;
16; Interpolated str is written in
17; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` if this file not already exists.
18;
19; This output file :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`lwr_correction_ncdf.pro`.
20;
21;     .. graphviz::
22;
23;        digraph interp_erai_lwr_1989_2009 {
24;           graph [
25;           rankdir="LR",
26;           ]
27;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
28;
29;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc"];
30;
31;           ncfile [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc"];
32;
33;           interp_erai_lwr_1989_2009 [shape=box,
34;           fontname=Courier,
35;           color=blue,
36;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_lwr_1989_2009.pro",
37;           label="${PROJECT}/src/interp_erai_lwr_1989_2009.pro"];
38;
39;           {mask file_in} -> {interp_erai_lwr_1989_2009} -> {ncfile}
40;
41;         }
42;
43; SEE ALSO
44; ========
45;
46; :ref:`project_profile.sh`
47;
48; :func:`report <saxo:report>`
49; :func:`isadirectory <saxo:isadirectory>`
50; :func:`isafile <saxo:isafile>`
51; :func:`initncdf <saxo:initncdf>`
52; :func:`read_ncdf <saxo:read_ncdf>`
53; :func:`domdef <saxo:domdef>`
54; :func:`call_interp2d <saxo:call_interp2d>`
55; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
56;
57; :ref:`lwr_correction_ncdf`
58;
59; EXAMPLES
60; ========
61;
62; ::
63;
64;  IDL> .compile file_interp
65;  IDL> interp_erai_lwr_1989_2009
66;
67; TODO
68; ====
69;
70; make it work : pb on loholt1::
71;
72;   Variable is undefined: OUTMASK_IND.
73;
74; coding rules
75;
76; KNOWN ISSUES
77; ============
78;
79; test of existence of fullfilename_msk not very efficient because
80; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
81;
82; EVOLUTIONS
83; ==========
84;
85; $Id$
86;
87; $URL$
88;
89; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux)
90;
91;   * usage of $PROJECT_ID and $PROJECT_OD
92;
93; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
94;
95;   * remove hard coded directory for mask_oaflux_30N30S.nc
96;
97; - fplod 20101215T094137Z aedon.locean-ipsl.upmc.fr (Darwin)
98;
99;   * add graph in header
100;
101; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
102;
103;   * minimal header
104;
105; - pbk 2008
106;
107;   * creation
108;
109;-
110pro interp_erai_lwr_1989_2009
111;
112@cm_4cal
113@cm_4data
114@cm_4mesh
115@cm_4data
116@cm_project
117;
118; check for input directory
119;
120; test if ${PROJECT_ID} defined
121CASE project_id_env OF
122    ''  :  BEGIN
123     msg = 'eee : ${PROJECT_ID} is not defined'
124     ras = report(msg)
125     STOP
126           END
127 ELSE: BEGIN
128     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
129     ras = report(msg)
130       END
131ENDCASE
132;
133iodirin = isadirectory(project_id_env)
134;
135; existence and protection of ${PROJECT_ID}
136IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
137   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
138   ras = report(msg)
139   STOP
140ENDIF
141;
142; build mask filename
143filename_msk='mask_oaflux_30N30S.nc'
144;
145; check if this file exists
146fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
147IF fullfilename_msk[0] EQ '' THEN BEGIN
148   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
149   ras = report(msg)
150   STOP
151ENDIF
152
153st=19890101 & en=20090801
154
155; build data filename
156filename='20c3m_erai_str_TROP_1989_2009.nc'
157;
158; check if this file exists
159fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
160IF fullfilename_msk[0] EQ '' THEN BEGIN
161   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
162   ras = report(msg)
163   STOP
164ENDIF
165;
166; test if ${PROJECT_OD} defined
167CASE project_od_env OF
168  '' : BEGIN
169         msg = 'eee : ${PROJECT_OD} is not defined'
170         ras = report(msg)
171       STOP
172       END
173  ELSE: BEGIN
174          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
175          ras = report(msg)
176        END
177 ENDCASE
178;
179; check if output data will be possible
180iodirout = isadirectory(project_od_env)
181;
182; existence and protection
183IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
184    msg = 'eee : the directory' + iodirout  + ' was not found.'
185    ras = report(msg)
186    STOP
187ENDIF
188;
189; build output filename
190filename_out = 'erai_lwr_19890101_20091231_oafluxgrid.nc'
191fullfilename_out = iodirout + filename_out
192; in order to avoid unexpected overwritten
193IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
194   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
195   ras = report(msg)
196   STOP
197ENDIF
198;
199initncdf, fullfilename
200lwrin=read_ncdf("str",0,7668,/timestep,file=fullfilename,/nostr)
201lwrin=-1*lwrin
202help, lwrin
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)
209
210timein=time & jptin=jpt
211tab=lwrin(*,*,0)
212mskin=glamt*0.+1.
213
214initncdf, fullfilename_msk
215domdef
216latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
217print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
218print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
219mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
220
221help, lwrin
222
223si=size(swrin)
224lwrout=fltarr(jpi,jpj,jptin)
225
226for jt=0,jptin-1 do begin
227  print, 'Interpolation jt=',jt,' / ',jptin-1
228
229  tab=reform(lwrin(*,*,jt))
230  lwrout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
231  lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20
232
233endfor
234
235time=timegen(7669, start=julday(1,2,1989,0), units='days') & jpt=n_elements(time)
236tt=time & jptin=jpt
237cda0=string(jul2date(tt(0)),format='(i8.8)')
238cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
239tt=tt-julday(1,1,1950,00,00,00)
240xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
241
242initncdf, fullfilename_msk
243valmask=1.e20
244
245ylat=latout
246xlon=lonout
247ncfile='!' + fullfilename_out
248lon_attr={units:'degrees_east',long_name:'Longitude'}
249lat_attr={units:'degrees_north',long_name:'Latitude'}
250time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
251
252lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation ',short_name:'lwr',axis:'TYX'}
253time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
254globattr={source:'Tropical ocean fluxes obtained from ERA Interim',timerange:cda0+' - '+cda1}
255
256help,lwrout
257
258ncfields = 'lwr[longitude,latitude,time]=lwrout:lwr_attr; ' $
259                      + 'longitude[]=xlon:lon_attr; ' $
260                      + 'latitude[]=ylat:lat_attr; ' $
261                      + 'tt[*time]=tt:time_attr ' $
262                      + ' @ globattr'
263
264@ncdf_quickwrite
265
266return
267end
Note: See TracBrowser for help on using the repository browser.