1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _interp_erai_dewt_1989_2009.pro: |
---|
4 | ; |
---|
5 | ; ============================================================================== |
---|
6 | ; interp_erai_dewt_1989_2009.pro - Interpolation of d2 from ERA-I grid to OAFLUX |
---|
7 | ; ============================================================================== |
---|
8 | ; |
---|
9 | ; Interpolation of d2 from ERA-I grid to OAFLUX grid |
---|
10 | ; |
---|
11 | ; :file:`${PROJECT_ID}/20c3m_erai_d2_TROP_1989_2009.nc` containing d2 from ERA-I have been produced |
---|
12 | ; by :ref:`compute_erai_daily_region_2d.sh`. |
---|
13 | ; |
---|
14 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`. |
---|
15 | ; |
---|
16 | ; Interpolated d2 is written in |
---|
17 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` if this file not already exists. |
---|
18 | ; |
---|
19 | ; This output file :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`d2m_to_q2m.pro`. |
---|
20 | ; |
---|
21 | ; .. graphviz:: |
---|
22 | ; |
---|
23 | ; digraph interp_erai_dewt_1989_2009 { |
---|
24 | ; graph [ |
---|
25 | ; rankdir="LR", |
---|
26 | ; ] |
---|
27 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_d2_TROP_1989_2009.nc"]; |
---|
28 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
29 | ; |
---|
30 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc"]; |
---|
31 | ; interp_erai_dewt_1989_2009 [shape=box, |
---|
32 | ; fontname=Courier, |
---|
33 | ; color=blue, |
---|
34 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_dewt_1989_2009.pro", |
---|
35 | ; label="${PROJECT}/src/interp_erai_dewt_1989_2009.pro"]; |
---|
36 | ; |
---|
37 | ; {file_in mask} -> {interp_erai_dewt_1989_2009} -> {file_out} |
---|
38 | ; |
---|
39 | ; } |
---|
40 | ; |
---|
41 | ; SEE ALSO |
---|
42 | ; ======== |
---|
43 | ; |
---|
44 | ; :ref:`project_profile.sh` |
---|
45 | ; |
---|
46 | ; :func:`report <saxo:report>` |
---|
47 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
48 | ; :func:`isafile <saxo:isafile>` |
---|
49 | ; :func:`initncdf <saxo:initncdf>` |
---|
50 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
51 | ; :func:`domdef <saxo:domdef>` |
---|
52 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
53 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
54 | ; |
---|
55 | ; :ref:`d2m_to_q2m.pro` |
---|
56 | ; |
---|
57 | ; EXAMPLES |
---|
58 | ; ======== |
---|
59 | ; |
---|
60 | ; :: |
---|
61 | ; |
---|
62 | ; IDL> .compile file_interp |
---|
63 | ; IDL> interp_erai_dewt_1989_2009 |
---|
64 | ; |
---|
65 | ; TODO |
---|
66 | ; ==== |
---|
67 | ; |
---|
68 | ; make it work : pb on loholt1:: |
---|
69 | ; |
---|
70 | ; Variable is undefined: OUTMASK_IND. |
---|
71 | ; |
---|
72 | ; coding rules |
---|
73 | ; |
---|
74 | ; KNOWN ISSUES |
---|
75 | ; ============ |
---|
76 | ; |
---|
77 | ; test of existence of fullfilename_msk not very efficient because |
---|
78 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
79 | ; |
---|
80 | ; EVOLUTIONS |
---|
81 | ; ========== |
---|
82 | ; |
---|
83 | ; $Id$ |
---|
84 | ; |
---|
85 | ; $URL$ |
---|
86 | ; |
---|
87 | ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
88 | ; |
---|
89 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
90 | ; |
---|
91 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
92 | ; |
---|
93 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
94 | ; |
---|
95 | ; - fplod 20101215T093710Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
96 | ; |
---|
97 | ; * add graph in header |
---|
98 | ; |
---|
99 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
100 | ; |
---|
101 | ; * minimal header |
---|
102 | ; |
---|
103 | ; - pbk 2008 |
---|
104 | ; |
---|
105 | ; * creation |
---|
106 | ; |
---|
107 | ;- |
---|
108 | pro interp_erai_dewt_1989_2009 |
---|
109 | ; |
---|
110 | @cm_4cal |
---|
111 | @cm_4data |
---|
112 | @cm_4mesh |
---|
113 | @cm_4data |
---|
114 | @cm_project |
---|
115 | ; |
---|
116 | ; check for input directory |
---|
117 | ; |
---|
118 | ; test if ${PROJECT_ID} defined |
---|
119 | CASE project_id_env OF |
---|
120 | '' : BEGIN |
---|
121 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
122 | ras = report(msg) |
---|
123 | STOP |
---|
124 | END |
---|
125 | ELSE: BEGIN |
---|
126 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
127 | ras = report(msg) |
---|
128 | END |
---|
129 | ENDCASE |
---|
130 | ; |
---|
131 | iodirin = isadirectory(project_id_env) |
---|
132 | ; |
---|
133 | ; existence and protection of ${PROJECT_ID} |
---|
134 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
135 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
136 | ras = report(msg) |
---|
137 | STOP |
---|
138 | ENDIF |
---|
139 | ; |
---|
140 | ; build mask filename |
---|
141 | filename_msk='mask_oaflux_30N30S.nc' |
---|
142 | ; |
---|
143 | ; check if this file exists |
---|
144 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
145 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
146 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
147 | ras = report(msg) |
---|
148 | STOP |
---|
149 | ENDIF |
---|
150 | ; |
---|
151 | ; build data filename |
---|
152 | filename='20c3m_erai_d2_TROP_1989_2009.nc' |
---|
153 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
154 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
155 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
156 | ras = report(msg) |
---|
157 | STOP |
---|
158 | ENDIF |
---|
159 | ; |
---|
160 | ; |
---|
161 | ; test if ${PROJECT_OD} defined |
---|
162 | CASE project_od_env OF |
---|
163 | '' : BEGIN |
---|
164 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
165 | ras = report(msg) |
---|
166 | STOP |
---|
167 | END |
---|
168 | ELSE: BEGIN |
---|
169 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
170 | ras = report(msg) |
---|
171 | END |
---|
172 | ENDCASE |
---|
173 | ; |
---|
174 | ; check if output data will be possible |
---|
175 | iodirout = isadirectory(project_od_env) |
---|
176 | ; |
---|
177 | ; existence and protection |
---|
178 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
179 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
180 | ras = report(msg) |
---|
181 | STOP |
---|
182 | ENDIF |
---|
183 | ; |
---|
184 | ; build output filename |
---|
185 | filename_out = 'erai_d2m_19890101_20091231_oafluxgrid.nc' |
---|
186 | fullfilename_out = iodirout + filename_out |
---|
187 | ; in order to avoid unexpected overwritten |
---|
188 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
189 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
190 | ras = report(msg) |
---|
191 | STOP |
---|
192 | ENDIF |
---|
193 | ; |
---|
194 | initncdf, fullfilename |
---|
195 | domdef |
---|
196 | latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0)) |
---|
197 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
198 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
199 | d2min=read_ncdf("d2",19881201,20101231,file=fullfilename,/nostr) |
---|
200 | |
---|
201 | timein=time & jptin=jpt |
---|
202 | tab=d2min(*,*,0) |
---|
203 | mskin=glamt*0.+1. |
---|
204 | |
---|
205 | initncdf, fullfilename_msk |
---|
206 | domdef |
---|
207 | latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0)) |
---|
208 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
209 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
210 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
211 | |
---|
212 | help, d2min,lonin,latin,mskin,lonout,latout,mskout |
---|
213 | |
---|
214 | si=size(d2min) |
---|
215 | d2mout=fltarr(jpi,jpj,jptin) |
---|
216 | for jt=0,jptin-1 do begin |
---|
217 | print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
218 | tab=reform(d2min(*,*,jt)) |
---|
219 | d2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear') |
---|
220 | d2mout(*,*,jt)=d2mout(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
221 | endfor |
---|
222 | |
---|
223 | |
---|
224 | timein=timein & jptin=jpt |
---|
225 | |
---|
226 | initncdf, fullfilename_msk |
---|
227 | cda0=string(jul2date(timein(0)),format='(i8.8)') |
---|
228 | cda1=string(jul2date(timein(jpt-1)),format='(i8.8)') |
---|
229 | |
---|
230 | time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) |
---|
231 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
232 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
233 | timein=time-julday(1,1,1950,00,00) |
---|
234 | |
---|
235 | lat=latout |
---|
236 | lon=lonout |
---|
237 | ncfile='!' + fullfilename_out |
---|
238 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
239 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
240 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} |
---|
241 | d2m_attr={units:'degK',missing_value:1e20,long_name:'Dew Point Temperature at 2m',short_name:'d2m',axis:'TYX'} |
---|
242 | globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1} |
---|
243 | |
---|
244 | |
---|
245 | ncfields = 'd2m[longitude,latitude,time]=d2mout:d2m_attr; ' $ |
---|
246 | + 'longitude[]=lon:lon_attr; ' $ |
---|
247 | + 'latitude[]=lat:lat_attr; ' $ |
---|
248 | + 'time[*time]=timein:time_attr ' $ |
---|
249 | + ' @ globattr' |
---|
250 | |
---|
251 | @ncdf_quickwrite |
---|
252 | |
---|
253 | |
---|
254 | end |
---|