source: trunk/src/interp_erai_sst_1989_2009.pro @ 153

Last change on this file since 153 was 153, checked in by pinsard, 12 years ago

pro oaflux_mask_30n30s is now a function

  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1;+
2;
3; .. _interp_erai_sst_1989_2009.pro:
4;
5; =============================
6; interp_erai_sst_1989_2009.pro
7; =============================
8;
9; DESCRIPTION
10; ===========
11;
12; Interpolation of sst from ERA-I grid to OAFLUX grid
13;
14; :file:`${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc`
15; containing sst from ERA-I
16; has been produced by
17; :ref:`compute_erai_daily_region_2d.sh`.
18;
19; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc`
20; containing
21; OAFLUX grid
22; has been produced by
23; :func:`oaflux_mask_30n30s`.
24;
25; Interpolated sst
26; is written in
27; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc`
28; if this file not already exists.
29;
30; This output file
31; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc`
32; must be processed after by
33; :ref:`sst_correction_ncdf.pro`.
34;
35; .. only:: man
36;
37;    Figure is visible on PDF and HTML documents only.
38;
39; .. only:: html or latex
40;
41;     .. graphviz::
42;
43;        digraph interp_erai_sst_1989_2009 {
44;
45;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc"];
46;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
47;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"];
48;
49;           interp_erai_sst_1989_2009 [shape=box,
50;           fontname=Courier,
51;           color=blue,
52;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_sst_1989_2009.pro",
53;           label="${PROJECT}/src/interp_erai_sst_1989_2009.pro"];
54;
55;           {file_in mask} -> {interp_erai_sst_1989_2009} -> {file_out}
56;
57;        }
58;
59; SEE ALSO
60; ========
61;
62; :ref:`interpolate_data`
63;
64; :ref:`project_profile.sh`
65;
66; :func:`report <saxo:report>`
67; :func:`isadirectory <saxo:isadirectory>`
68; :func:`isafile <saxo:isafile>`
69; :func:`initncdf <saxo:initncdf>`
70; :func:`read_ncdf <saxo:read_ncdf>`
71; :func:`domdef <saxo:domdef>`
72; :func:`call_interp2d <saxo:call_interp2d>`
73; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
74;
75; :ref:`sst_correction_ncdf.pro`
76;
77; EXAMPLES
78; ========
79;
80; ::
81;
82;  IDL> .compile file_interp
83;  IDL> interp_erai_sst_1989_2009
84;
85; TODO
86; ====
87;
88; on cratos strange red data looking with ncview
89;
90; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
91;
92; coding rules
93;
94; use real output of :ref:`compute_erai_daily_region_2d.sh`.
95;
96; KNOWN ISSUES
97; ============
98;
99; test of existence of fullfilename_msk not very efficient because
100; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
101;
102; EVOLUTIONS
103; ==========
104;
105; $Id$
106;
107; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_sst_1989_2009.pro $
108;
109; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux)
110;
111;   * retry on loholt1 with idl8 and idl6
112;
113; - fplod 20110808T094156Z cratos (Linux)
114;
115;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
116;
117; - pinsard 2011-07-04T15:45:35Z loholt1.ipsl.polytechnique.fr (Linux)
118;
119;   * usage of ${PROJECT_ID} and $PROJECT_OD
120;
121; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
122;
123;   * remove hard coded directory for mask_oaflux_30N30S.nc
124;
125; - fplod 20101215T100932Z aedon.locean-ipsl.upmc.fr (Darwin)
126;
127;   * add graph in header
128;
129; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
130;
131;   * minimal header
132;
133; - pbk 2008
134;
135;   * creation
136;
137;-
138pro interp_erai_sst_1989_2009
139;
140@cm_4cal
141@cm_4data
142@cm_4mesh
143@cm_4data
144@cm_project
145;
146; check for input directory
147;
148; test if ${PROJECT_ID} defined
149CASE project_id_env OF
150    ''  :  BEGIN
151     msg = 'eee : ${PROJECT_ID} is not defined'
152     ras = report(msg)
153     STOP
154           END
155 ELSE: BEGIN
156     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
157     ras = report(msg)
158       END
159ENDCASE
160;
161iodirin = isadirectory(project_id_env)
162;
163; existence and protection of ${PROJECT_ID}
164IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
165   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
166   ras = report(msg)
167   STOP
168ENDIF
169;
170; build mask filename
171filename_msk='mask_oaflux_30N30S.nc'
172;
173; check if this file exists
174msg='iii : looking for ' + filename_msk
175ras = report(msg)
176fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
177IF fullfilename_msk[0] EQ '' THEN BEGIN
178   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
179   ras = report(msg)
180   STOP
181ENDIF
182;
183; build data filename
184filename='20c3m_erai_sstk_TROP_1989_2009.nc'
185;
186; check if this file exists
187msg='iii : looking for ' + filename
188ras = report(msg)
189fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
190IF fullfilename[0] EQ '' THEN BEGIN
191   msg = 'eee : the file ' + fullfilename + ' was not found.'
192   ras = report(msg)
193   STOP
194ENDIF
195;
196; test if ${PROJECT_OD} defined
197CASE project_od_env OF
198  '' : BEGIN
199         msg = 'eee : ${PROJECT_OD} is not defined'
200         ras = report(msg)
201       STOP
202       END
203  ELSE: BEGIN
204          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
205          ras = report(msg)
206        END
207 ENDCASE
208;
209; check if output data will be possible
210iodirout = isadirectory(project_od_env)
211;
212; existence and protection
213IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
214    msg = 'eee : the directory' + iodirout  + ' was not found.'
215    ras = report(msg)
216    STOP
217ENDIF
218;
219; build output filename
220filename_out = 'erai_sst_19890101_20091231_oafluxgrid.nc'
221fullfilename_out = iodirout + filename_out
222; in order to avoid unexpected overwritten
223IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
224   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
225   ras = report(msg)
226   STOP
227ENDIF
228;
229initncdf, fullfilename
230domdef
231latin=reform(gphit(0,*))
232lonin=reform(glamt(*,0))
233print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
234print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
235sstkin=read_ncdf("sstk",19871201,20100930,file=fullfilename,/nostr)
236;
237timein=time
238jptin=jpt
239tab=sstkin(*,*,0)
240mskin=glamt*0.+1.
241ind=where((tab eq 1.e9) or finite(tab,/nan))
242mskin(ind)=0.
243;
244initncdf, fullfilename_msk
245domdef
246latout=reform(gphit(0,*))
247lonout=reform(glamt(*,0))
248print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
249print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
250mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
251;
252help, sstkin,lonin,latin,mskin,lonout,latout,mskout
253;
254sstkout=fltarr(jpi,jpj,jptin)
255for jt=0,jptin-1 do begin
256  ; ++print, 'Interpolation jt=',jt,' / ',jptin-1
257  tab=reform(sstkin(*,*,jt))
258  sstkout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
259      , lonout,latout,method='bilinear' $
260      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
261  sstkout(*,*,jt)=sstkout(*,*,jt)*mskout+(1.-mskout)*1.e20
262endfor
263;
264initncdf, fullfilename_msk
265time=timegen(7670, start=julday(1,1,1989,0), units='days')
266jpt=n_elements(time)
267cda0=string(jul2date(time(0)),format='(i8.8)')
268cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
269timein=timein-julday(1,1,1950,00,00)
270;
271lat=latout
272lon=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'}
277globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
278sstk_attr={units:'degK',missing_value:1e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'}
279;
280ncfields = 'sst[longitude,latitude,time]=sstkout:sstk_attr; ' $
281                      + 'longitude[]=lon:lon_attr; ' $
282                      + 'latitude[]=lat:lat_attr; ' $
283                      + 'time[*time]=timein:time_attr ' $
284                      + ' @ globattr'
285;
286@ncdf_quickwrite
287;
288end
Note: See TracBrowser for help on using the repository browser.