def convolve(self, other):
     result = NDistanceFunction(self.dim)
     result.offsets = [
         so + oo for so, oo in zip(self.offsets, other.offsets)
     ]
     result.vector = Convolve.convolve(self.vector, other.vector)
     result.resetMaxDistance()
     return result
Example #2
0
def main(*args):
    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)
    l = ls.LorentzProfile(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_l = Convolve.convolve(y, l(), Convolve.SAME)
    res_v = Convolve.convolve(y, v(), Convolve.SAME)
    for i in zip(x, y, res_g, res_l, res_v):
        print "%12.6f %12.6f %12.6f %12.6f %12.6f" % i
 def convolve(self, other):
     result = NDistanceFunction(self.dim)
     result.offsets = [so + oo for so, oo in zip(self.offsets, other.offsets)]
     result.vector = Convolve.convolve(self.vector, other.vector)
     result.resetMaxDistance()
     return result