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