source: trunk/src/interp_erai_lwr_1989_2009.pro @ 67

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

fix for doc

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