Changeset 384 for trunk


Ignore:
Timestamp:
11/06/08 03:32:33 (16 years ago)
Author:
smasson
Message:

add fill(xy)dir keyword to extrapolate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Interpolation/extrapolate.pro

    r381 r384  
    2020; is no more masked values we exit extrapolate before reaching nb_iteration 
    2121; 
     22; @keyword FILLXDIR {type=scalar, 0 or 1}{default=0} 
     23; put 1 to specify that filling of the data must be done only along x direction 
     24; 
     25; @keyword FILLYDIR {type=scalar, 0 or 1}{default=0} 
     26; put 1 to specify that filling of the data must be done only along y direction 
     27; 
    2228; @keyword X_PERIODIC {type=scalar, 0 or 1}{default=0} 
    2329; put 1 to specify that the data are periodic along x axis 
     
    5763; 
    5864;- 
    59 FUNCTION extrapolate, zinput, maskinput, nb_iteration, X_PERIODIC=x_periodic $ 
    60                       , MINVAL=minval, MAXVAL=maxval, GE0=ge0, _EXTRA=ex 
     65FUNCTION extrapolate, zinput, maskinput, nb_iteration, FILLXDIR = fillxdir, FILLYDIR = fillydir $ 
     66                      , X_PERIODIC = x_periodic, MINVAL=minval, MAXVAL=maxval, GE0=ge0, _EXTRA=ex 
    6167; 
    6268  compile_opt idl2, strictarrsubs 
     
    118124; find the land points 
    119125  land = where(msk EQ 0, cnt_land) 
     126  IF keyword_set(fillxdir) THEN BEGIN  
     127    tst = total(msk[1:nx, 1:ny], 1) 
     128    cnt_land = total(tst NE 0 AND tst NE nx) 
     129  ENDIF  
     130  IF keyword_set(fillydir) THEN BEGIN  
     131    tst = total(msk[1:nx, 1:ny], 2) 
     132    cnt_land = total(tst NE 0 AND tst NE ny) 
     133  ENDIF  
    120134;--------------------------------------------------------------- 
    121135  WHILE cnt LE nb_iteration AND cnt_land NE 0 DO BEGIN 
     
    149163; border of the array, we can compute the weight without shift 
    150164; (faster). 
    151 ; 
    152     weight = msk[land+1]+msk[land-1]+msk[land+nx2]+msk[land-nx2] $ 
    153              +sqrtinv*(msk[land+nx2+1]+msk[land+nx2-1] $ 
    154                        +msk[land-nx2+1]+msk[land-nx2-1]) 
     165;  
     166    CASE 1 OF 
     167      keyword_set(fillxdir):weight = msk[land+1]+msk[land-1] 
     168      keyword_set(fillydir):weight = msk[land+nx2]+msk[land-nx2] 
     169      ELSE:weight = msk[land+1]+msk[land-1]+msk[land+nx2]+msk[land-nx2] $ 
     170                    +sqrtinv*(msk[land+nx2+1]+msk[land+nx2-1] $ 
     171                              +msk[land-nx2+1]+msk[land-nx2-1]) 
     172    ENDCASE 
    155173; list all the points that have sea neighbors 
    156174    ok = where(weight GT 0) 
     
    164182    z = temporary(z)*msk 
    165183; 
    166     zcoast = z[1+coast]+z[-1+coast]+z[nx2+coast]+z[-nx2+coast] $ 
     184    CASE 1 OF 
     185      keyword_set(fillxdir):zcoast = z[1+coast]+z[-1+coast] 
     186      keyword_set(fillydir):zcoast = z[nx2+coast]+z[-nx2+coast] 
     187      ELSE:zcoast = z[1+coast]+z[-1+coast]+z[nx2+coast]+z[-nx2+coast] $ 
    167188             +1./sqrt(2)*(z[nx2+1+coast]+z[nx2-1+coast] $ 
    168189                          +z[-nx2+1+coast]+z[-nx2-1+coast]) 
     190    ENDCASE 
    169191; 
    170192    IF keyword_set(ge0) THEN zcoast = 0. > temporary(zcoast) 
     
    192214; find the land points 
    193215    land = where(msk EQ 0, cnt_land) 
     216    IF keyword_set(fillxdir) THEN BEGIN  
     217      tst = total(msk[1:nx, 1:ny], 1) 
     218      cnt_land = total(tst NE 0 AND tst NE nx) 
     219    ENDIF  
     220    IF keyword_set(fillydir) THEN BEGIN  
     221      tst = total(msk[1:nx, 1:ny], 2) 
     222      cnt_land = total(tst NE 0 AND tst NE ny) 
     223    ENDIF  
    194224; 
    195225  ENDWHILE 
Note: See TracChangeset for help on using the changeset viewer.