source: trunk/src/interp_erai_dewt_1989_2009.pro @ 71

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