Gaussian line profile using numeric python
John J. Lee
phrxy at csv.warwick.ac.uk
Thu Mar 29 13:01:44 EST 2001
On 29 Mar 2001, Konrad Hinsen wrote:
> "Geoff Low" <geoff at ou043085.otago.ac.nz> writes:
>
> > I have an extensive set of xy data that I want to convolute with a gaussian
> > profile. Below is my algorithm, which doesn't work. Can anyone see where
> > I'm being dumb?
What goes wrong? Couldn't see your original message.
> To be honest, I am too lazy to look through this. However,
Me too. :) I do have some working routines that will do gaussian
convolution, using the standard Numeric FFT module -- very simple. Or at
least would be if I didn't have a lot of stuff for using the FFTW library
in there, which doesn't actually work (the docs for the rfftw part of the
FFTW python wrapper seem to be wrong: anybody got this working?).
> 1) The function Numeric.convolve is certainly a lot more efficient
> than your code, and should make it simpler.
I seem to recall that it doesn't cover all the possibilities, though. I
don't remember exactly why, but since I wrote my own functions to do this
there must have been a reason!
> 2) If you work with large data sets, you ought to use FFTs to
> compute the convolution, that's O(N*log(N)) in the size of the
> data set, instead of O(N**2) for the straightforward method.
> Any good book on FFTs should explain how this works in detail.
but you probably don't need to know in detail, it boils down to
inv_FFT(FFT(data)*FFT(kernel))
But if you have small data sets it might be slower, of course.
> > P.S. I'm no math wizard but this is my interpretation of the gaussian lineshape
> > function
> > G(v) = 1/(sqrt(2*PI)*FWHM)*exp(-(v-vo)^2/(2*FWHM^2))
>
> Assuming that FWHM stands for full width at half minimum, no, it's not
> correct. What you call FWHM is the variance sigma of the Gaussian, the
> FWHM is around 2.35*sigma (quick calculation, no guarantee).
That number is about right, from memory.
John
More information about the Python-list
mailing list