1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _interp_erai_dewt_1989_2009.pro: |
---|
4 | ; |
---|
5 | ; ============================== |
---|
6 | ; interp_erai_dewt_1989_2009.pro |
---|
7 | ; ============================== |
---|
8 | ; |
---|
9 | ; DESCRIPTION |
---|
10 | ; =========== |
---|
11 | ; |
---|
12 | ; Interpolation of d2 from ERA-I grid to OAFLUX grid |
---|
13 | ; |
---|
14 | ; :file:`${PROJECT_ID}/20c3m_erai_d2_TROP_1989_2009.nc` |
---|
15 | ; containing |
---|
16 | ; d2 from ERA-I |
---|
17 | ; has been produced by |
---|
18 | ; :ref:`compute_erai_daily_region_2d.sh`. |
---|
19 | ; |
---|
20 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` |
---|
21 | ; containing OAFLUX grid |
---|
22 | ; has been produced by |
---|
23 | ; :ref:`oaflux_mask_30N30S.pro`. |
---|
24 | ; |
---|
25 | ; Interpolated d2 |
---|
26 | ; is written in |
---|
27 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` |
---|
28 | ; if this file not already exists. |
---|
29 | ; |
---|
30 | ; This output file |
---|
31 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` |
---|
32 | ; must be processed after by |
---|
33 | ; :ref:`d2m_to_q2m_erai.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_dewt_1989_2009 { |
---|
44 | ; |
---|
45 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_d2_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_d2m_19890101_20091231_oafluxgrid.nc"]; |
---|
48 | ; |
---|
49 | ; interp_erai_dewt_1989_2009 [shape=box, |
---|
50 | ; fontname=Courier, |
---|
51 | ; color=blue, |
---|
52 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_dewt_1989_2009.pro", |
---|
53 | ; label="${PROJECT}/src/interp_erai_dewt_1989_2009.pro"]; |
---|
54 | ; |
---|
55 | ; {file_in mask} -> {interp_erai_dewt_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:`d2m_to_q2m_erai.pro` |
---|
76 | ; |
---|
77 | ; EXAMPLES |
---|
78 | ; ======== |
---|
79 | ; |
---|
80 | ; :: |
---|
81 | ; |
---|
82 | ; IDL> .compile file_interp |
---|
83 | ; IDL> interp_erai_dewt_1989_2009 |
---|
84 | ; |
---|
85 | ; TIPS |
---|
86 | ; ==== |
---|
87 | ; |
---|
88 | ; To see some values of variable :: |
---|
89 | ; |
---|
90 | ; $ ncks -v d2m -d time,0,1 -d latitude,0,1 -d longitude,0,1 \ |
---|
91 | ; $PROJECT_ID/erai_d2m_19890101_200 1231_oafluxgrid.nc |
---|
92 | ; |
---|
93 | ; TODO |
---|
94 | ; ==== |
---|
95 | ; |
---|
96 | ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call |
---|
97 | ; |
---|
98 | ; use real output of :ref:`compute_erai_daily_region_2d.sh`. |
---|
99 | ; |
---|
100 | ; coding rules |
---|
101 | ; |
---|
102 | ; KNOWN ISSUES |
---|
103 | ; ============ |
---|
104 | ; |
---|
105 | ; test of existence of fullfilename_msk not very efficient because |
---|
106 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
107 | ; |
---|
108 | ; EVOLUTIONS |
---|
109 | ; ========== |
---|
110 | ; |
---|
111 | ; $Id$ |
---|
112 | ; |
---|
113 | ; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_dewt_1989_2009.pro $ |
---|
114 | ; |
---|
115 | ; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
116 | ; |
---|
117 | ; * retry on loholt1 with idl8 and idl6 |
---|
118 | ; |
---|
119 | ; - fplod 20110808T094156Z cratos (Linux) |
---|
120 | ; |
---|
121 | ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call |
---|
122 | ; |
---|
123 | ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
124 | ; |
---|
125 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
126 | ; |
---|
127 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
128 | ; |
---|
129 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
130 | ; |
---|
131 | ; - fplod 20101215T093710Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
132 | ; |
---|
133 | ; * add graph in header |
---|
134 | ; |
---|
135 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
136 | ; |
---|
137 | ; * minimal header |
---|
138 | ; |
---|
139 | ; - pbk 2008 |
---|
140 | ; |
---|
141 | ; * creation |
---|
142 | ; |
---|
143 | ;- |
---|
144 | pro interp_erai_dewt_1989_2009 |
---|
145 | ; |
---|
146 | @cm_4cal |
---|
147 | @cm_4data |
---|
148 | @cm_4mesh |
---|
149 | @cm_4data |
---|
150 | @cm_project |
---|
151 | ; |
---|
152 | ; check for input directory |
---|
153 | ; |
---|
154 | ; test if ${PROJECT_ID} defined |
---|
155 | CASE project_id_env OF |
---|
156 | '' : BEGIN |
---|
157 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
158 | ras = report(msg) |
---|
159 | STOP |
---|
160 | END |
---|
161 | ELSE: BEGIN |
---|
162 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
163 | ras = report(msg) |
---|
164 | END |
---|
165 | ENDCASE |
---|
166 | ; |
---|
167 | iodirin = isadirectory(project_id_env) |
---|
168 | ; |
---|
169 | ; existence and protection of ${PROJECT_ID} |
---|
170 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
171 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
172 | ras = report(msg) |
---|
173 | STOP |
---|
174 | ENDIF |
---|
175 | ; |
---|
176 | ; build mask filename |
---|
177 | filename_msk='mask_oaflux_30N30S.nc' |
---|
178 | ; |
---|
179 | ; check if this file exists |
---|
180 | msg='iii : looking for ' + filename_msk |
---|
181 | ras = report(msg) |
---|
182 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
183 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
184 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
185 | ras = report(msg) |
---|
186 | STOP |
---|
187 | ENDIF |
---|
188 | ; |
---|
189 | ; build data filename |
---|
190 | filename='20c3m_erai_d2_TROP_1989_2009.nc' |
---|
191 | ; |
---|
192 | ; check if this file exists |
---|
193 | msg='iii : looking for ' + filename |
---|
194 | ras = report(msg) |
---|
195 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
196 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
197 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
198 | ras = report(msg) |
---|
199 | STOP |
---|
200 | ENDIF |
---|
201 | ; |
---|
202 | ; test if ${PROJECT_OD} defined |
---|
203 | CASE project_od_env OF |
---|
204 | '' : BEGIN |
---|
205 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
206 | ras = report(msg) |
---|
207 | STOP |
---|
208 | END |
---|
209 | ELSE: BEGIN |
---|
210 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
211 | ras = report(msg) |
---|
212 | END |
---|
213 | ENDCASE |
---|
214 | ; |
---|
215 | ; check if output data will be possible |
---|
216 | iodirout = isadirectory(project_od_env) |
---|
217 | ; |
---|
218 | ; existence and protection |
---|
219 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
220 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
221 | ras = report(msg) |
---|
222 | STOP |
---|
223 | ENDIF |
---|
224 | ; |
---|
225 | ; build output filename |
---|
226 | filename_out = 'erai_d2m_19890101_20091231_oafluxgrid.nc' |
---|
227 | fullfilename_out = iodirout + filename_out |
---|
228 | ; in order to avoid unexpected overwritten |
---|
229 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
230 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
231 | ras = report(msg) |
---|
232 | STOP |
---|
233 | ENDIF |
---|
234 | ; |
---|
235 | initncdf, fullfilename |
---|
236 | domdef |
---|
237 | latin=reform(gphit(0,*)) |
---|
238 | lonin=reform(glamt(*,0)) |
---|
239 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
240 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
241 | d2min=read_ncdf("d2",19881201,20101231,file=fullfilename,/nostr) |
---|
242 | ; |
---|
243 | jptin=jpt |
---|
244 | tab=d2min(*,*,0) |
---|
245 | mskin=glamt*0.+1. |
---|
246 | ; |
---|
247 | initncdf, fullfilename_msk |
---|
248 | domdef |
---|
249 | latout=reform(gphit(0,*)) |
---|
250 | lonout=reform(glamt(*,0)) |
---|
251 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
252 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
253 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
254 | ; |
---|
255 | help, d2min,lonin,latin,mskin,lonout,latout,mskout |
---|
256 | ; |
---|
257 | d2mout=fltarr(jpi,jpj,jptin) |
---|
258 | for jt=0,jptin-1 do begin |
---|
259 | ; ++ print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
260 | tab=reform(d2min(*,*,jt)) |
---|
261 | d2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
262 | , lonout,latout,method='bilinear' $ |
---|
263 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
264 | d2mout(*,*,jt)=d2mout(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
265 | endfor |
---|
266 | ; |
---|
267 | initncdf, fullfilename_msk |
---|
268 | ; |
---|
269 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
270 | jpt=n_elements(time) |
---|
271 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
272 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
273 | time=time-julday(1,1,1950,00,00) |
---|
274 | ; |
---|
275 | lat=latout |
---|
276 | lon=lonout |
---|
277 | ncfile='!' + fullfilename_out |
---|
278 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
279 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
280 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
281 | globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1} |
---|
282 | d2m_attr={units:'degK',missing_value:1e20,long_name:'Dew Point Temperature at 2m',short_name:'d2m',axis:'TYX'} |
---|
283 | ; |
---|
284 | ncfields = 'd2m[longitude,latitude,time]=d2mout:d2m_attr; ' $ |
---|
285 | + 'longitude[]=lon:lon_attr; ' $ |
---|
286 | + 'latitude[]=lat:lat_attr; ' $ |
---|
287 | + 'time[*time]=time:time_attr ' $ |
---|
288 | + ' @ globattr' |
---|
289 | ; |
---|
290 | @ncdf_quickwrite |
---|
291 | ; |
---|
292 | end |
---|