- Timestamp:
- 07/06/06 16:10:25 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Interpolation/compute_fromreg_imoms3_weigaddr.pro
r118 r125 1 1 ;+ 2 2 ; 3 ; @file_comments compute the weight and address neede to interpolate data from a 4 ; "regular grid" to any grid using the imoms3 method 5 ; 3 ; @file_comments 4 ; compute the weight and address neede to interpolate data from a 5 ; "regular grid" to any grid using the imoms3 method 6 ; 6 7 ; @categories interpolation 7 8 ; 8 ; @param alonin {in}{required} longitude of the input data 9 ; @param alatin {in}{required} latitude of the input data10 ; @param olonin {in}{required} longitude of the output data 11 ; @param olat {in}{required} latitude of the output data 12 ; 13 ; @keyword /NONORTHERNLINE14 ; @keyword /NOSOUTHERNLINE15 ; activate if you don't w hant to take into account the northen/southern line9 ; @param alonin {in}{required} longitude of the input data 10 ; @param alatin {in}{required} latitude of the input data 11 ; @param olonin {in}{required} longitude of the output data 12 ; @param olat {in}{required} latitude of the output data 13 ; 14 ; @keyword NONORTHERNLINE 15 ; @keyword NOSOUTHERNLINE 16 ; activate if you don't want to take into account the northen/southern line 16 17 ; of the input data when perfoming the interpolation. 17 18 ; … … 24 25 ; 25 26 ; @restrictions 26 ; - 27 ; 28 ; 27 ; - the input grid must be a "regular/rectangular grid", defined as a grid for 28 ; which each lontitudes lines have the same latitude and each latitudes columns 29 ; have the same longitude. 29 30 ; - We supposed the data are located on a sphere, with a periodicity along 30 ; 31 ; the longitude. 31 32 ; - points located between the first/last 2 lines are interpolated 32 ; 33 ; 34 ; - 35 ; 36 ; 33 ; using a imoms3 interpolation along the longitudinal direction and linear 34 ; interpolation along the latitudinal direction 35 ; - points located out of the southern and northern boundaries are interpolated 36 ; using a imoms3 interpolation only along the longitudinal direction. 37 ; 37 38 ; @history 38 ; November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr) 39 ; November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr) 39 40 ; March 2006: works for rectangular grids 40 41 ; … … 49 50 , NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline 50 51 ; 51 compile_opt idl2, strictarrsubs 52 compile_opt idl2, strictarrsubs 52 53 ; 53 54 alon = alonin … … 65 66 IF maxalon-minalon GE 360. THEN stop 66 67 ; alon must be monotonically increasing 67 IF array_equal(sort(alon), lindgen(jpia)) NE 1 THEN BEGIN 68 IF array_equal(sort(alon), lindgen(jpia)) NE 1 THEN BEGIN 68 69 shiftx = -(where(alon EQ min(alon)))[0] 69 70 alon = shift(alon, shiftx) … … 89 90 IF total((step-step[0]) GE 1.e-6) NE 0 THEN noregy = 1 90 91 ; 91 if keyword_set(nonorthernline) then BEGIN 92 if keyword_set(nonorthernline) then BEGIN 92 93 jpja = jpja - 1L 93 94 alat = alat[0: jpja-1L] 94 95 ENDIF 95 if keyword_set(nosouthernline) then BEGIN 96 if keyword_set(nosouthernline) then BEGIN 96 97 alat = alat[1: jpja-1L] 97 98 jpja = jpja - 1L … … 123 124 indexlat = value_locate(alat, olat) 124 125 ; 125 ; for the ocean points located below the atm line 126 ; for the ocean points located below the atm line 126 127 ; jpja-2 and above the line 1 127 128 ; for those points we can always find 16 neighbors … … 131 132 ilon = indexlon[short] 132 133 ilat = indexlat[short] 133 ; 134 IF NOT keyword_set(noregy) THEN BEGIN 134 ; 135 IF NOT keyword_set(noregy) THEN BEGIN 135 136 delta = alat[ilat+1L]-alat[ilat] 136 137 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop … … 147 148 d2 = (alat[ilat+1L]-olat[short])/delta 148 149 IF min(d2, max = ma) LE 0 THEN stop 149 IF ma GT 1 THEN stop 150 IF ma GT 1 THEN stop 150 151 wy2 = imoms3(temporary(d2)) 151 152 d3 = (alat[ilat+2L]-olat[short])/delta 152 153 IF min(d3, max = ma) LE 1 THEN stop 153 IF ma GT 2 THEN stop 154 IF ma GT 2 THEN stop 154 155 wy3 = imoms3(temporary(d3)) 155 ENDIF ELSE BEGIN 156 ENDIF ELSE BEGIN 156 157 nele = n_elements(short) 157 158 wy0 = fltarr(nele) … … 169 170 wy3[i] = imoms3(2-newlat) 170 171 ENDFOR 171 ENDELSE 172 ENDELSE 172 173 ; 173 174 mi = min(wy0+wy1+wy2+wy3, max = ma) … … 175 176 IF abs(ma-1) GE 1.e-6 THEN stop 176 177 ; 177 IF NOT keyword_set(noregx) THEN BEGIN 178 IF NOT keyword_set(noregx) THEN BEGIN 178 179 delta = alon[ilon]-alon[ilon-1L] 179 180 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop … … 194 195 d3 = (alon[ilon+2L]-olon[short])/delta 195 196 IF min(d3, max = ma) LE 1 THEN stop 196 IF ma GT 2 THEN stop 197 IF ma GT 2 THEN stop 197 198 wx3 = imoms3(temporary(d3)) 198 ENDIF ELSE BEGIN 199 ENDIF ELSE BEGIN 199 200 nele = n_elements(short) 200 201 wx0 = fltarr(nele) … … 212 213 wx3[i] = imoms3(2-newlon) 213 214 ENDFOR 214 ENDELSE 215 ENDELSE 215 216 ; 216 217 mi = min(wx0+wx1+wx2+wx3, max = ma) … … 220 221 ; line 0 221 222 xaddr[0, short] = ilon - 1L 222 xaddr[1, short] = ilon 223 xaddr[1, short] = ilon 223 224 xaddr[2, short] = ilon + 1L 224 225 xaddr[3, short] = ilon + 2L … … 233 234 ; line 1 234 235 xaddr[4, short] = ilon - 1L 235 xaddr[5, short] = ilon 236 xaddr[5, short] = ilon 236 237 xaddr[6, short] = ilon + 1L 237 238 xaddr[7, short] = ilon + 2L 238 yaddr[4, short] = ilat 239 yaddr[5, short] = ilat 240 yaddr[6, short] = ilat 241 yaddr[7, short] = ilat 239 yaddr[4, short] = ilat 240 yaddr[5, short] = ilat 241 yaddr[6, short] = ilat 242 yaddr[7, short] = ilat 242 243 weig[4, short] = wx0 * wy1 243 244 weig[5, short] = wx1 * wy1 … … 246 247 ; line 2 247 248 xaddr[8, short] = ilon - 1L 248 xaddr[9, short] = ilon 249 xaddr[9, short] = ilon 249 250 xaddr[10, short] = ilon + 1L 250 251 xaddr[11, short] = ilon + 2L … … 259 260 ; line 3 260 261 xaddr[12, short] = ilon - 1L 261 xaddr[13, short] = ilon 262 xaddr[13, short] = ilon 262 263 xaddr[14, short] = ilon + 1L 263 264 xaddr[15, short] = ilon + 2L … … 275 276 IF abs(ma-1) GE 1.e-6 THEN stop 276 277 ; 277 ; for the ocean points located between the atm lines 278 ; for the ocean points located between the atm lines 278 279 ; jpja-2 and jpja-1 or between the atm lines 0 and 1 279 280 ; linear interpolation between line 1 and line 2 … … 285 286 ; 286 287 delta = alat[ilat+1L]-alat[ilat] 287 IF NOT keyword_set(noregy) THEN BEGIN 288 IF NOT keyword_set(noregy) THEN BEGIN 288 289 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop 289 delta = delta[0] 290 ENDIF 290 delta = delta[0] 291 ENDIF 291 292 ; 292 293 d1 = (alat[ilat ]-olat[short])/delta … … 296 297 d2 = (alat[ilat+1L]-olat[short])/delta 297 298 IF min(d2, max = ma) LE 0 THEN stop 298 IF ma GT 1 THEN stop 299 IF ma GT 1 THEN stop 299 300 wy2 = 1.- temporary(d2) 300 301 ; … … 303 304 IF abs(ma-1) GE 1.e-6 THEN stop 304 305 ; but imoms3 along the longitude 305 IF NOT keyword_set(noregx) THEN BEGIN 306 IF NOT keyword_set(noregx) THEN BEGIN 306 307 delta = alon[ilon]-alon[ilon-1L] 307 308 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop … … 322 323 d3 = (alon[ilon+2L]-olon[short])/delta 323 324 IF min(d3, max = ma) LE 1 THEN stop 324 IF ma GT 2 THEN stop 325 IF ma GT 2 THEN stop 325 326 wx3 = imoms3(temporary(d3)) 326 ENDIF ELSE BEGIN 327 ENDIF ELSE BEGIN 327 328 nele = n_elements(short) 328 329 wx0 = fltarr(nele) … … 340 341 wx3[i] = imoms3(2-newlon) 341 342 ENDFOR 342 ENDELSE 343 ENDELSE 343 344 ; 344 345 mi = min(wx0+wx1+wx2+wx3, max = ma) … … 347 348 ; line 1 348 349 xaddr[0, short] = ilon - 1L 349 xaddr[1, short] = ilon 350 xaddr[1, short] = ilon 350 351 xaddr[2, short] = ilon + 1L 351 352 xaddr[3, short] = ilon + 2L 352 yaddr[0, short] = ilat 353 yaddr[1, short] = ilat 354 yaddr[2, short] = ilat 355 yaddr[3, short] = ilat 353 yaddr[0, short] = ilat 354 yaddr[1, short] = ilat 355 yaddr[2, short] = ilat 356 yaddr[3, short] = ilat 356 357 weig[0, short] = wx0 * wy1 357 358 weig[1, short] = wx1 * wy1 … … 360 361 ; line 2 361 362 xaddr[4, short] = ilon - 1L 362 xaddr[5, short] = ilon 363 xaddr[5, short] = ilon 363 364 xaddr[6, short] = ilon + 1L 364 365 xaddr[7, short] = ilon + 2L … … 379 380 ; 380 381 ; for the ocean points located below the line 0 381 ; Interpolation only along the longitude 382 ; Interpolation only along the longitude 382 383 ; 383 384 short = where(indexlat EQ -1) … … 385 386 ilon = indexlon[short] 386 387 ; 387 IF NOT keyword_set(noregx) THEN BEGIN 388 IF NOT keyword_set(noregx) THEN BEGIN 388 389 delta = alon[ilon]-alon[ilon-1L] 389 390 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop … … 404 405 d3 = (alon[ilon+2L]-olon[short])/delta 405 406 IF min(d3, max = ma) LE 1 THEN stop 406 IF ma GT 2 THEN stop 407 IF ma GT 2 THEN stop 407 408 wx3 = imoms3(temporary(d3)) 408 ENDIF ELSE BEGIN 409 ENDIF ELSE BEGIN 409 410 nele = n_elements(short) 410 411 wx0 = fltarr(nele) … … 422 423 wx3[i] = imoms3(2-newlon) 423 424 ENDFOR 424 ENDELSE 425 ENDELSE 425 426 ; 426 427 mi = min(wx0+wx1+wx2+wx3, max = ma) … … 429 430 ; line 1 430 431 xaddr[0, short] = ilon - 1L 431 xaddr[1, short] = ilon 432 xaddr[1, short] = ilon 432 433 xaddr[2, short] = ilon + 1L 433 434 xaddr[3, short] = ilon + 2L 434 yaddr[0:3, short] = 0 435 yaddr[0:3, short] = 0 435 436 weig[0, short] = wx0 436 437 weig[1, short] = wx1 … … 444 445 ENDIF 445 446 ; 446 ; for the ocean points located above jpia-1 447 ; Interpolation only along the longitude 447 ; for the ocean points located above jpia-1 448 ; Interpolation only along the longitude 448 449 ; 449 450 short = where(indexlat EQ jpja-1L) … … 451 452 ilon = indexlon[short] 452 453 ; 453 IF NOT keyword_set(noregx) THEN BEGIN 454 IF NOT keyword_set(noregx) THEN BEGIN 454 455 delta = alon[ilon]-alon[ilon-1L] 455 456 IF max(abs(delta-delta[0])) GE 1.e-6 THEN stop … … 470 471 d3 = (alon[ilon+2L]-olon[short])/delta 471 472 IF min(d3, max = ma) LE 1 THEN stop 472 IF ma GT 2 THEN stop 473 IF ma GT 2 THEN stop 473 474 wx3 = imoms3(temporary(d3)) 474 ENDIF ELSE BEGIN 475 ENDIF ELSE BEGIN 475 476 nele = n_elements(short) 476 477 wx0 = fltarr(nele) … … 488 489 wx3[i] = imoms3(2-newlon) 489 490 ENDFOR 490 ENDELSE 491 ENDELSE 491 492 ; 492 493 mi = min(wx0+wx1+wx2+wx3, max = ma) … … 495 496 ; line 1 496 497 xaddr[0, short] = ilon-1L 497 xaddr[1, short] = ilon 498 xaddr[1, short] = ilon 498 499 xaddr[2, short] = ilon+1L 499 500 xaddr[3, short] = ilon+2L … … 531 532 IF revy EQ 1 THEN yaddr = jpja - 1L - temporary(yaddr) 532 533 ; ; 533 addr = temporary(yaddr)*jpia+temporary(xaddr) 534 addr = temporary(yaddr)*jpia+temporary(xaddr) 534 535 ; 535 536 RETURN
Note: See TracChangeset
for help on using the changeset viewer.