source: trunk/SRC/Interpolation/neighbor.pro @ 331

Last change on this file since 331 was 327, checked in by pinsard, 17 years ago

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:keywords set to Id
File size: 1.9 KB
RevLine 
[59]1;+
2;
[101]3; @file_comments
[238]4; find the closest point of (P0) within a list of np1 points
5; P1 which can be on a sphere
[59]6;
[231]7; @categories
8; Maps
[59]9;
[242]10; @param p0lon {in}{required} {type=scalar}
11; longitudes of point P0.
[136]12;
[242]13; @param p0lat {in}{required} {type=scalar}
14; latitudes of point P0.
[136]15;
[125]16; @param neighlon {in}{optional}
[136]17;
[125]18; @param neighlat {in}{optional}
[59]19;
[125]20; @keyword RADIANS
21; if set, inputs and angular outputs are in radians, otherwise degrees.
[59]22;
[125]23; @keyword DISTANCE
24; dis, to get back the distances between P0 and the np1 points P1 in the
25; variable dis.
26;
[238]27; @keyword SPHERE
28; to activate if points are located on a sphere.
[125]29;
[101]30; @returns
[125]31; index giving the P1[index] point that is the closest point of (P0)
[59]32;
[101]33; @examples
[125]34; IDL> print, neighbor(-105.15,40.02,[-0.07,100,50],[51.30,20,0], $
35; IDL> distance=dis)
[59]36;                  0
[125]37; IDL> print, dis
[59]38;             105.684      206.125      160.228
39;
[101]40; @history
41; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[59]42;                  October 2003
[118]43;
[231]44; @version
45; $Id$
[118]46;
[59]47;-
[327]48FUNCTION neighbor, p0lon, p0lat, neighlon, neighlat $
49                 , SPHERE=sphere, DISTANCE=distance, RADIANS=radians
[59]50;
[114]51  compile_opt idl2, strictarrsubs
52;
[242]53; some checks
54  IF  n_elements(p0lon) NE 1 THEN ras = report('Sorry p0lon must be a scalar')
[59]55  p0lon = p0lon[0]
[242]56  IF  n_elements(p0lat) NE 1 THEN ras = report('Sorry p0lat must be a scalar')
[59]57  p0lat = p0lat[0]
[125]58  nneig = n_elements(neighlon)
[59]59  IF  n_elements(neighlat) NE nneig  THEN $
[242]60    ras = report('neighlon and neighlat must have the same number of elements')
[59]61; distance between P0 and the others points
62  IF keyword_set(sphere) THEN BEGIN
63    IF sphere NE 1 THEN radius = sphere
64    distance = Map_nPoints(p0lon, p0lat, neighlon, neighlat $
65                       , radius = radius, radians = radians)
[125]66  ENDIF ELSE BEGIN
[59]67    distance = (neighlon-p0lon)^2+(neighlat-p0lat)^2
68    IF arg_present(distance) THEN distance = sqrt(distance)
69  ENDELSE
70  RETURN, where(distance EQ min(distance))
71END
Note: See TracBrowser for help on using the repository browser.