Thanks Guys for all your prompt responses. I have tried to use the provided solutions but I am had my share of issues mixed with my lack of knowledge to the point that I feel quite embarrassed to bother you guys. Issue 1 I am running FC 3 with native python-2.3 and then I installed python-2.4 in it. numarray-1.5.1 seems to have installed with success in python-2.3. I have tried to install numpy-0.9.6-1.i586.rpm but I don't have python-base and when I try to install python-base I get a long list of dependency lists which I need. I haven't further pursued down that line, unfortunately I haven't been able to use numarray, I don't know how to use it because ppl have repeatedly told me to use numpy but I can't seem to get that installed. Issue 2 To input the file, Ryan suggested to use scipy, I don't want to go down that path, if only there is a simple way to input the file, (i can clean up the file and format it in the right way in perl, I can do that in a heartbeat) Issue 3 I don't want to use gnuplot functionality, or mathplot, if only I am able to write the file then again I can use perl to format it and use gnuplot then, So if there is the simplest of ways in which I can just i) read the file (formatting will be done in perl) ii) get the fft iii) write the file or files (and then use perl to format for gnuplot) I am sure all of you will say why not use the existing functionalities, but after 3 days I haven't gotten anywhere. All I need to do is get FFT of some sound files so that I can verify the result of FFT's and compare them with my FFT code in VxWorks. An Pierre, I started reading diveintopython.pdf but got nowhere when I tried two of its examples, the attached image shows that when I tried to run one of the examples on python-2.3 and the output wasn't according to what the guide suggested. (no output to be precise) http://jobim.colorado.edu/~sohail/pythonExample.JPG Thanks again guys. Quoting Ryan Krauss <ryanlists@gmail.com>:
I guess it depends on how much you want to learn and what you want to do.
I was able to load your data using data=scipy.io.read_array('monkey.dat')
I had to comment out the first line to make it work. I couldn't make the fromfile method of numpy work because the data is actually fixed width.
If you don't want to install scipy, you would need to learn enough Python to read the file and clean it up a little by hand.
It seems like the first column is time and the second is the signal you want to fft. I was able to fft it with: myfft=numpy.fft(data[:,1]) (I don't have the latest version of numpy and don't seem to have the refft function Robert mentioned).
t=data[:,0] df=1/max(t) df maxf=8012 fvect=arange(0,maxf+df,df)
plot(fvect,abs(myfft))
I am plotting using matplotlib and the resulting figures are attached.
If you really want to learn python for scientific and plotting applications, I would highly recommend a few packages: SciPy - some additional capabilities beyond Numpy (optimization, ode's , ...) ipython - it is a really good interactive python shell matplotlib - the best python 2d plotting package I am aware of
Let me know if you have any additional questions. You can find out about each package by googling it. They are all closely related to Numpy and all have good mailing lists to help you.
Ryan
Do let me know if you get somewhere.
Thanks
Quoting Ryan Krauss <ryanlists@gmail.com>:
email me the dat file and I could play with it a bit. If I can read your input file, the rest should be easy.
Ryan
Hi guys
I have never used python, but I wanted to compute FFT of audio files, I came upon a page which had python code, so I installed Numpy but after beating
On 4/15/06, Saqib bin Sohail <Saqib.Sohail@colorado.edu> wrote: the
bush for a few days, I have finally come in here to ask. After taking
On 4/15/06, Saqib bin Sohail <Saqib.Sohail@colorado.edu> wrote: the
FFT I
want to output it to a file and the use gnuplot to plot it.
When I instaled NumPy, and ran the tests, it seemed that all passed without a problem. My input is a .dat file converted from .wav file by sox.
Here is the code which obviously doesn't work because it seems that changes have occured since this code was written. (not my code, just from some website where a guy had written on how to do things which i require)
import Numeric import FFT out_array=Numeric.array(out) out_fft=FFT.fft(out)
offt=open('outfile_fft.dat','w') for x in range(len(out_fft)/2): offt.write('%f %f\n'%(1.0*x/wtime,abs(out_fft[x].real)))
I do the following at the python prompt
import numarray myFile = open('test.dat', 'r') my_array = numarray.arra(myFile)
/* at this stage I wanted to see if it was correctly read */
print myArray [1632837691 1701605485 1952535072 ..., 538976288 538976288 168632368]
it seems that these values do not correspond to the values in the file (but I guess the array is considering these as ints when infact these are floats)
anyway the problem starts when i try to do fft, because I can't seem to find module or how to invoke it,
the second problem is writing to the file, that code obviously doesn't work, and in my search through various documentations, i found arrayrange() but couldn't make it to work, call me stupid, but despite going through several examples, i haven't been able to make the for loop worked in any case,
it would be very kind of someone if he could at least tell me what i am doing wrong and reply a simple example so that I can modify my code or at least be able to understand .
Thanks
-- Saqib bin Sohail PhD ECE University of Colorado at Boulder Res: (303) 786 0636 http://ucsu.colorado.edu/~sohail/index.html
------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- Saqib bin Sohail PhD ECE University of Colorado at Boulder Res: (303) 786 0636 http://ucsu.colorado.edu/~sohail/index.html
-- Saqib bin Sohail PhD ECE University of Colorado at Boulder Res: (303) 786 0636 http://ucsu.colorado.edu/~sohail/index.html
Saqib bin Sohail wrote:
An Pierre, I started reading diveintopython.pdf but got nowhere when I tried two of its examples, the attached image shows that when I tried to run one of the examples on python-2.3 and the output wasn't according to what the guide suggested. (no output to be precise)
Note the indentation. Indentation is important in Python.
Quoting Ryan Krauss <ryanlists@gmail.com>:
(I don't have the latest version of numpy and don't seem to have the refft function Robert mentioned).
My example was wrong. It should have used "numpy.dft.refft()", not "numpy.refft()". -- Robert Kern robert.kern@gmail.com "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Saqib bin Sohail wrote:
I am sure all of you will say why not use the existing functionalities, but after 3 days I haven't gotten anywhere. All I need to do is get FFT of some sound files so that I can verify the result of FFT's and compare them with my FFT code in VxWorks.
Well, if you are just trying to get an independent verification of your VxWorks FFT code, and you are much more comfortable with Perl, then you might want to use one of the FFT libraries available for Perl like Math::FFT. -- Robert Kern robert.kern@gmail.com "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Alright Saqib, Robert is right that you should try fft in perl if you don't want to learn Python. But as I understand it, you want to read in this file, fft it, and write the fft to a file using only numarray. Attached is a script that does that. Most of the script is just low-level file io to avoid having to install scipy to read and write the arrays. Hope this helps, Ryan On 4/16/06, Robert Kern <robert.kern@gmail.com> wrote:
Saqib bin Sohail wrote:
I am sure all of you will say why not use the existing functionalities, but after 3 days I haven't gotten anywhere. All I need to do is get FFT of some sound files so that I can verify the result of FFT's and compare them with my FFT code in VxWorks.
Well, if you are just trying to get an independent verification of your VxWorks FFT code, and you are much more comfortable with Perl, then you might want to use one of the FFT libraries available for Perl like Math::FFT.
-- Robert Kern robert.kern@gmail.com
"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (3)
-
Robert Kern
-
Ryan Krauss
-
Saqib bin Sohail