As promised, here's the wrap-up of my search for a plot tool.
Per the advice received in this forum, I first made the straightforward
change to use numpy arrays. That lead me to take a closer look at SciPy.
After that, the plot package became obvious: I've decided to use pylab's
plot() facility (http://matplotlib.sourceforge.net/tutorial.html). It
is almost trivially easy for a pynewbie to deploy, and the end-user gets
powerful and intuitive plot manipulation tools.
My thanks to all responders to this thread for their time and advice.
Python rocks! Even for (especially for?) embedded soft-real-time
numerically-intensive multi-threaded applications such as mine.
I can hardly express the joy I feel to have finally left make behind,
and the associated linker and compiler flag tweaking: It was like
developing a whole 'nother application just to build my application.
The vast diversity and ease-of-use of the gazillion stable and mature
Python packages out there, well, let's just say I'm finally becoming the
lazy programmer I've always wanted to be. I haven't reinvented any
wheels so far this year!
Thanks again,
-BobC
(newbius pythonicus intermedius)
Christopher Barker wrote:
Robert Cunningham wrote:
Thanks for the code! I'll study it, and the alternatives you
recommended, then get back to the list with the result.
let us know.
If anyone wants to beat on this to make it more "Pythonic", I'm here to
learn...
* use numpy -- you will be glad you did. for example:
> # A really dumb max() function. There's got to be a better way...
> max = theChannels[chan].aTheSpectrum.aSpectrum[0]
> for i in range(1,count):
> if max < theChannels[chan].aTheSpectrum.aSpectrum[i]:
> max = theChannels[chan].aTheSpectrum.aSpectrum[i]
import numpy as N
Spectrum = N.array(theChannels[chan].aTheSpectrum.aSpectrum)
# though it should probably be a numpy array to begin with
max = Spectrum.max()
Not only clean, but much faster.
(and if you store all the channels in one 2-d array, you could calculate
all the maximums in one call)
Not only clean, but much faster. though now that I think about it,
python's max() function works fine on lists an tuples too:
Max = max(N.array(theChannels[chan].aTheSpectrum.aSpectrum))
(careful using "max" as a name, it overwrite python's "max()" function)
But numpy is still faster, and better for this sort of thing in a lot of
ways.
str = "Max counts = %d. Each '|' = %0.2f counts. Longest line
is 100 '|' long.\n"%(max,(1/scale))
for i in range(0,count):
str += "% 4d "%i +
"|"*int(theChannels[chan].aTheSpectrum.aSpectrum[i]*scale) + "\n"
don't use str += when building up a long string -- it makes a new string
each time through the loop. Instead, use a list of string, then put them
together:
> bars = []
> for i in range(0,count):
> bars.append("% 4d "%i +
"|"*int(theChannels[chan].aTheSpectrum.aSpectrum[i]*scale) + "\n")
str = "".join(bars)
-Chris
--
Robert Cunnigham
Chief Engineer, SDTI
[EMAIL PROTECTED]
Ph: 858-332-0700 ext. 118
Fax:858-332-0709
SD Technologies, Inc.
C/O Space Micro, Inc.
http://www.spacemicro.com/
10401 Roselle Street Suite 400
San Diego, CA 92121
begin:vcard
fn:Robert Cunningham
n:Cunningham;Robert
org:Space Micro;DSD
adr;dom:;;10401 Roselle Street, Suite 400;San Diego;CA;92121
email;internet:[EMAIL PROTECTED]
title:Chief Engineer
tel;work:858-332-0700 x118
tel;fax:858-332-0709
url:http://www.spacemicro.com
version:2.1
end:vcard
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas