source: trunk/src/interp_erai_sst_1989_2009.pro @ 85

Last change on this file since 85 was 77, checked in by pinsard, 13 years ago

complete documentation

  • Property svn:keywords set to URL
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` 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 produced 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;
32;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc"];
33;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
34;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"];
35;
36;           interp_erai_sst_1989_2009 [shape=box,
37;           fontname=Courier,
38;           color=blue,
39;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_sst_1989_2009.pro",
40;           label="${PROJECT}/src/interp_erai_sst_1989_2009.pro"];
41;
42;           {file_in mask} -> {interp_erai_sst_1989_2009} -> {file_out}
43;
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; on cratos strange red data looking with ncview
74;
75; make it work : pb on loholt1 idl8::
76;
77;  sst[longitude,latitude,time]=sstkout:sstk_attr; longitude[]=lon:lon_attr; latitude[]=lat:lat_attr; time[*time]=timein:time_attr  @ globattr
78;  % NCDF_DIMDEF: 0 is not a valid cdfid.
79;  % Stop encountered: INTERP_ERAI_SST_1989_2009    1
80;     /home/pinsard/tropflux_ws/src/interp_erai_sst_1989_2009.pro
81;
82; but ok on loholt1 idl6
83;
84; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call
85;
86; coding rules
87;
88; use real output of :ref:`compute_erai_daily_region_2d.sh`.
89;
90; KNOWN ISSUES
91; ============
92;
93; test of existence of fullfilename_msk not very efficient because
94; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
95;
96; EVOLUTIONS
97; ==========
98;
99; $Id$
100;
101; $URL$
102;
103; - fplod 20110808T094156Z cratos (Linux)
104;
105;   * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call
106;
107; - pinsard 2011-07-04T15:45:35Z loholt1.ipsl.polytechnique.fr (Linux)
108;
109;   * usage of ${PROJECT_ID} and $PROJECT_OD
110;
111; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
112;
113;   * remove hard coded directory for mask_oaflux_30N30S.nc
114;
115; - fplod 20101215T100932Z aedon.locean-ipsl.upmc.fr (Darwin)
116;
117;   * add graph in header
118;
119; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
120;
121;   * minimal header
122;
123; - pbk 2008
124;
125;   * creation
126;
127;-
128pro interp_erai_sst_1989_2009
129;
130@cm_4cal
131@cm_4data
132@cm_4mesh
133@cm_4data
134@cm_project
135;
136; check for input directory
137;
138; test if ${PROJECT_ID} defined
139CASE project_id_env OF
140    ''  :  BEGIN
141     msg = 'eee : ${PROJECT_ID} is not defined'
142     ras = report(msg)
143     STOP
144           END
145 ELSE: BEGIN
146     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
147     ras = report(msg)
148       END
149ENDCASE
150;
151iodirin = isadirectory(project_id_env)
152;
153; existence and protection of ${PROJECT_ID}
154IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
155   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
156   ras = report(msg)
157   STOP
158ENDIF
159;
160; build mask filename
161filename_msk='mask_oaflux_30N30S.nc'
162;
163; check if this file exists
164fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
165IF fullfilename_msk[0] EQ '' THEN BEGIN
166   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
167   ras = report(msg)
168   STOP
169ENDIF
170;
171; build data filename
172filename='20c3m_erai_sstk_TROP_1989_2009.nc'
173;
174; check if this file exists
175fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST)
176IF fullfilename[0] EQ '' THEN BEGIN
177   msg = 'eee : the file ' + fullfilename + ' was not found.'
178   ras = report(msg)
179   STOP
180ENDIF
181;
182; test if ${PROJECT_OD} defined
183CASE project_od_env OF
184  '' : BEGIN
185         msg = 'eee : ${PROJECT_OD} is not defined'
186         ras = report(msg)
187       STOP
188       END
189  ELSE: BEGIN
190          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
191          ras = report(msg)
192        END
193 ENDCASE
194;
195; check if output data will be possible
196iodirout = isadirectory(project_od_env)
197;
198; existence and protection
199IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
200    msg = 'eee : the directory' + iodirout  + ' was not found.'
201    ras = report(msg)
202    STOP
203ENDIF
204;
205; build output filename
206filename_out = 'erai_sst_19890101_20091231_oafluxgrid.nc'
207fullfilename_out = iodirout + filename_out
208; in order to avoid unexpected overwritten
209IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
210   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
211   ras = report(msg)
212   STOP
213ENDIF
214;
215initncdf, fullfilename
216domdef
217latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
218print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
219print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
220sstkin=read_ncdf("sstk",19871201,20100930,file=fullfilename,/nostr)
221
222timein=time & jptin=jpt
223tab=sstkin(*,*,0)
224mskin=glamt*0.+1. & ind=where((tab eq 1.e9) or finite(tab,/nan)) & mskin(ind)=0.
225;mskin=glamt*0.+1.
226
227initncdf, fullfilename_msk
228domdef
229latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
230print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
231print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
232mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
233
234help, sstkin,lonin,latin,mskin,lonout,latout,mskout
235
236si=size(sstkin)
237sstkout=fltarr(jpi,jpj,jptin)
238for jt=0,jptin-1 do begin
239  print, 'Interpolation jt=',jt,' / ',jptin-1
240  tab=reform(sstkin(*,*,jt))
241  sstkout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $
242      , lonout,latout,method='bilinear' $
243      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
244  sstkout(*,*,jt)=sstkout(*,*,jt)*mskout+(1.-mskout)*1.e20
245endfor
246
247timein=timein & jptin=jpt
248
249initncdf, fullfilename_msk
250time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
251tt=time
252cda0=string(jul2date(time(0)),format='(i8.8)')
253cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
254timein=timein-julday(1,1,1950,00,00)
255
256lat=latout
257lon=lonout
258ncfile='!' + fullfilename_out
259lon_attr={units:'degrees_east',long_name:'Longitude'}
260lat_attr={units:'degrees_north',long_name:'Latitude'}
261time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
262sstk_attr={units:'degK',missing_value:1e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'}
263globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
264
265ncfields = 'sst[longitude,latitude,time]=sstkout:sstk_attr; ' $
266                      + 'longitude[]=lon:lon_attr; ' $
267                      + 'latitude[]=lat:lat_attr; ' $
268                      + 'time[*time]=timein:time_attr ' $
269                      + ' @ globattr'
270
271@ncdf_quickwrite
272
273end
Note: See TracBrowser for help on using the repository browser.