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

Last change on this file since 105 was 101, checked in by pinsard, 18 years ago

start to modify headers of Interpolation *.pro files for better idldoc output

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