[Numpy-discussion] numarray, Convolve, and lineshapes

Todd Miller jmiller at stsci.edu
Thu Aug 22 11:27:02 CDT 2002


Hi Jochen,

Your contribution to the Convolve package is a welcome addition provided 
that you are willing to tighten up your copyrights a little. 
 Doc/unittest.py has an example of an acceptable copyright, where 
"Python" should technically be replaced by "numarray",  but where the 
intent remains the same:  open source under a BSD-like license.

Regards,
Todd

Jochen Küpper wrote:

>Looking at Convolve last night I came up with the idea that we often
>need to convolute datasets with common profiles, such as Gauss- or
>Voigt-lineshapes, for example.
>
>So tonight I took my old module I had for that purpose apart and put
>it as submodule into Convolve. Well, currently it really only supports
>Gauss, Lorentz, and Voigt, but the general "framework" to add more
>profiles is there. Adding a new one would consist of defining a new
>derived class (overall 5 lines of code) and providing a function that
>calculates the actual line profile.
>
>I chose the implementation using functor classes so profiles can be
>reused.
>
>I am aware that there are some issues with the functions in
>Lineshape.py (error checking, not automatically converting sequences
>to arrays, ...). If this is a way to go I would move the functions to
>C anyway. Nevertheless a sample function in Python will be provided,
>so new profiles can easily added without caring about C.
>
>I would like to get some feedback whether you think this should be
>included in numarray. I believe it fits very well into Convolve.
>
>
>Example use:
>
>import numarray as num
>import random as ran
>import Convolve
>import Convolve.Lineshape as ls
>
>resolution = 0.1
>fwhm = 0.5
>
># get some (random) data, i.e. a stick-spectrum
>x = num.arange(-50, 50+resolution, resolution)
>y = num.zeros(x.shape, num.Float)
>for i in range(10):
>    y[ran.randint(0, len(y)-1)] = ran.random()
>
># create lineshape objects
>g = ls.GaussProfile(num.arange(-10*fwhm, 10*fwhm+resolution, resolution), 1.0)
>v = ls.VoigtProfile(num.arange(-10*fwhm, 10*fwhm+resolution, resolution), (0.6, 0.6))
>
># convolute data with profile
>res_g = Convolve.convolve(y, g(), Convolve.SAME)
>res_v = Convolve.convolve(y, v(), Convolve.SAME)
>for i in zip(x, y, res_g, res_v):
>    print "%12.6f %12.6f %12.6f %12.6f" % i
>
>
>I attach an archive of the whole Convolve/ dir here in my local copy.
>
>Greetings,
>Jochen
>


-- 
Todd Miller 			jmiller at stsci.edu
STSCI / SSG







More information about the Numpy-discussion mailing list