source: trunk/src/interp_erai_lwr_1989_2009.pro @ 128

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

start to homogenize (to be cont.)

  • Property svn:keywords set to Id
File size: 8.7 KB
RevLine 
[6]1;+
2;
[19]3; .. _interp_erai_lwr_1989_2009.pro:
[6]4;
[67]5; =============================
6; interp_erai_lwr_1989_2009.pro
7; =============================
[6]8;
[67]9; DESCRIPTION
10; ===========
11;
[66]12; Interpolation of str from ERA-I grid to OAFLUX grid
13;
[97]14; :file:`${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc`
15; containing str from ERA-I
[100]16; has been produced by
17; :ref:`compute_erai_daily_region_2d.sh`.
[66]18;
[97]19; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc`
[88]20; containing OAFLUX mask
[97]21; has been produced by
[88]22; :ref:`oaflux_mask_30N30S.pro`.
[66]23;
[100]24; Interpolated str
25; is written in
[97]26; :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc`
[88]27; if this file not already exists.
[66]28;
[97]29; This output file
30; :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc`
[100]31; must be processed after by
32; :ref:`add_198900101.sh`.
[66]33;
[92]34; .. only:: man
35;
36;    Figure is visible on PDF and HTML documents only.
37;
38; .. only:: html or latex
39;
[8]40;     .. graphviz::
41;
42;        digraph interp_erai_lwr_1989_2009 {
43;
[66]44;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc"];
[71]45;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
46;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc"];
[8]47;
48;           interp_erai_lwr_1989_2009 [shape=box,
49;           fontname=Courier,
50;           color=blue,
51;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_lwr_1989_2009.pro",
[50]52;           label="${PROJECT}/src/interp_erai_lwr_1989_2009.pro"];
[8]53;
[71]54;           {file_in mask} -> {interp_erai_lwr_1989_2009} -> {file_out}
[8]55;
[100]56;        }
[8]57;
[6]58; SEE ALSO
59; ========
60;
[92]61; :ref:`interpolate_data`
62;
[50]63; :ref:`project_profile.sh`
[19]64;
[20]65; :func:`report <saxo:report>`
66; :func:`isadirectory <saxo:isadirectory>`
67; :func:`isafile <saxo:isafile>`
68; :func:`initncdf <saxo:initncdf>`
69; :func:`read_ncdf <saxo:read_ncdf>`
70; :func:`domdef <saxo:domdef>`
71; :func:`call_interp2d <saxo:call_interp2d>`
72; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
73;
[88]74; :ref:`add_198900101.sh`
[66]75;
[6]76; EXAMPLES
77; ========
78;
79; ::
80;
[66]81;  IDL> .compile file_interp
[6]82;  IDL> interp_erai_lwr_1989_2009
83;
84; TODO
85; ====
86;
[93]87; make it work : pb on loholt1 idl8:
[6]88;
[93]89; reach end but bad values (all NaN)
[66]90;
[73]91; make it work : pb on loholt1 idl6::
92;
93;   lwr[longitude,latitude,time]=lwrout:lwr_attr; longitude[]=xlon:lon_attr; latitude[]=ylat:lat_attr; tt[*time]=tt:time_attr  @ globattr
94;   % NCDF_VARPUT: Operation Failed, bad file (4) or variable (0) id ?
95;                  (NC_ERROR=-31)
96;   % Stop encountered: INTERP_ERAI_LWR_1989_2009    1
97;     /home/pinsard/tropflux_ws/src/interp_erai_lwr_1989_2009.pro
98;
[70]99; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
100;
101; use real output of :ref:`compute_erai_daily_region_2d.sh`.
102;
[88]103; remove hard coded time
104;
[70]105; 19890101 is not provided in ERA-Intermim file str : a possible workaround is to copy 19890102
[78]106; dataset to 19890101 using nco after this processing. see :ref:`compute_erai_daily_region_2d.sh`
[70]107;
[6]108; coding rules
109;
[19]110; KNOWN ISSUES
111; ============
112;
113; test of existence of fullfilename_msk not very efficient because
114; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
115;
[6]116; EVOLUTIONS
117; ==========
118;
[66]119; $Id$
120;
[88]121; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_lwr_1989_2009.pro $
[66]122;
[100]123; - fplod 20110830T145010Z cratos (Linux)
124;
125;   * replace xlon by lon and xlat by lat; suppress extra initcdf call
126;
[98]127; - fplod 20110830T135030Z cratos (Linux)
128;
129;   * replace tt by time
130;
[92]131; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux)
132;
133;   * retry on loholt1 with idl8 and idl6
134;
[88]135; - fplod 20110819T084310Z aedon.locean-ipsl.upmc.fr (Darwin)
136;
137;   * replace next step :ref:`lwr_correction_ncdf.pro` by :ref:`add_19890101.sh`
138;   * fix output file name to erai_lwr_19890102_20091231_oafluxgrid.nc
139;
[73]140; - pinsard 2011-08-08T16:03:48Z loholt1.ipsl.polytechnique.fr (Linux)
141;
142;   * remove return statement
143;
[70]144; - fplod 20110808T094156Z cratos (Linux)
145;
146;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
147;   * fix typo
148;     .. note::
149;
150;        IDL do not warn when asking size of an undefined array::
151;
152;           IDL> must_crash=size(ginette)
153;
[66]154; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux)
155;
156;   * usage of $PROJECT_ID and $PROJECT_OD
157;
[19]158; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
159;
160;   * remove hard coded directory for mask_oaflux_30N30S.nc
161;
[8]162; - fplod 20101215T094137Z aedon.locean-ipsl.upmc.fr (Darwin)
163;
164;   * add graph in header
165;
[6]166; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
167;
168;   * minimal header
169;
170; - pbk 2008
171;
172;   * creation
173;
174;-
[5]175pro interp_erai_lwr_1989_2009
[19]176;
[66]177@cm_4cal
178@cm_4data
179@cm_4mesh
180@cm_4data
181@cm_project
182;
[20]183; check for input directory
[19]184;
[50]185; test if ${PROJECT_ID} defined
186CASE project_id_env OF
[19]187    ''  :  BEGIN
[50]188     msg = 'eee : ${PROJECT_ID} is not defined'
[19]189     ras = report(msg)
190     STOP
191           END
192 ELSE: BEGIN
[50]193     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
[19]194     ras = report(msg)
195       END
196ENDCASE
197;
[50]198iodirin = isadirectory(project_id_env)
[19]199;
[50]200; existence and protection of ${PROJECT_ID}
[19]201IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
202   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
203   ras = report(msg)
204   STOP
205ENDIF
206;
207; build mask filename
208filename_msk='mask_oaflux_30N30S.nc'
209;
210; check if this file exists
[92]211msg='iii : looking for ' + filename_msk
212ras = report(msg)
[19]213fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
214IF fullfilename_msk[0] EQ '' THEN BEGIN
215   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
216   ras = report(msg)
217   STOP
218ENDIF
[97]219;
220st=19890101
[94]221en=20090801
[97]222;
[66]223; build data filename
224filename='20c3m_erai_str_TROP_1989_2009.nc'
225;
226; check if this file exists
[92]227msg='iii : looking for ' + filename
228ras = report(msg)
[66]229fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
[71]230IF fullfilename[0] EQ '' THEN BEGIN
231   msg = 'eee : the file ' + fullfilename + ' was not found.'
[66]232   ras = report(msg)
233   STOP
234ENDIF
235;
236; test if ${PROJECT_OD} defined
237CASE project_od_env OF
238  '' : BEGIN
239         msg = 'eee : ${PROJECT_OD} is not defined'
240         ras = report(msg)
241       STOP
242       END
243  ELSE: BEGIN
244          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
245          ras = report(msg)
246        END
247 ENDCASE
248;
249; check if output data will be possible
250iodirout = isadirectory(project_od_env)
251;
252; existence and protection
253IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
254    msg = 'eee : the directory' + iodirout  + ' was not found.'
255    ras = report(msg)
256    STOP
257ENDIF
258;
259; build output filename
[88]260filename_out = 'erai_lwr_19890102_20091231_oafluxgrid.nc'
[66]261fullfilename_out = iodirout + filename_out
262; in order to avoid unexpected overwritten
263IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
264   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
265   ras = report(msg)
266   STOP
267ENDIF
268;
269initncdf, fullfilename
270lwrin=read_ncdf("str",0,7668,/timestep,file=fullfilename,/nostr)
[5]271lwrin=-1*lwrin
[97]272;
[66]273initncdf, fullfilename
[5]274domdef
[97]275latin=reform(gphit(0,*))
[94]276lonin=reform(glamt(*,0))
[5]277print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
278print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
[97]279;
[94]280jptin=jpt
[5]281tab=lwrin(*,*,0)
282mskin=glamt*0.+1.
[97]283;
[19]284initncdf, fullfilename_msk
[5]285domdef
[100]286latout=reform(gphit(0,*))
287lonout=reform(glamt(*,0))
[5]288print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
289print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
[19]290mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
[97]291;
[5]292lwrout=fltarr(jpi,jpj,jptin)
[97]293;
[5]294for jt=0,jptin-1 do begin
[92]295  ; ++print, 'Interpolation jt=',jt,' / ',jptin-1
[97]296;
[5]297  tab=reform(lwrin(*,*,jt))
[70]298  lwrout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
[71]299      , lonout,latout,method='bilinear' $
300      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
[5]301  lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20
[97]302;
[5]303endfor
[97]304;
305time=timegen(7669, start=julday(1,2,1989,0), units='days')
[94]306jpt=n_elements(time)
[98]307cda0=string(jul2date(time(0)),format='(i8.8)')
308cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
309time=time-julday(1,1,1950,00,00,00)
[97]310;
[100]311lat=latout
312lon=lonout
[66]313ncfile='!' + fullfilename_out
[5]314lon_attr={units:'degrees_east',long_name:'Longitude'}
315lat_attr={units:'degrees_north',long_name:'Latitude'}
[100]316time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
317globattr={source:'Tropical ocean fluxes obtained from ERA Interim',timerange:cda0+' - '+cda1}
[5]318lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation ',short_name:'lwr',axis:'TYX'}
[97]319;
[5]320ncfields = 'lwr[longitude,latitude,time]=lwrout:lwr_attr; ' $
[100]321                      + 'longitude[]=lon:lon_attr; ' $
322                      + 'latitude[]=lat:lat_attr; ' $
[98]323                      + 'time[*time]=time:time_attr ' $
[5]324                      + ' @ globattr'
[97]325;
[5]326@ncdf_quickwrite
[97]327;
[5]328end
Note: See TracBrowser for help on using the repository browser.