Ignore:
Timestamp:
07/06/06 16:10:25 (18 years ago)
Author:
pinsard
Message:

improvements of Interpolation/*.pro header

File:
1 edited

Legend:

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

    r121 r125  
    11;+ 
    2 ; @file_comments to find if an (x,y) point is in a quadrilateral (x1,x2,x3,x4) 
     2; @file_comments  
     3; to find if an (x,y) point is in a quadrilateral (x1,x2,x3,x4) 
    34; 
    45; @categories grid manipulation 
     
    67; @param x {in}{required} 
    78; @param y {in}{required} 
    8 ;  the coordinates of the point we want to know where it is.  
    9 ;  Must be a scalar if /onsphere activated else can be scalar or array.  
     9;  the coordinates of the point we want to know where it is. 
     10;  Must be a scalar if /ONSPHERE activated else can be scalar or array. 
    1011; 
    1112; @param x1 {in}{required} 
     
    1718; @param x4 {in}{required} 
    1819; @param y4 {in}{required} 
    19 ;  the coordinates of the quadrilateral given in the CLOCKWISE order.  
     20;  the coordinates of the quadrilateral given in the CLOCKWISE order. 
    2021;  Scalar or array. 
    2122; 
    22 ; @keyword /DOUBLE use double precision to perform the computation  
    23 ; 
    24 ; @keyword /ONSPHERE to specify that the quadilateral are on a sphere and 
     23; @keyword DOUBLE use double precision to perform the computation 
     24; 
     25; @keyword ONSPHERE to specify that the quadilateral are on a sphere and 
    2526;    that teir coordinates are longitude-latitude coordinates. In this 
    2627;    case, est-west periodicity, poles singularity and other pbs 
    2728;    related to longitude-latitude coordinates are managed 
    28 ;    automatically.  
     29;    automatically. 
    2930; 
    3031; @keyword ZOOMRADIUS {default=4} 
     
    3233;    zoomradius degree where we look for the the quadrilateral which 
    3334;    contains the (x,y) point) used for the satellite projection 
    34 ;    when /onsphere is activated.  
    35 ;    4 seems to be the minimum which can be used.  
     35;    when /ONSPHERE is activated. 
     36;    4 seems to be the minimum which can be used. 
    3637;    Can be increase if the cell size is larger than 5 degrees. 
    37 ;    
    38 ; @keyword /NOPRINT to suppress the print messages. 
     38; 
     39; @keyword NOPRINT to suppress the print messages. 
    3940; 
    4041; @keyword NEWCOORD 
     
    4546;    quadrilateral number j with (0 <= j <= n_elements(x0)-1) 
    4647; 
    47 ; @restrictions I think degenerated quadrilateral (e.g. flat of 
    48 ; twisted) is not work. This has to be tested. 
    49 ; 
    50 ; @examples  
     48; @restrictions 
     49; I think degenerated quadrilateral (e.g. flat of twisted) is not work. 
     50; This has to be tested. 
     51; 
     52; @examples 
    5153; 
    5254; IDL> x = 1.*[1, 2, 6, 7, 3] 
     
    7072;      Sebastien Masson (smasson\@lodyc.jussieu.fr) 
    7173;      August 2003 
    72 ;      Based on Convert_clic_ij.pro written by Gurvan Madec  
     74;      Based on Convert_clic_ij.pro written by Gurvan Madec 
    7375; 
    7476; @version $Id$ 
     
    100102    x3 = x3 MOD 360 
    101103    x4 = x4 MOD 360 
    102 ; save !map  
     104; save !map 
    103105    save = {map:!map, x:!x, y:!y, z:!z, p:!p} 
    104 ; do a satellite projection  
     106; do a satellite projection 
    105107    IF NOT keyword_set(zoomradius) THEN zoomradius = 4 
    106108    map_set, y[0], x[0], 0, /satellite, sat_p = [1+zoomradius*20/6371.229, 0, 0], /noerase, /iso, /noborder 
    107109; use normal coordinates to reject cells which are out of the projection. 
    108     tmp  = convert_coord(x, y, /DATA, /TO_NORMAL, DOUBLE = double)  
    109     tmp1 = convert_coord(x1, y1, /DATA, /TO_NORMAL, DOUBLE = double)  
    110     tmp2 = convert_coord(x2, y2, /DATA, /TO_NORMAL, DOUBLE = double)  
    111     tmp3 = convert_coord(x3, y3, /DATA, /TO_NORMAL, DOUBLE = double)  
    112     tmp4 = convert_coord(x4, y4, /DATA, /TO_NORMAL, DOUBLE = double)  
     110    tmp  = convert_coord(x, y, /DATA, /TO_NORMAL, DOUBLE = double) 
     111    tmp1 = convert_coord(x1, y1, /DATA, /TO_NORMAL, DOUBLE = double) 
     112    tmp2 = convert_coord(x2, y2, /DATA, /TO_NORMAL, DOUBLE = double) 
     113    tmp3 = convert_coord(x3, y3, /DATA, /TO_NORMAL, DOUBLE = double) 
     114    tmp4 = convert_coord(x4, y4, /DATA, /TO_NORMAL, DOUBLE = double) 
    113115; remove cell which have one corner with coordinates equal to NaN 
    114116    test = finite(tmp1[0, *]+tmp1[1, *]+tmp2[0, *]+tmp2[1, *] $ 
     
    150152; 
    151153    tmp1 = -1 & tmp2 = -1 & tmp3 = -1 & tmp4 = -1 
    152 ; remove cells which are obviously bad  
     154; remove cells which are obviously bad 
    153155    test = (x1 GT x AND x2 GT x AND x3 GT x AND x4 GT x) $ 
    154156      OR (x1 LT x AND x2 LT x AND x3 LT x AND x4 LT x) $ 
     
    179181    ENDIF 
    180182; 
    181     nquad = n_elements(good2)  
     183    nquad = n_elements(good2) 
    182184    x1 = x1[good2] 
    183185    y1 = y1[good2] 
     
    196198;       *((x-x2)*(y3-y2) GT (x3-x2)*(y-y2)) $ 
    197199;       *((x-x3)*(y4-y3) GT (x4-x3)*(y-y3)) $ 
    198 ;       *((x-x4)*(y1-y4) GE (x1-x4)*(y-y4))  
     200;       *((x-x4)*(y1-y4) GE (x1-x4)*(y-y4)) 
    199201; 
    200202; computation of test without any do loop for ntofind points (x,y) and 
     
    202204; test dimensions are (ntofind, nquad) 
    203205; column i of test corresponds to the intersection of point i with all 
    204 ; quadirlateral.  
    205 ; row j of test corresponds to all the points localized in cell j  
     206; quadirlateral. 
     207; row j of test corresponds to all the points localized in cell j 
    206208  test = $ 
    207209; (x-x1) 
     
    277279        ENDIF 
    278280        return,  -1 
    279       END  
     281      END 
    280282      n_elements(found) GT ntofind:BEGIN 
    281283        IF NOT keyword_set(noprint) THEN print, 'The point is in more than one cell' 
    282       END  
     284      END 
    283285      ELSE: 
    284286    ENDCASE 
    285287  ENDIF ELSE BEGIN 
    286 ; if ntofind GT 1, found must be sorted  
     288; if ntofind GT 1, found must be sorted 
    287289; i position of found. this corresponds to one x,y point 
    288290    forsort = found MOD ntofind 
Note: See TracChangeset for help on using the changeset viewer.