source: trunk/src/interp_erai_sst_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.0 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` containing sst 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 p roduced by :ref:`oaflux_mask_30N30S.pro`.
18;
19; Interpolated sst is written in
20; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc` if this file not already exists.
21;
22; This output file :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`sst_correction_ncdf.pro`.
23;
24;
25;     .. graphviz::
26;
27;        digraph interp_erai_sst_1989_2009 {
28;           graph [
29;           rankdir="LR",
30;           ]
31;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc"];
32;
33;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
34;
35;           ncfile [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"];
36;
37;           interp_erai_sst_1989_2009 [shape=box,
38;           fontname=Courier,
39;           color=blue,
40;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_sst_1989_2009.pro",
41;           label="${PROJECT}/src/interp_erai_sst_1989_2009.pro"];
42;
43;           {file_in mask} -> {interp_erai_sst_1989_2009} -> {ncfile}
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:`sst_correction_ncdf.pro`
61;
62; EXAMPLES
63; ========
64;
65; ::
66;
67;  IDL> .compile file_interp
68;  IDL> interp_erai_sst_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; use real output of :ref:`compute_erai_daily_region_2d.sh`.
80;
81; KNOWN ISSUES
82; ============
83;
84; test of existence of fullfilename_msk not very efficient because
85; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
86;
87; EVOLUTIONS
88; ==========
89;
90; $Id$
91;
92; $URL$
93;
94; - pinsard 2011-07-04T15:45:35Z loholt1.ipsl.polytechnique.fr (Linux)
95;
96;   * usage of ${PROJECT_ID} and $PROJECT_OD
97;
98; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
99;
100;   * remove hard coded directory for mask_oaflux_30N30S.nc
101;
102; - fplod 20101215T100932Z aedon.locean-ipsl.upmc.fr (Darwin)
103;
104;   * add graph in header
105;
106; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
107;
108;   * minimal header
109;
110; - pbk 2008
111;
112;   * creation
113;
114;-
115pro interp_erai_sst_1989_2009
116;
117@cm_4cal
118@cm_4data
119@cm_4mesh
120@cm_4data
121@cm_project
122;
123; check for input directory
124;
125; test if ${PROJECT_ID} defined
126CASE project_id_env OF
127    ''  :  BEGIN
128     msg = 'eee : ${PROJECT_ID} is not defined'
129     ras = report(msg)
130     STOP
131           END
132 ELSE: BEGIN
133     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
134     ras = report(msg)
135       END
136ENDCASE
137;
138iodirin = isadirectory(project_id_env)
139;
140; existence and protection of ${PROJECT_ID}
141IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
142   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
143   ras = report(msg)
144   STOP
145ENDIF
146;
147; build mask filename
148filename_msk='mask_oaflux_30N30S.nc'
149;
150; check if this file exists
151fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
152IF fullfilename_msk[0] EQ '' THEN BEGIN
153   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
154   ras = report(msg)
155   STOP
156ENDIF
157;
158; build data filename
159filename='20c3m_erai_sstk_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_sst_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
203domdef
204latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
205print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
206print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
207sstkin=read_ncdf("sstk",19871201,20100930,file=fullfilename,/nostr)
208
209timein=time & jptin=jpt
210tab=sstkin(*,*,0)
211mskin=glamt*0.+1. & ind=where((tab eq 1.e9) or finite(tab,/nan)) & mskin(ind)=0.
212;mskin=glamt*0.+1.
213
214initncdf, fullfilename_msk
215domdef
216latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
217print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
218print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
219mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
220;stop
221help, sstkin,lonin,latin,mskin,lonout,latout,mskout
222
223si=size(sstkin)
224sstkout=fltarr(jpi,jpj,jptin)
225for jt=0,jptin-1 do begin
226  print, 'Interpolation jt=',jt,' / ',jptin-1
227  tab=reform(sstkin(*,*,jt))
228  sstkout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
229  sstkout(*,*,jt)=sstkout(*,*,jt)*mskout+(1.-mskout)*1.e20
230endfor
231
232
233timein=timein & jptin=jpt
234
235initncdf, fullfilename_msk
236time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
237tt=time
238cda0=string(jul2date(time(0)),format='(i8.8)')
239cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
240timein=timein-julday(1,1,1950,00,00)
241
242lat=latout
243lon=lonout
244ncfile='!' + fullfilename_out
245lon_attr={units:'degrees_east',long_name:'Longitude'}
246lat_attr={units:'degrees_north',long_name:'Latitude'}
247time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
248sstk_attr={units:'degK',missing_value:1e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'}
249globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
250
251
252ncfields = 'sst[longitude,latitude,time]=sstkout:sstk_attr; ' $
253                      + 'longitude[]=lon:lon_attr; ' $
254                      + 'latitude[]=lat:lat_attr; ' $
255                      + 'time[*time]=timein:time_attr ' $
256                      + ' @ globattr'
257
258@ncdf_quickwrite
259
260
261end
Note: See TracBrowser for help on using the repository browser.