Filling in Degrees in a Circle (Astronomy)
W. eWatson
notvalid2 at sbcglobal.net
Sat Aug 23 02:10:42 EDT 2008
Maric Michaud wrote:
> Le Saturday 23 August 2008 01:12:48 W. eWatson, vous avez écrit :
>> 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.
>
> Not sure I got it, but is that fulfill your specs ?
>
>>>> [20]: def interpolate(a, b) :
> slope = float(b[1] - a[1]) / (b[0] - a[0])
> return [ slope * float(i) for i in xrange(b[0]-a[0] + 1) ]
> ....:
>
>>>> [23]: interpolate((0, 0), (180, 45))
> ...[23]:
> [0.0,
> 0.25,
> 0.5,
> 0.75,
> ....
> 44.5,
> 44.75,
> 45.0]
>
>>>> [29]: interpolate((80, 20), (180, 45))
> [0.0,
> 0.25,
> 0.5,
> 0.75,
> 1.0,
> 1.25,
> ...
> 24.5,
> 24.75,
> 25.0]
>
>
>
Yes, the interpolation part looks right, but the tricky part is to be able
to go through the list and find where one needs to generate all the missing
az angles. A chunk of my data is in a post above yours. Here's a more
revealing set of data where four data points are known:
az el
0 10
4 14 (slope is 1)
12 30 (slope is 2)
15 15 (slope is -5)
16 points need to be generated, 0 to 15, representing 15 degrees around the
circle.
So, I'm doing this in my head, one would get
0 10 (slope is 1)
1 11
2 12
3 13
4 14
5 16 (slope is 2)
6 18
7 18
...
12 30
13 25
14 20
15 15
I use Python occasionally, and starting up requires some effort, but I've
finally decided to take a go at this.
I'm working on this now, but my knowledge of python needs refreshing. Right
now I have a file of all the az,el data I've collected, and I'd like to open
it with Python for XP. However, Python doesn't like this:
junkfile = open('c:\tmp\junkpythonfile','w')
I get
junkfile = open('c:\tmp\junkpythonfile','w')
IOError: [Errno 2] No such file or directory: 'c:\tmp\\junkpythonfile'
This problematic segment is just a hack of a similar statement which has the
same problem and a much longer path. I suspect the problem is with the back
slash.
--
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/>
More information about the Python-list
mailing list