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