[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _interp_erai_ws_1989_2009.pro: |
---|
| 4 | ; |
---|
[67] | 5 | ; ============================ |
---|
| 6 | ; interp_erai_ws_1989_2009.pro |
---|
| 7 | ; ============================ |
---|
[9] | 8 | ; |
---|
[67] | 9 | ; DESCRIPTION |
---|
| 10 | ; =========== |
---|
| 11 | ; |
---|
[66] | 12 | ; Interpolation of u10 and v10 from ERA-I grid to OAFLUX grid |
---|
| 13 | ; |
---|
[92] | 14 | ; :file:`${PROJECT_ID}/20c3m_erai_u10_TROP_1989_2009.nc` |
---|
| 15 | ; containing |
---|
| 16 | ; u10 from ERA-I |
---|
[93] | 17 | ; has been produced by |
---|
[92] | 18 | ; :ref:`compute_erai_daily_region_2d.sh`. |
---|
[66] | 19 | ; |
---|
[92] | 20 | ; :file:`${PROJECT_ID}/20c3m_erai_v10_TROP_1989_2009.nc` |
---|
| 21 | ; containing |
---|
| 22 | ; v10 from ERA-I |
---|
[93] | 23 | ; has been produced by |
---|
[92] | 24 | ; :ref:`compute_erai_daily_region_2d.sh`. |
---|
[66] | 25 | ; |
---|
[92] | 26 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` |
---|
| 27 | ; containing OAFLUX grid |
---|
[93] | 28 | ; has been produced by |
---|
[153] | 29 | ; :func:`oaflux_mask_30n30s.pro`. |
---|
[66] | 30 | ; |
---|
[92] | 31 | ; Interpolated u10 and v10 are written in |
---|
| 32 | ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` |
---|
| 33 | ; if this file not already exists. |
---|
[66] | 34 | ; |
---|
[92] | 35 | ; This output file |
---|
| 36 | ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` |
---|
| 37 | ; must be processed after by |
---|
| 38 | ; :ref:`ws_correction_ncdf.pro`. |
---|
[66] | 39 | ; |
---|
[92] | 40 | ; .. only:: man |
---|
| 41 | ; |
---|
| 42 | ; Figure is visible on PDF and HTML documents only. |
---|
| 43 | ; |
---|
| 44 | ; .. only:: html or latex |
---|
| 45 | ; |
---|
[9] | 46 | ; .. graphviz:: |
---|
| 47 | ; |
---|
| 48 | ; digraph interp_erai_ws_1989_2009 { |
---|
[71] | 49 | ; |
---|
[66] | 50 | ; file_u10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_u10_TROP_1989_2009.nc"]; |
---|
| 51 | ; file_v10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_v10_TROP_1989_2009.nc"]; |
---|
[50] | 52 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
[71] | 53 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"]; |
---|
[9] | 54 | ; |
---|
| 55 | ; interp_erai_ws_1989_2009 [shape=box, |
---|
| 56 | ; fontname=Courier, |
---|
| 57 | ; color=blue, |
---|
| 58 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_ws_1989_2009.pro", |
---|
[50] | 59 | ; label="${PROJECT}/src/interp_erai_ws_1989_2009.pro"]; |
---|
[9] | 60 | ; |
---|
[71] | 61 | ; {file_u10 file_v10 mask} -> {interp_erai_ws_1989_2009} -> {file_out} |
---|
[9] | 62 | ; |
---|
[100] | 63 | ; } |
---|
[9] | 64 | ; |
---|
[6] | 65 | ; SEE ALSO |
---|
| 66 | ; ======== |
---|
| 67 | ; |
---|
[92] | 68 | ; :ref:`interpolate_data` |
---|
| 69 | ; |
---|
[50] | 70 | ; :ref:`project_profile.sh` |
---|
[19] | 71 | ; |
---|
[20] | 72 | ; :func:`report <saxo:report>` |
---|
| 73 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
| 74 | ; :func:`isafile <saxo:isafile>` |
---|
| 75 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 76 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 77 | ; :func:`domdef <saxo:domdef>` |
---|
| 78 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
| 79 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 80 | ; |
---|
[66] | 81 | ; :ref:`ws_correction_ncdf.pro` |
---|
| 82 | ; |
---|
[6] | 83 | ; EXAMPLES |
---|
| 84 | ; ======== |
---|
| 85 | ; |
---|
| 86 | ; :: |
---|
| 87 | ; |
---|
[66] | 88 | ; IDL> .compile file_interp |
---|
[6] | 89 | ; IDL> interp_erai_ws_1989_2009 |
---|
| 90 | ; |
---|
| 91 | ; TODO |
---|
| 92 | ; ==== |
---|
| 93 | ; |
---|
[93] | 94 | ; make it work : pb on loholt1 idl8 |
---|
[6] | 95 | ; |
---|
[93] | 96 | ; reach end but bad values et nb timestep 4581:: |
---|
[66] | 97 | ; |
---|
[97] | 98 | ; ncks -v u10 -d time,0,1 -d latitude,0,1 -d longitude,0,1 /homedata/pinsard/tropflux_d/erai_ws_19890101_20091231_oafluxgrid.nc |
---|
[93] | 99 | ; latitude[0]=-29.5 degrees_north |
---|
| 100 | ; latitude[1]=-28.5 degrees_north |
---|
[97] | 101 | ; |
---|
[93] | 102 | ; longitude[0]=30.5 degrees_east |
---|
| 103 | ; longitude[1]=31.5 degrees_east |
---|
[97] | 104 | ; |
---|
[93] | 105 | ; time[0] latitude[0]=-29.5 longitude[0]=30.5 u10[0]=9.96921e+36 m/s |
---|
| 106 | ; time[0] latitude[0]=-29.5 longitude[1]=31.5 u10[1]=9.96921e+36 m/s |
---|
| 107 | ; time[0] latitude[1]=-28.5 longitude[0]=30.5 u10[350]=9.96921e+36 m/s |
---|
| 108 | ; time[0] latitude[1]=-28.5 longitude[1]=31.5 u10[351]=9.96921e+36 m/s |
---|
| 109 | ; time[1] latitude[0]=-29.5 longitude[0]=30.5 u10[21000]=9.96921e+36 m/s |
---|
| 110 | ; time[1] latitude[0]=-29.5 longitude[1]=31.5 u10[21001]=9.96921e+36 m/s |
---|
| 111 | ; time[1] latitude[1]=-28.5 longitude[0]=30.5 u10[21350]=9.96921e+36 m/s |
---|
| 112 | ; time[1] latitude[1]=-28.5 longitude[1]=31.5 u10[21351]=9.96921e+36 m/s |
---|
| 113 | ; |
---|
[73] | 114 | ; make it work : pb on loholt1 idl6:: |
---|
| 115 | ; |
---|
[92] | 116 | ; Writing fields: |
---|
[73] | 117 | ; u10[longitude,latitude,time]=u10out:u10_attr; v10[longitude,latitude,time]=v10out:v10_attr; longitude[]=xlon:lon_attr; latitude[]=ylat:lat_attr; tt[*time]=tt:time_attr @ globattr |
---|
| 118 | ; % NCDF_VARPUT: Operation Failed, bad file (6) or variable (0) id ? |
---|
| 119 | ; (NC_ERROR=-31) |
---|
| 120 | ; % Stop encountered: INTERP_ERAI_WS_1989_2009 1 |
---|
| 121 | ; |
---|
[70] | 122 | ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call |
---|
| 123 | ; |
---|
| 124 | ; use real output of :ref:`compute_erai_daily_region_2d.sh`. |
---|
| 125 | ; |
---|
[6] | 126 | ; coding rules |
---|
| 127 | ; |
---|
[19] | 128 | ; KNOWN ISSUES |
---|
| 129 | ; ============ |
---|
| 130 | ; |
---|
| 131 | ; test of existence of fullfilename_msk not very efficient because |
---|
| 132 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 133 | ; |
---|
[6] | 134 | ; EVOLUTIONS |
---|
| 135 | ; ========== |
---|
| 136 | ; |
---|
[66] | 137 | ; $Id$ |
---|
| 138 | ; |
---|
[88] | 139 | ; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_ws_1989_2009.pro $ |
---|
[66] | 140 | ; |
---|
[98] | 141 | ; - fplod 20110830T135212Z cratos (Linux) |
---|
| 142 | ; |
---|
| 143 | ; * replace tt by time |
---|
| 144 | ; |
---|
[92] | 145 | ; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
| 146 | ; |
---|
| 147 | ; * retry on loholt1 with idl8 and idl6 |
---|
| 148 | ; |
---|
[70] | 149 | ; - fplod 20110808T094156Z cratos (Linux) |
---|
| 150 | ; |
---|
| 151 | ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call |
---|
| 152 | ; |
---|
[66] | 153 | ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
| 154 | ; |
---|
| 155 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
| 156 | ; |
---|
[19] | 157 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 158 | ; |
---|
| 159 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
| 160 | ; |
---|
[9] | 161 | ; - fplod 20101215T112657Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 162 | ; |
---|
| 163 | ; * add graph in header |
---|
| 164 | ; |
---|
[6] | 165 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 166 | ; |
---|
| 167 | ; * minimal header |
---|
| 168 | ; |
---|
| 169 | ; - pbk 2008 |
---|
| 170 | ; |
---|
| 171 | ; * creation |
---|
| 172 | ; |
---|
| 173 | ;- |
---|
[5] | 174 | pro interp_erai_ws_1989_2009 |
---|
[66] | 175 | ; |
---|
| 176 | @cm_4cal |
---|
| 177 | @cm_4data |
---|
| 178 | @cm_4mesh |
---|
| 179 | @cm_4data |
---|
[50] | 180 | @cm_project |
---|
[19] | 181 | ; |
---|
[20] | 182 | ; check for input directory |
---|
[19] | 183 | ; |
---|
[50] | 184 | ; test if ${PROJECT_ID} defined |
---|
| 185 | CASE project_id_env OF |
---|
[19] | 186 | '' : BEGIN |
---|
[50] | 187 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
[19] | 188 | ras = report(msg) |
---|
| 189 | STOP |
---|
| 190 | END |
---|
| 191 | ELSE: BEGIN |
---|
[50] | 192 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
[19] | 193 | ras = report(msg) |
---|
| 194 | END |
---|
| 195 | ENDCASE |
---|
| 196 | ; |
---|
[50] | 197 | iodirin = isadirectory(project_id_env) |
---|
[19] | 198 | ; |
---|
[50] | 199 | ; existence and protection of ${PROJECT_ID} |
---|
[19] | 200 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 201 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
| 202 | ras = report(msg) |
---|
| 203 | STOP |
---|
| 204 | ENDIF |
---|
| 205 | ; |
---|
| 206 | ; build mask filename |
---|
| 207 | filename_msk='mask_oaflux_30N30S.nc' |
---|
| 208 | ; |
---|
| 209 | ; check if this file exists |
---|
[92] | 210 | msg='iii : looking for ' + filename_msk |
---|
| 211 | ras = report(msg) |
---|
[19] | 212 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
| 213 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
| 214 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
| 215 | ras = report(msg) |
---|
| 216 | STOP |
---|
| 217 | ENDIF |
---|
[66] | 218 | ; |
---|
[97] | 219 | st=19880101 |
---|
[94] | 220 | en=20100930 |
---|
[66] | 221 | ; |
---|
| 222 | ; build u10 data filename |
---|
| 223 | filename='20c3m_erai_u10_TROP_1989_2009.nc' |
---|
| 224 | ; |
---|
| 225 | ; check if this file exists |
---|
[92] | 226 | msg='iii : looking for ' + filename |
---|
| 227 | ras = report(msg) |
---|
[66] | 228 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
| 229 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 230 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 231 | ras = report(msg) |
---|
| 232 | STOP |
---|
| 233 | ENDIF |
---|
| 234 | ; |
---|
| 235 | ; test if ${PROJECT_OD} defined |
---|
| 236 | CASE project_od_env OF |
---|
| 237 | '' : BEGIN |
---|
| 238 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 239 | ras = report(msg) |
---|
| 240 | STOP |
---|
| 241 | END |
---|
| 242 | ELSE: BEGIN |
---|
| 243 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 244 | ras = report(msg) |
---|
| 245 | END |
---|
| 246 | ENDCASE |
---|
| 247 | ; |
---|
| 248 | ; check if output data will be possible |
---|
| 249 | iodirout = isadirectory(project_od_env) |
---|
| 250 | ; |
---|
| 251 | ; existence and protection |
---|
| 252 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 253 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 254 | ras = report(msg) |
---|
| 255 | STOP |
---|
| 256 | ENDIF |
---|
| 257 | ; |
---|
| 258 | ; build output filename |
---|
| 259 | filename_out = 'erai_ws_19890101_20091231_oafluxgrid.nc' |
---|
| 260 | fullfilename_out = iodirout + filename_out |
---|
| 261 | ; in order to avoid unexpected overwritten |
---|
| 262 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 263 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 264 | ras = report(msg) |
---|
| 265 | STOP |
---|
| 266 | ENDIF |
---|
| 267 | ; |
---|
| 268 | initncdf, fullfilename |
---|
| 269 | u10in=read_ncdf("u10",st, en,file=fullfilename,/nostr) |
---|
[97] | 270 | ; |
---|
[66] | 271 | ; build v10 data filename |
---|
| 272 | filename='20c3m_erai_v10_TROP_1989_2009.nc' |
---|
| 273 | ; |
---|
| 274 | ; check if this file exists |
---|
[92] | 275 | msg='iii : looking for ' + filename |
---|
| 276 | ras = report(msg) |
---|
[66] | 277 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
| 278 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 279 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 280 | ras = report(msg) |
---|
| 281 | STOP |
---|
| 282 | ENDIF |
---|
| 283 | initncdf, fullfilename |
---|
| 284 | v10in=read_ncdf("v10",st, en,file=fullfilename,/nostr) |
---|
[97] | 285 | ; |
---|
[66] | 286 | initncdf, fullfilename |
---|
[5] | 287 | domdef |
---|
[97] | 288 | latin=reform(gphit(0,*)) |
---|
[94] | 289 | lonin=reform(glamt(*,0)) |
---|
[5] | 290 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
| 291 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
[97] | 292 | ; |
---|
| 293 | timein=time |
---|
[94] | 294 | jptin=jpt |
---|
[5] | 295 | tab=u10in(*,*,0) |
---|
| 296 | mskin=glamt*0.+1. |
---|
[97] | 297 | ; |
---|
[19] | 298 | initncdf, fullfilename_msk |
---|
[5] | 299 | domdef |
---|
[97] | 300 | latout=reform(gphit(0,*)) |
---|
[94] | 301 | lonout=reform(glamt(*,0)) |
---|
[5] | 302 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
| 303 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
[19] | 304 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
[97] | 305 | ; |
---|
[5] | 306 | help, u10in, v10in,lonin,latin,mskin,lonout,latout,mskout |
---|
[97] | 307 | ; |
---|
[5] | 308 | u10out=fltarr(jpi,jpj,jptin) |
---|
| 309 | v10out=fltarr(jpi,jpj,jptin) |
---|
[97] | 310 | ; |
---|
[5] | 311 | for jt=0,jptin-1 do begin |
---|
[92] | 312 | ; ++print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
[5] | 313 | tab=reform(u10in(*,*,jt)) |
---|
[70] | 314 | u10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
| 315 | , lonout,latout,method='bilinear' $ |
---|
| 316 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
[5] | 317 | u10out(*,*,jt)=u10out(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
[97] | 318 | ; |
---|
[5] | 319 | tab=reform(v10in(*,*,jt)) |
---|
[70] | 320 | v10out(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
| 321 | , lonout,latout,method='bilinear' $ |
---|
| 322 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
[5] | 323 | v10out(*,*,jt)=v10out(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
[97] | 324 | ; |
---|
[5] | 325 | endfor |
---|
[97] | 326 | ; |
---|
[100] | 327 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
[94] | 328 | jpt=n_elements(time) |
---|
[98] | 329 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 330 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 331 | time=time-julday(1,1,1950,00,00,00) |
---|
[97] | 332 | xlon=reform(glamt(*,0) ) |
---|
[94] | 333 | ylat=reform(gphit(0,*)) |
---|
[97] | 334 | ; |
---|
[19] | 335 | initncdf, fullfilename_msk |
---|
[5] | 336 | valmask=1.e20 |
---|
[97] | 337 | ; |
---|
[5] | 338 | ylat=latout |
---|
| 339 | xlon=lonout |
---|
[66] | 340 | ncfile='!' + fullfilename_out |
---|
[5] | 341 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 342 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
[100] | 343 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 344 | globattr={source:'Tropical ocean winds obtained from ERA Interim',timerange:cda0+' - '+cda1} |
---|
[5] | 345 | u10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre u wind component',short_name:'u10',axis:'TYX'} |
---|
| 346 | v10_attr={units:'m/s',missing_value:valmask,long_name:'10 metre v wind component',short_name:'v10',axis:'TYX'} |
---|
[97] | 347 | ; |
---|
[98] | 348 | help, u10out,v10out,time,xlon,ylat |
---|
[97] | 349 | ; |
---|
[5] | 350 | ncfields = 'u10[longitude,latitude,time]=u10out:u10_attr; ' $ |
---|
| 351 | +'v10[longitude,latitude,time]=v10out:v10_attr; ' $ |
---|
| 352 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
| 353 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
[98] | 354 | + 'time[*time]=time:time_attr ' $ |
---|
[5] | 355 | + ' @ globattr' |
---|
[97] | 356 | ; |
---|
[5] | 357 | @ncdf_quickwrite |
---|
[97] | 358 | ; |
---|
[5] | 359 | end |
---|