Filling in Degrees in a Circle (Astronomy)

W

W. eWatson

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/>
 
M

Mensanator

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.

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.
print (az,az*0.25),

(0, 0.0) (1, 0.25) (2, 0.5) (3, 0.75)
(4, 1.0) (5, 1.25) (6, 1.5) (7, 1.75)
(8, 2.0) (9, 2.25) (10, 2.5) (11, 2.75)
(12, 3.0) (13, 3.25) (14, 3.5) (15, 3.75)
(16, 4.0) (17, 4.25) (18, 4.5) (19, 4.75)
(20, 5.0) (21, 5.25) (22, 5.5) (23, 5.75)
etc.

But are you saying if you have two readings of tree tops

*
*
*
*
* *
* *
____*___*______


And you linearly interpret between them

/
/*
/ *
/ *
/ *
/* *
* *
____*___*______

that the area below the dashed line is assumed to be hidden?

That wouldn't necessarily be true, as the tree profile could
dip below the line.

/
/*
/ *
/ **
/ ***
/* ****
** ****
___***_****____

Of course, if you take enough points, the open areas may be small
enough not to be practical to worry about.
 
M

Maric Michaud

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 ?
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]
 
W

W. eWatson

Mensanator said:
print (az,az*0.25),

(0, 0.0) (1, 0.25) (2, 0.5) (3, 0.75)
(4, 1.0) (5, 1.25) (6, 1.5) (7, 1.75)
(8, 2.0) (9, 2.25) (10, 2.5) (11, 2.75)
(12, 3.0) (13, 3.25) (14, 3.5) (15, 3.75)
(16, 4.0) (17, 4.25) (18, 4.5) (19, 4.75)
(20, 5.0) (21, 5.25) (22, 5.5) (23, 5.75)
etc.
Yes, that works, but that was only a simple illustration. My data looks in
fact looks like this (only a few values given:
Az Alt
0 18
18 18
27 16
34 20
48 20
....
268 28
290 32
....
So the python software should generate
0 18
1 18
2 18
3 18
.... the trees are all about 18 degrees high
18 18
19 17.9 we have a slight slope. I'm using values that might be close
20 27.75
21
....
27 16
28 16.4 now the trees are starting to get a little higher
29 16.9
....
359 18 (most likely. I didn't have the patience to make a measure at 359)

That should pretty well illustrate it. In actuality, as I swept around the
circle, the tree line becomes much more abrupt than those first few data
points. The tallest tree is at 36 degrees and is among some other equally
tall trees.
But are you saying if you have two readings of tree tops

*
*
x *
x *
* x *
* x *
____*_x_*______


And you linearly interpret between them
exactly. I put a value there -- x
/
/*
/ *
/ *
/ *
/* *
* *
____*___*______

that the area below the dashed line is assumed to be hidden?
Yes, the telescope software will see that it cannot move the telescope into
that area. Surprisingly, they use interpolation. For example, suppose the
two trees in your illustration are at an az of 100 and 101, and the two
altitudes are 3 and 7. Suppose the telescope wants to go below the line into
100.622 az and an alt of 2.42. The software will say no you don't.
 
C

Carl Banks

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?

There's nothing built in, but see the bisect module. It is a good way
to determine which interval you are in, and you can interpolate the
points yourself.


Carl Banks
 
W

W. eWatson

Maric said:
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/>
 
W

W. eWatson

Carl said:
There's nothing built in, but see the bisect module. It is a good way
to determine which interval you are in, and you can interpolate the
points yourself.


Carl Banks
I'll take a look. I just posted above yours with a more insightful set of
data than the first three pointer. Yes, some way of bisecting, or chopping
is the trick here. One is just trying to fill in all the gaps with
interpolation and produce 360 points to feed to the telescope software. It's
sort of like giving someone, and forgetting interpolation here, the sequence
20, 30, blank, 60, 70, 80 and asking for the two missing tens between 30 and
60. 40 and 50, of course.

The fellow above wrote an interpolate function that will probably fit the bill.

--
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/>
 
W

W. eWatson

Scott said:
W. eWatson said:
...
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.

A standard windows error. note that '\t' is a tab, and I doubt you have
a directory named <tab> <m> <p>. Get in the habit of _always_ using:
junkfile = open(r'c:\tmp\junkpythonfile','w')
or
junkfile = open('c:\\tmp\\junkpythonfile','w')
for file names.

--Scott David Daniels
(e-mail address removed)
Thanks. r did the job nicely.

--
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/>
 
T

tom

W. eWatson said:
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.


If I understand you right, I think using interpolation as provided by
scipy would do what you need.

Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1: # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
 
W

W. eWatson

I completed a Win Python program and it has generated the necessary data,
which I have in turn used successfully with the telescope software. Is there
some way to turn this into an executable program for people who do not have
Python?

--
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/>
 
W

W. eWatson

tom said:
W. eWatson said:
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.


If I understand you right, I think using interpolation as provided by
scipy would do what you need.

Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1: # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
I decided this morning and roll up my sleeves and write the program. I plan
to take a deeper plunge in the next month than my so far erratic look over
the last 18 or more months It's working.

The above looks like it's on the right track. Is scipy some collection of
astro programs? mx is a graphics character plot?

I just hauled it into IDLE and tried executing it.
from scipy.interpolate.interpolate import interp1d
ImportError: No module named scipy.interpolate.interpolate

Apparently, something is missing.

I posted a recent msg a bit higher that will probably go unnoticed, so I'll
repeat most of it. How do I get my py code into some executable form so that
Win users who don't have python can execute it?


--
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/>
 
W

W. eWatson

Dennis said:
I'll take a look. I just posted above yours with a more insightful set of
data than the first three pointer. Yes, some way of bisecting, or chopping
is the trick here. One is just trying to fill in all the gaps with
interpolation and produce 360 points to feed to the telescope software. It's
sort of like giving someone, and forgetting interpolation here, the sequence
20, 30, blank, 60, 70, 80 and asking for the two missing tens between 30 and
60. 40 and 50, of course.

Presuming the data is an ordered list (in azimuth) of az/el pairs,
AND that the last measurement does not close the circle (eg: (0, 1),
(90, 5), (180, 5), (270, 2) ) the first step would be to append a data
point consisting of the first azimuth data point + 360, but with the
same elevation value. With normalization at the output, this would work
if the first data point was not at 0. Then one would perform repeated
interpolations over pairs of data points, outputting the first pair as
the first value, and stopping when the azimuth reached the second pair.

Something like (watch out for line wrapping):

-=-=-=-=-=-=-
import pprint

def gatherPoints():
pointList = []
while True:
cAz = raw_input("Enter Azimuth in integer degrees (blank line to
exit) : ")
cAz = cAz.strip()
if not cAz: break
az = int(cAz)
cEl = raw_input("Enter Elevation in real degrees for azimuth %s
: " % az).strip()
el = float(cEl)
pointList.append( (az, el) )
if pointList:
pointList.append( (pointList[0][0] + 360, pointList[0][1]) )
return pointList

def interpolate(start, end, step):
slope = float(end[1] - start[1]) / (end[0] - start[0])
iPoints = [ (i, (slope * (i - start[0])) + start[1])
for i in range(start[0], end[0], step) ]
return iPoints


if __name__ == "__main__":
points = gatherPoints()
output = []
if points:
for s in range(len(points) - 1):
output.extend(interpolate(points, points[s+1], 1))
pprint.pprint(output)
-=-=-=-=-=-=-

Close. A nice looking piece of code. Something for me to learn from. I play
with python on a pretty irregular basis.

The game here is like someone gives you five distinct integer numbers from 1
to 10 in order, and one needs to write a program to fill in the gaps. In my
case, the numbers go from 0 to 359, and I have lots of gaps. I gave a pretty
illustrative example in a post above. 11:10 pm last night. Of course, not
only the gaps from 0 to 359 need to be filled in, but the interpolated
values of the related values need to be obtained. Elevation.

As I just posted to the fellow below you. I decided this morning and roll up
my sleeves and write the program. I plan to take a deeper plunge in the next
month than my so far erratic look over the last 18 or more months It's working.


--
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/>
 
T

tom

W. eWatson said:
tom said:
W. eWatson said:
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.


If I understand you right, I think using interpolation as provided by
scipy would do what you need.

Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1: # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
I decided this morning and roll up my sleeves and write the program. I
plan to take a deeper plunge in the next month than my so far erratic
look over the last 18 or more months It's working.

The above looks like it's on the right track. Is scipy some collection
of astro programs? mx is a graphics character plot?

I just hauled it into IDLE and tried executing it.
from scipy.interpolate.interpolate import interp1d
ImportError: No module named scipy.interpolate.interpolate

Apparently, something is missing.

I posted a recent msg a bit higher that will probably go unnoticed, so
I'll repeat most of it. How do I get my py code into some executable
form so that Win users who don't have python can execute it?

Both scipy and matplotlib are not part of the standard Python
distribution so they would need to be installed separately. Scipy is
useful for scientific data analysis, and matplotlib is useful for making
plots.

Since you want to wrap everything into a Windows executable, it's
probably easiest for you not to use scipy. At the least, I suspect it
would make your executable file much larger, but I've never made a
Windows executable so I don't know the details.

As for making an executable, I'm not the one to ask, but googling leads
to this:
http://effbot.org/pyfaq/how-can-i-create-a-stand-alone-binary-from-a-python-script.htm
which looks like a good place to start.

Tom
 
K

Ken Starks

tom said:
Both scipy and matplotlib are not part of the standard Python
distribution so they would need to be installed separately. Scipy is
useful for scientific data analysis, and matplotlib is useful for making
plots.

For a review of a really nice looking wrapper around lots of open-source
mathematical tools, look here:

http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/

it is called SAGE and includes both of the above and lots more goodies.

for sage itself:

http://www.sagemath.org/
 
W

W. eWatson

tom said:
W. eWatson said:
tom said:
W. eWatson 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.



If I understand you right, I think using interpolation as provided by
scipy would do what you need.

Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1: # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
I decided this morning and roll up my sleeves and write the program. I
plan to take a deeper plunge in the next month than my so far erratic
look over the last 18 or more months It's working.

The above looks like it's on the right track. Is scipy some collection
of astro programs? mx is a graphics character plot?

I just hauled it into IDLE and tried executing it.
from scipy.interpolate.interpolate import interp1d
ImportError: No module named scipy.interpolate.interpolate

Apparently, something is missing.

I posted a recent msg a bit higher that will probably go unnoticed, so
I'll repeat most of it. How do I get my py code into some executable
form so that Win users who don't have python can execute it?

Both scipy and matplotlib are not part of the standard Python
distribution so they would need to be installed separately. Scipy is
useful for scientific data analysis, and matplotlib is useful for making
plots.

Since you want to wrap everything into a Windows executable, it's
probably easiest for you not to use scipy. At the least, I suspect it
would make your executable file much larger, but I've never made a
Windows executable so I don't know the details.

As for making an executable, I'm not the one to ask, but googling leads
to this:
http://effbot.org/pyfaq/how-can-i-create-a-stand-alone-binary-from-a-python-script.htm

which looks like a good place to start.

Tom
What modules do I need to use pylab? I've installed scipy and numpy.

--
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/>
 
R

Roel Schroeven

W. eWatson schreef:
I completed a Win Python program and it has generated the necessary data,
which I have in turn used successfully with the telescope software. Is there
some way to turn this into an executable program for people who do not have
Python?

Yes, you can use py2exe (http://www.py2exe.org/) for that.

--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov

Roel Schroeven
 
T

tom

I'm using Python 2.4. The install looks pretty complicated for Windows.
It doesn't seem like matplotlib is a module.

Maybe going with the enthought edition would be easiest for you as it is
a very complete set of tools all in one package. It's at
http://www.enthought.com/products/epd.php

These are really nice tools for scientific (and other) data analysis,
and are very competitive with most professional packages. There are
other bundles as well, like Sage. I've always used enthought.

On the other hand, I think making tools that use these in a bundled exe
might be more difficult, and if possible, might not be consistent with
their license agreements, and might make for large packages. I never
really looked into this.

Also, with matplotlib, you might just try installing it without anything
else and see how it goes. Just download the exe and double-click, or
the egg file and do whatever one does with those. I bet it will work...
I think it will just default to using Tk for the GUI, which you already
have installed with Python, and it won't use agg (an anti-aliasing
library), so your plots won't be quite as pretty. But they'll still be
nice, and it will likely work.
 
D

drobinow

W. eWatson said:
...
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.

A standard windows error. note that '\t' is a tab, and I doubt you have
a directory named <tab> <m> <p>.  Get in the habit of _always_ using:
    junkfile = open(r'c:\tmp\junkpythonfile','w')
or
    junkfile = open('c:\\tmp\\junkpythonfile','w')
for file names.

--Scott David Daniels
(e-mail address removed)

Avoid backslashes whenever possible.
junkfile = open('c:/tmp/junkpythonfile','w')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top