Ignore:
Timestamp:
01/12/07 12:00:06 (17 years ago)
Author:
smasson
Message:

add extrapsmooth + light bugfix in compute_fromirr_bilinear_weigaddr + improve some headers

Location:
trunk/SRC/Interpolation
Files:
1 added
6 edited

Legend:

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

    r157 r202  
    88; 
    99; @param plam {in}{required} 
     10; longitude position 
    1011; 
    1112; @param pphi {in}{required} 
     13; latitude position 
    1214; 
    1315; @keyword DOUBLE {default=0} 
     
    1517; 
    1618; @returns 
    17 ;       gsinu,gcosu : sinus and cosinus of the angle 
    18 ;       gsinv,gcosv   between north-south direction 
    19 ;       gsint,gcost   and the j-direction of the mesh 
    20 ; 
    21 ; @restrictions 
    22 ; to compute the lateral boundary conditions, we assume that: 
    23 ;     (1) the first line is similar to the second line 
    24 ;       =>    gcosu[*, 0] = gcosu[*, 1] 
    25 ;       =>    gsinu[*, 0] = gsinu[*, 1] 
    26 ;     (2) the grid follows OPA x periodicity rule, first column is 
    27 ;     equal to the next to last column 
    28 ;       =>    gcosv[0, *] = gcosv[jpj-2, *] 
    29 ;       =>    gsinv[0, *] = gsinv[jpj-2, *] 
    30 ; 
    31 ; 
    32 ; @history 
    33 ;       Original :  96-07 (O. Marti) 
    34 ;                   98-06 (G. Madec) 
    35 ;       Feb 2005: IDL adaptation S. Masson 
    36 ; 
    37 ; @version $Id$ 
     19; structure: {x:x, y:y} containing the point position in north stereographic polar projection 
     20; 
     21; @hidden 
    3822; 
    3923;- 
     
    5640;--------- 
    5741;+ 
    58 ; @file_comments Compute angles between grid lines and direction of the North 
     42; @file_comments Compute angles between grid lines and direction of the North pole 
    5943;(fom angle.F,v 2.2 in OPA8.2) 
    6044; 
    61 ; @param fileocemesh {in}{required} a netcdf file that contains (at least): 
     45; @categories  
     46; Interpolation 
     47; 
     48; @param fileocemesh {in}{required}{type=scalar string} 
     49; a netcdf file that contains (at least) the following variables: 
    6250;        glamu, gphiu: longitudes and latitudes at U-points 
    6351;        glamv, gphiv: longitudes and latitudes at V-points 
    6452;        glamf, gphif: longitudes and latitudes at F-points 
    6553; 
    66 ; @param gcosu {in}{required} 
    67 ; @param gsinu {in}{required} 
    68 ; @param gcosv {in}{required} 
    69 ; @param gsinv {in}{required} 
    70 ; @param gcost {in}{required} 
    71 ; @param gsint {in}{required} 
    72 ; @keyword IODIRECTORY the directory path where is located fileocemesh 
    73 ; @keyword DOUBLE {default=0} use double precision (default is float) 
     54; @param gcosu {out}{type=2d array} 
     55; cosinus of the angle between grid lines at U points and direction of the North pole 
     56; 
     57; @param gsinu {out}{type=2d array} 
     58; sinus of the angle between grid lines at U points and direction of the North pole 
     59; 
     60; @param gcosv {out}{type=2d array} 
     61; cosinus of the angle between grid lines at V points and direction of the North pole 
     62; 
     63; @param gsinv {out}{type=2d array} 
     64; sinus of the angle between grid lines at V points and direction of the North pole 
     65; 
     66; @param gcost {out}{type=2d array} 
     67; cosinus of the angle between grid lines at T points and direction of the North pole 
     68; 
     69; @param gsint {out}{type=2d array} 
     70; sinus of the angle between grid lines at T points and direction of the North pole 
     71; 
     72; @keyword IODIRECTORY {type=scalar string}{default=''} 
     73; the directory path where is located fileocemesh 
     74; 
     75; @keyword DOUBLE {type=1 ou 2}{default=0} 
     76; put 1 to use double precision (default is float) 
     77; 
     78; @restrictions 
     79; to compute the lateral boundary conditions, we assume that: 
     80;     (1) the first line is similar to the second line 
     81;       =>    gcosu[*, 0] = gcosu[*, 1] 
     82;       =>    gsinu[*, 0] = gsinu[*, 1] 
     83;     (2) the grid follows OPA x periodicity rule, first column is 
     84;     equal to the next to last column 
     85;       =>    gcosv[0, *] = gcosv[jpj-2, *] 
     86;       =>    gsinv[0, *] = gsinv[jpj-2, *] 
     87; 
     88; @history 
     89;       Original :  96-07 (O. Marti) 
     90;                   98-06 (G. Madec) 
     91;       Feb 2005: IDL adaptation S. Masson 
     92; 
     93; @version $Id$ 
    7494;- 
    7595;--------- 
  • trunk/SRC/Interpolation/compute_fromirr_bilinear_weigaddr.pro

    r157 r202  
    88; Interpolation 
    99; 
    10 ; @param olonin {in}{required} 
     10; @param olonin {in}{required}{type=2d array} 
    1111; longitude of the input data 
    1212; 
    13 ; @param olat {in}{required} 
     13; @param olat {in}{required}{type=2d array} 
    1414; latitude of the input data 
    1515; 
    16 ; @param omsk {in}{required} 
     16; @param omsk {in}{required}{type=2d array or -1} 
    1717; land/sea mask of the input data 
    18 ; 
    19 ; @param alonin {in}{required} 
     18; put -1 if input data are not masked 
     19; 
     20; @param alonin {in}{required}{type=2d array} 
    2021; longitude of the output data 
    2122; 
    22 ; @param alat {in}{required} 
     23; @param alat {in}{required}{type=2d array} 
    2324; latitude of the output data 
    2425; 
    25 ; @param amsk {in}{required} 
     26; @param amsk {in}{required}{type=2d array or -1} 
    2627; land/sea mask of the output data 
    27 ; 
    28 ; @param weig {out} 
    29 ; @param addr {out} 
     28; put -1 if output data are not masked 
     29; 
     30; @param weig {out}{type=2d array} 
     31; (see ADDR) 
     32; 
     33; @param addr {out}{type=2d array} 
    3034; 2D arrays, weig and addr are the weight and addresses used to 
    3135; perform the interpolation: 
     
    4448;  and the weight is redistributed on the remaining "water" corners 
    4549;  -  points located out of the southern and northern boundaries or in cells 
    46 ;  containing only land points are set the the same value as their closest neighbor l 
     50;  containing only land points are set the the same value as their closest neighbor 
    4751; 
    4852; @history 
     
    6165; 
    6266  jpio = (size(olonin, /dimensions))[0] 
    63   jpjo = (size(olonin, /dimensions))[1] 
     67  jpjo = (size(olonin, /dimensions))[1]   
     68; mask check 
     69  IF n_elements(omsk) EQ 1 AND omsk[0] EQ -1 THEN omsk = replicate(1b, jpio, jpjo) 
     70  IF n_elements(amsk) EQ 1 AND amsk[0] EQ -1 THEN amsk = replicate(1b, jpia, jpja) 
     71  IF n_elements(omsk) NE jpio*jpjo THEN BEGIN 
     72    print, 'input grid mask do not have the good size' 
     73    stop 
     74  ENDIF 
     75  IF n_elements(amsk) NE jpia*jpja THEN BEGIN  
     76    print, 'output grid mask do not have the good size' 
     77    stop 
     78  ENDIF 
    6479; 
    6580; longitude, between 0 and 360 
     
    7186  IF out[0] NE -1 THEN olon[out] = olon[out]+360 
    7287; 
    73 ; we work only on the water points 
    74   owater = where(omsk EQ 1) 
    75   nowater = n_elements(owater) 
     88; we work only on the ouput grid water points 
    7689  awater = where(amsk EQ 1) 
    7790  nawater = n_elements(awater) 
     
    167180      IF ind NE -1 THEN BEGIN 
    168181        ind = good[ind] 
    169 ; we keep its address 
    170         foraddr[n] = ind 
    171182; now, we morph the quadrilateral ocean cell into the reference square (0 -> 1) 
    172183; in addition we get the corrdinates of the atmospheric point in this new morphed square 
     
    189200        one = where(abs(1-xy) LT 1e-4) 
    190201        IF one[0] NE -1 THEN xy[one] = 1 
    191 ; some (useless) checks... 
    192         IF  xy[0] LT 0 OR xy[0] GT 1 THEN stop 
    193         IF  xy[0] LT 0 OR xy[0] GT 1 THEN stop 
     202; some checks... 
     203        tmpmsk = omsk[celladdr[*, ind]] 
     204        CASE 1 OF 
     205          xy[0] LT 0 OR xy[0] GT 1 : stop 
     206          xy[1] LT 0 OR xy[1] GT 1 : stop 
     207          xy[0] EQ 0 AND xy[1] EQ 0 AND tmpmsk[0] EQ 0 : foraddr[n] = -1 
     208          xy[0] EQ 1 AND xy[1] EQ 0 AND tmpmsk[1] EQ 0 : foraddr[n] = -1 
     209          xy[0] EQ 1 AND xy[1] EQ 1 AND tmpmsk[2] EQ 0 : foraddr[n] = -1 
     210          xy[0] EQ 0 AND xy[1] EQ 1 AND tmpmsk[3] EQ 0 : foraddr[n] = -1 
     211          xy[0] EQ 0 AND (tmpmsk[0]+tmpmsk[3]) EQ 0    : foraddr[n] = -1 
     212          xy[0] EQ 1 AND (tmpmsk[1]+tmpmsk[2]) EQ 0    : foraddr[n] = -1 
     213          xy[1] EQ 0 AND (tmpmsk[0]+tmpmsk[1]) EQ 0    : foraddr[n] = -1 
     214          xy[1] EQ 1 AND (tmpmsk[2]+tmpmsk[3]) EQ 0    : foraddr[n] = -1 
     215          ELSE: BEGIN  
     216; we keep its address 
     217        foraddr[n] = ind 
    194218; keep the new coordinates 
    195         forweight[n, 0] = xy[0] 
    196         forweight[n, 1] = xy[1] 
     219            forweight[n, 0] = xy[0] 
     220            forweight[n, 1] = xy[1] 
     221          END 
     222        ENDCASE 
     223 
     224 
     225 
    197226      ENDIF ELSE foraddr[n] = -1 
    198227    ENDIF ELSE foraddr[n] = -1 
     
    237266; weights normalization 
    238267  totalweig = total(newaweig, 1) 
     268  IF min(totalweig, max = ma) EQ 0 then stop 
     269  IF ma GT 1 then stop 
    239270  newaweig = newaweig/(replicate(1., 4)#totalweig) 
    240271  totalweig = total(newaweig, 1) 
  • trunk/SRC/Interpolation/compute_fromreg_bilinear_weigaddr.pro

    r163 r202  
    77; Interpolation 
    88; 
    9 ; @param alonin{in}{required} 
     9; @param alonin{in}{required}{type=2d array} 
    1010; longitude of the input data 
    1111; 
    12 ; @param alatin {in}{required} 
     12; @param alatin {in}{required}{type=2d array} 
    1313; latitude of the input data 
    1414; 
    15 ; @param olonin {in}{required} 
     15; @param olonin {in}{required}{type=2d array} 
    1616; longitude of the output data 
    1717; 
    18 ; @param olat {in}{required} 
     18; @param olat {in}{required}{type=2d array} 
    1919; latitude of the output data 
    2020; 
    21 ; @keyword NONORTHERNLINE 
    22 ; activate if you don't want to take into 
     21; @keyword NONORTHERNLINE {type=scalar 0 or 1}{default=0} 
     22; put 1 if you don't want to take into 
    2323; account the northen line of the input data when performing the interpolation. 
    2424; 
    25 ; @keyword NOSOUTHERNLINE 
    26 ; activate if you don't want to take into 
     25; @keyword NOSOUTHERNLINE {type=scalar 0 or 1}{default=0} 
     26; put 1 if you don't want to take into 
    2727; account the southern line of the input data when performing the interpolation. 
    2828; 
    29 ; @param weig {out} 
    30 ; @param addr {out} 
     29; @param weig {out}{type=2d array} 
     30; (see ADDR) 
     31; 
     32; @param addr {out}{type=2d array} 
    3133; 2D arrays, weig and addr are the weight and addresses used to 
    3234; perform the interpolation: 
  • trunk/SRC/Interpolation/compute_fromreg_imoms3_weigaddr.pro

    r163 r202  
    88; Interpolation 
    99; 
    10 ; @param alonin {in}{required} 
     10; @param alonin {in}{required}{type=2d array} 
    1111; longitude of the input data 
    1212; 
    13 ; @param alatin {in}{required} 
     13; @param alatin {in}{required}{type=2d array} 
    1414; latitude of the input data 
    1515; 
    16 ; @param olonin {in}{required} 
     16; @param olonin {in}{required}{type=2d array} 
    1717; longitude of the output data 
    18 ; @param olat {in}{required} 
     18; 
     19; @param olat {in}{required}{type=2d array} 
    1920; latitude of the output data 
    2021; 
    21 ; @keyword NONORTHERNLINE 
    22 ; @keyword NOSOUTHERNLINE 
    23 ; activate if you don't want to take into account the northen/southern line 
    24 ; of the input data when performing the interpolation. 
    25 ; 
    26 ; @param weig {out} 
    27 ; @param addr {out} 
     22; @keyword NONORTHERNLINE {type=scalar 0 or 1}{default=0} 
     23; put 1 if you don't want to take into 
     24; account the northen line of the input data when performing the interpolation. 
     25; 
     26; @keyword NOSOUTHERNLINE {type=scalar 0 or 1}{default=0} 
     27; put 1 if you don't want to take into 
     28; account the southern line of the input data when performing the interpolation. 
     29; 
     30; @param weig {out}{type=2d array} 
     31; (see ADDR) 
     32; 
     33; @param addr {out}{type=2d array} 
    2834; 2D arrays, weig and addr are the weight and addresses used to 
    2935; perform the interpolation: 
  • trunk/SRC/Interpolation/extrapolate.pro

    r199 r202  
    11;+ 
    22; @file_comments 
    3 ; extrapolate data (zinput) where maskinput eq 0 by filling 
    4 ; step by step the coastline points with the mean value of the 8 neighbourgs. 
     3; extrapolate data (zinput) where maskinput eq 0 by filling step by  
     4; step the coastline points with the mean value of the 8 neighbourgs 
     5; (weighted by their mask value). 
    56; 
    67; @categories  
    78; Interpolation 
    89; 
    9 ; @param zinput {in}{required} 
     10; @param zinput {in}{required}{type=2d array} 
    1011; data to be extrapolate 
    1112; 
    12 ; @param maskinput {in}{required} 
     13; @param maskinput {in}{required}{type=2d array or -1} 
     14; a 2D array, the land-sea mask of the output data (1 on ocean, 0 on land) 
     15; put -1 if input data are not masked 
    1316; 
    14 ; @param nb_iteration {in}{optional} 
    15 ; number of iteration 
     17; @param nb_iteration {in}{optional}{type=integer scalar}{default=10.E20} 
     18; Maximum number if iterations done in the extrapolation process. If there 
     19; is no more masked values we exit extrapolate before reaching nb_iteration 
     20; (to be sure to fill everything, you can use a very large value) 
    1621; 
    17 ; @keyword x_periodic 
    18 ; @keyword MINVAL 
    19 ; @keyword MAXVAL 
    20 ; @keyword GE0 
     22; @keyword x_periodic {type=scalar, 0 or 1}{default=0} 
     23; put 1 to specify that the data are periodic along x axis 
     24; 
     25; @keyword MINVAL {type=scalar}{default=not used} 
     26; to specify a minimum value to the extrapolated values 
     27; 
     28; @keyword MAXVAL {type=scalar}{default=not used} 
     29; to specify a maximum value to the extrapolated values 
     30; 
     31; @keyword GE0 {type=scalar 0 or 1}{default=0} 
     32; put 1 to force the extrapolated values to be larger than 0, same as using minval=0. 
     33; 
     34; @returns {type=2d array} 
     35; the extrapolated array 
     36; 
     37; @examples 
     38; IDL> a=extrapolate(dist(jpi,jpj),tmask[*,*,0],/x_periodic) 
     39; IDL> tvplus, a 
     40; IDL> tvplus, a*(1-tmask[*,*,0]) 
     41; get the coastline: 
     42; IDL> a=extrapolate(tmask[*,*,0],tmask[*,*,0],1,/x_periodic) 
     43; IDL> tvplus, a-tmask[*,*,0] 
     44; 
     45; @history 
     46;  Originaly written by G. Roulet 
     47;  Sebastien Masson (smasson\@lodyc.jussieu.fr) 
    2148; 
    2249; @version $Id$ 
    2350; 
    2451;- 
    25 FUNCTION extrapolate, zinput, maskinput, nb_iteration, x_periodic = x_periodic, MINVAL = minval, MAXVAL = maxval, GE0 = ge0 
     52FUNCTION extrapolate, zinput, maskinput, nb_iteration, x_periodic = x_periodic $ 
     53                      , MINVAL = minval, MAXVAL = maxval, GE0 = ge0 
    2654; 
    2755  compile_opt idl2, strictarrsubs 
     
    4270; 
    4371  ztmp = bytarr(nx+2, ny+2) 
     72  IF n_elements(maskinput) EQ 1 AND maskinput[0] EQ -1 THEN maskinput = replicate(1b, nx, ny) 
     73  IF n_elements(maskinput) NE nx*ny THEN BEGIN  
     74    print, 'input grid mask do not have the good size' 
     75    return, -1 
     76  ENDIF 
    4477  ztmp[1:nx, 1:ny] = byte(maskinput) 
    4578  msk = temporary(ztmp) 
  • trunk/SRC/Interpolation/fromirr.pro

    r163 r202  
    2020; a 2D array defining the latitude of the input data. 
    2121; 
    22 ; @param mskin {in}{optional}{type=2d array} 
     22; @param mskin {in}{optional}{type=2d array or -1} 
    2323; a 2D array, the land-sea mask of the input data (1 on ocean, 0 on land) 
     24; put -1 if input data are not masked 
    2425; 
    2526; @param lonout {in}{optional}{type=1d or 2d array} 
     
    2930; 1D or 2D array defining the latitude of the output data. 
    3031; 
    31 ; @param mskout {in}{required}{type=2d array} 
     32; @param mskout {in}{required}{type=2d array or -1} 
    3233; a 2D array, the land-sea mask of the output data (1 on ocean, 0 on land) 
     34; put -1 if output data are not masked 
    3335; 
    3436; @keyword WEIG {type=2d array} 
Note: See TracChangeset for help on using the changeset viewer.