source: trunk/src/interp_erai_lwr_1989_2009.pro @ 72

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

try to interp ERA-I on climserv (not ok yet); minimize diffreneces between sources

  • Property svn:keywords set to URL
File size: 8.0 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;
31;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc"];
32;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
33;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc"];
34;
35;           interp_erai_lwr_1989_2009 [shape=box,
36;           fontname=Courier,
37;           color=blue,
38;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_lwr_1989_2009.pro",
39;           label="${PROJECT}/src/interp_erai_lwr_1989_2009.pro"];
40;
41;           {file_in mask} -> {interp_erai_lwr_1989_2009} -> {file_out}
42;
43;         }
44;
45; SEE ALSO
46; ========
47;
48; :ref:`project_profile.sh`
49;
50; :func:`report <saxo:report>`
51; :func:`isadirectory <saxo:isadirectory>`
52; :func:`isafile <saxo:isafile>`
53; :func:`initncdf <saxo:initncdf>`
54; :func:`read_ncdf <saxo:read_ncdf>`
55; :func:`domdef <saxo:domdef>`
56; :func:`call_interp2d <saxo:call_interp2d>`
57; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
58;
59; :ref:`lwr_correction_ncdf.pro`
60;
61; EXAMPLES
62; ========
63;
64; ::
65;
66;  IDL> .compile file_interp
67;  IDL> interp_erai_lwr_1989_2009
68;
69; TODO
70; ====
71;
72; make it work : pb on loholt1::
73;
74;  OUTMASK_IND     UNDEFINED = <Undefined>
75;  SET_OUTMSKVAL   UNDEFINED = <Undefined>
76
77;  lwr[longitude,latitude,time]=lwrout:lwr_attr; longitude[]=xlon:lon_attr; latitude[]=ylat:lat_attr; tt[*time]=tt:time_attr  @ globattr
78;  % NCDF_DIMDEF: 0 is not a valid cdfid.
79;  % Stop encountered: INTERP_ERAI_LWR_1989_2009    1
80;     /home/pinsard/tropflux_ws/src/interp_erai_lwr_1989_2009.pro
81;
82; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
83;
84; use real output of :ref:`compute_erai_daily_region_2d.sh`.
85;
86; 19890101 is not provided in ERA-Intermim file str : a possible workaround is to copy 19890102
87; dataset to 19890101 using nco before processing. see :ref:`compute_erai_daily_region_2d.sh`
88;
89; coding rules
90;
91; KNOWN ISSUES
92; ============
93;
94; test of existence of fullfilename_msk not very efficient because
95; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
96;
97; EVOLUTIONS
98; ==========
99;
100; $Id$
101;
102; $URL$
103;
104; - fplod 20110808T094156Z cratos (Linux)
105;
106;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
107;   * fix typo
108;     .. note::
109;
110;        IDL do not warn when asking size of an undefined array::
111;
112;           IDL> must_crash=size(ginette)
113;
114; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux)
115;
116;   * usage of $PROJECT_ID and $PROJECT_OD
117;
118; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
119;
120;   * remove hard coded directory for mask_oaflux_30N30S.nc
121;
122; - fplod 20101215T094137Z aedon.locean-ipsl.upmc.fr (Darwin)
123;
124;   * add graph in header
125;
126; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
127;
128;   * minimal header
129;
130; - pbk 2008
131;
132;   * creation
133;
134;-
135pro interp_erai_lwr_1989_2009
136;
137@cm_4cal
138@cm_4data
139@cm_4mesh
140@cm_4data
141@cm_project
142;
143; check for input directory
144;
145; test if ${PROJECT_ID} defined
146CASE project_id_env OF
147    ''  :  BEGIN
148     msg = 'eee : ${PROJECT_ID} is not defined'
149     ras = report(msg)
150     STOP
151           END
152 ELSE: BEGIN
153     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
154     ras = report(msg)
155       END
156ENDCASE
157;
158iodirin = isadirectory(project_id_env)
159;
160; existence and protection of ${PROJECT_ID}
161IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
162   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
163   ras = report(msg)
164   STOP
165ENDIF
166;
167; build mask filename
168filename_msk='mask_oaflux_30N30S.nc'
169;
170; check if this file exists
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
178st=19890101 & en=20090801
179
180; build data filename
181filename='20c3m_erai_str_TROP_1989_2009.nc'
182;
183; check if this file exists
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_lwr_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
225lwrin=read_ncdf("str",0,7668,/timestep,file=fullfilename,/nostr)
226lwrin=-1*lwrin
227
228initncdf, fullfilename
229domdef
230latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
231print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
232print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
233
234timein=time & jptin=jpt
235tab=lwrin(*,*,0)
236mskin=glamt*0.+1.
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
245si=size(lwrin)
246lwrout=fltarr(jpi,jpj,jptin)
247
248for jt=0,jptin-1 do begin
249  print, 'Interpolation jt=',jt,' / ',jptin-1
250
251  tab=reform(lwrin(*,*,jt))
252  lwrout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
253      , lonout,latout,method='bilinear' $
254      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
255  help, OUTMASK_IND
256  help, SET_OUTMSKVAL
257  lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20
258
259endfor
260
261time=timegen(7669, start=julday(1,2,1989,0), units='days') & jpt=n_elements(time)
262tt=time & jptin=jpt
263cda0=string(jul2date(tt(0)),format='(i8.8)')
264cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
265tt=tt-julday(1,1,1950,00,00,00)
266xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
267
268initncdf, fullfilename_msk
269valmask=1.e20
270
271ylat=latout
272xlon=lonout
273ncfile='!' + fullfilename_out
274lon_attr={units:'degrees_east',long_name:'Longitude'}
275lat_attr={units:'degrees_north',long_name:'Latitude'}
276time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
277
278lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation ',short_name:'lwr',axis:'TYX'}
279time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
280globattr={source:'Tropical ocean fluxes obtained from ERA Interim',timerange:cda0+' - '+cda1}
281
282ncfields = 'lwr[longitude,latitude,time]=lwrout:lwr_attr; ' $
283                      + 'longitude[]=xlon:lon_attr; ' $
284                      + 'latitude[]=ylat:lat_attr; ' $
285                      + 'tt[*time]=tt:time_attr ' $
286                      + ' @ globattr'
287
288@ncdf_quickwrite
289
290return
291end
Note: See TracBrowser for help on using the repository browser.