def conv(e, mu, kernel='gaussian', fwhm_e=None, efermi=None):
    f = np.copy(mu)
    z = np.zeros_like(f)
    if efermi is not None:
        #ief = index_nearest(e, efermi)
        ief = np.argmin(np.abs(e-efermi))
        f[0:ief] *= 0
    if e.shape != fwhm_e.shape:
        print("Error: 'fwhm_e' does not have the same shape of 'e'")
        return 0
    # linar fit upper part of the spectrum to avoid border effects
    # polyfit => pf
    lpf = len(e)/2.
    cpf = np.polyfit(e[-lpf:], f[-lpf:], 1)
    fpf = np.poly1d(cpf)
    # extend upper energy border to 3*fhwm_e[-1]
    estep = (e[-1] - e[-2])
    eup = np.append(e, np.arange(e[-1]+estep, e[-1]+3*fwhm_e[-1], estep))
    for n in range(len(f)):
        #from now on I change e with eup
        eimin, eimax = get_ene_index(eup, eup[n], 1.5*fwhm_e[n])
        if ((eimin is None) or (eimax is None)):
            if DEBUG:
                raise IndexError('e[{0}]'.format(n))
        if len(range(eimin, eimax)) % 2 == 0:
            kx = eup[eimin:eimax+1] # odd range centered at the convolution point
        else:
            kx = eup[eimin:eimax]
        ### kernel ###
        hwhm = fwhm_e[n]/2.0
        if ('gauss' in kernel.lower()):
            ky = gaussian(kx, cen=eup[n], sigma=hwhm)
        elif ('lor' in kernel.lower()):
            ky = lorentzian(kx, cen=eup[n], sigma=hwhm)
        else:
            raise ValueError("convolution kernel '{0}' not implemented".format(kernel))
        ky = ky/ky.sum() # normalize
        zn = 0
        lk = len(kx)
        for mf, mg in zip( range(-(lk/2), (lk/2)+1), range(lk) ):
            if ( ((n+mf) >= 0) and ((n+mf) < len(f)) ):
                zn += f[n+mf] * ky[mg]
            elif ((n+mf) >= 0):
                zn += fpf(eup[n+mf]) * ky[mg]
        z[n] = zn
    return z
value is in the range [low, high]
dataset/ETHPy150Open xraypy/xraylarch/plugins/math/convolution1D.py/conv--crossover with--dataset/ETHPy150Open fictorial/pygameui/pygameui/slider.py/SliderView.value