source: trunk/src/interp_erai_sst_1989_2009.pro @ 50

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

replace TROPFLUX by PROJECT

File size: 5.0 KB
Line 
1;+
2;
3; .. _interp_erai_sst_1989_2009.pro:
4;
5; =============================
6; interp_erai_sst_1989_2009.pro
7; =============================
8;
9;     .. graphviz::
10;
11;        digraph interp_erai_sst_1989_2009 {
12;           graph [
13;           rankdir="LR",
14;           ]
15;           file_in [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/ERAI_global/20c3m_erai_sstk_TROP_1989_2009.nc"];
16;
17;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
18;
19;           ncfile [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_sst_19890101_20091231_oafluxgrid.nc"];
20;
21;           interp_erai_sst_1989_2009 [shape=box,
22;           fontname=Courier,
23;           color=blue,
24;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_sst_1989_2009.pro",
25;           label="${PROJECT}/src/interp_erai_sst_1989_2009.pro"];
26;
27;           {file_in mask} -> {interp_erai_sst_1989_2009} -> {ncfile}
28;          }
29;
30; SEE ALSO
31; ========
32;
33; :ref:`project_profile.sh`
34;
35; :func:`report <saxo:report>`
36; :func:`isadirectory <saxo:isadirectory>`
37; :func:`isafile <saxo:isafile>`
38; :func:`initncdf <saxo:initncdf>`
39; :func:`read_ncdf <saxo:read_ncdf>`
40; :func:`domdef <saxo:domdef>`
41; :func:`call_interp2d <saxo:call_interp2d>`
42; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
43;
44; EXAMPLES
45; ========
46;
47; ::
48;
49;  IDL> interp_erai_sst_1989_2009
50;
51; TODO
52; ====
53;
54; hard coded directory - usage of ${PROJECT_ID}
55;
56; coding rules
57;
58; KNOWN ISSUES
59; ============
60;
61; test of existence of fullfilename_msk not very efficient because
62; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
63;
64; EVOLUTIONS
65; ==========
66;
67; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
68;
69;   * remove hard coded directory for mask_oaflux_30N30S.nc
70;
71; - fplod 20101215T100932Z aedon.locean-ipsl.upmc.fr (Darwin)
72;
73;   * add graph in header
74;
75; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
76;
77;   * minimal header
78;
79; - pbk 2008
80;
81;
82;   * creation
83;
84;-
85pro interp_erai_sst_1989_2009
86@common
87@cm_project
88;
89; check for input directory
90;
91; test if ${PROJECT_ID} defined
92CASE project_id_env OF
93    ''  :  BEGIN
94     msg = 'eee : ${PROJECT_ID} is not defined'
95     ras = report(msg)
96     STOP
97           END
98 ELSE: BEGIN
99     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
100     ras = report(msg)
101       END
102ENDCASE
103;
104iodirin = isadirectory(project_id_env)
105;
106; existence and protection of ${PROJECT_ID}
107IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
108   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
109   ras = report(msg)
110   STOP
111ENDIF
112;
113; build mask filename
114filename_msk='mask_oaflux_30N30S.nc'
115;
116; check if this file exists
117fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
118IF fullfilename_msk[0] EQ '' THEN BEGIN
119   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
120   ras = report(msg)
121   STOP
122ENDIF
123
124filein='/Volumes/PRAVEEN/ERAI_global/20c3m_erai_sstk_TROP_1989_2009.nc'
125
126initncdf, filein
127domdef
128latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
129print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
130print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
131sstkin=read_ncdf("sstk",19871201,20100930,file=filein,/nostr)
132
133timein=time & jptin=jpt
134tab=sstkin(*,*,0)
135mskin=glamt*0.+1. & ind=where((tab eq 1.e9) or finite(tab,/nan)) & mskin(ind)=0.
136;mskin=glamt*0.+1.
137
138initncdf, fullfilename_msk
139domdef
140latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
141print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
142print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
143mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
144;stop
145help, sstkin,lonin,latin,mskin,lonout,latout,mskout
146
147si=size(sstkin)
148sstkout=fltarr(jpi,jpj,jptin)
149for jt=0,jptin-1 do begin
150  print, 'Interpolation jt=',jt,' / ',jptin-1
151  tab=reform(sstkin(*,*,jt))
152  sstkout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
153  sstkout(*,*,jt)=sstkout(*,*,jt)*mskout+(1.-mskout)*1.e20
154endfor
155
156
157timein=timein & jptin=jpt
158
159initncdf, fullfilename_msk
160time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
161tt=time
162cda0=string(jul2date(time(0)),format='(i8.8)')
163cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
164timein=timein-julday(1,1,1950,00,00)
165
166lat=latout
167lon=lonout
168ncfile='/Volumes/PRAVEEN/TropFlux/input_uncor/erai_sst_19890101_20091231_oafluxgrid.nc'
169lon_attr={units:'degrees_east',long_name:'Longitude'}
170lat_attr={units:'degrees_north',long_name:'Latitude'}
171time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
172sstk_attr={units:'degK',missing_value:1e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'}
173globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1}
174
175
176ncfields = 'sst[longitude,latitude,time]=sstkout:sstk_attr; ' $
177                      + 'longitude[]=lon:lon_attr; ' $
178                      + 'latitude[]=lat:lat_attr; ' $
179                      + 'time[*time]=timein:time_attr ' $
180                      + ' @ globattr'
181
182@ncdf_quickwrite
183
184
185end
Note: See TracBrowser for help on using the repository browser.