On Aug 23, 6:12 am, "W. eWatson" <[EMAIL PROTECTED]> wrote: > The other night I surveyed a site for astronomical use by measuring the > altitude (0-90 degrees above the horizon) and az (azimuth, 0 degrees north > clockwise around the site to 360 degrees, almost north again) of obstacles, > trees. My purpose was to feed this profile of obstacles (trees) to an > astronomy program that would then account for not sighting objects below the > trees. > > When I got around to entering them into the program by a file, I found it > required the alt at 360 azimuth points in order from 0 to 360 (same as 0). > Instead I have about 25 points, and expected the program to be able to do > simple linear interpolation between those. > > Is there some simple operational device in Python that would allow me to > create an array (vector) of 360 points from my data by interpolating between > azimuth points when necessary? All my data I rounded to the nearest integer. > Maybe there's an interpolation operator? > > As an example, supposed I had made 3 observations: (0,0) (180,45) and > (360,0). I would want some thing like (note the slope of the line from 0 to > 179 is 45/180 or 0.25): > alt: 0, 0.25, 0.50, 0.75, ... 44.75, 45.0 > az : 0, 1, 2, 3, 180 > > Of course, I don't need the az. > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet > > Web Page: <www.speckledwithstars.net/>
Linear interpolation is simple, any mathematician would know. It's just like this: hA = height at point A hB = height at point B hN = height at point N (what we're finding) l = horizontal distance between A and B n = horizontal position measured from A hN = hA + ((n / l) * (hB - hA)) so: def interpolate(n, A, B): # A, B is two-tuple of (angle, height) of # the nearest known points surrounding n oA, hA = A oB, hB = B l = oB - oA return hA + ((n / l) * (hB - hA)) -- http://mail.python.org/mailman/listinfo/python-list