Mirror or UnMirror a Wave

These functions can be used in FFT or convolution to avoid Gibbs oscillations at endpoints. The wave is mirrored or unmirrored at its start (at = 0) or end (at = 1). For FFT, use odd = 0 to get an even number of points in return wave.

Applications
--
DoMirror(yw, 0)
Convolve/A broadening, yw
UndoMirror(yw, 0)
--
DoMirror(yw, 0, odd=0)
… do FFT operation on yw -> yw_fft
… smooth via subtraction of noise component in Fourier domain
… do inverse FFT operation on yw_fft -> yw
UnDoMirror(yw, 0, odd=0)

Function DoMirror(yw, at, [odd])
    wave/D yw
    variable at, odd
 
    variable nptso = numpnts(yw), nptsn
 
    odd = ParamIsDefault(odd) ? 1 : 0
   
    nptsn = 2*nptso + 1*odd
    Duplicate/FREE yw, ywtemp
    Redimension/N=(nptsn) yw
    switch(at)
        case 0:     // start
            yw[0,nptso-1] = ywtemp[nptso - 1 - p]
            yw[nptso] = ywtemp[0]
            yw[nptso+1*odd,nptsn-1] = ywtemp[p - 1*odd - nptso]
            break
        case 1:     // end
            yw[nptso] = ywtemp[nptso-1]
            yw[nptso+1*odd,nptsn-1] = ywtemp[nptsn - p - 1]
            break
    endswitch
    return 0
end

Function UnDoMirror(yw, at, [odd])
    wave/D yw
    variable at, odd

    odd = ParamIsDefault(odd) ? 1 : 0

    variable nptso = numpnts(yw), nptsn
   
    nptsn = (nptso - 1*odd)/2
    make/FREE/N=(nptsn) ywtemp
    ywtemp = yw[p]
    Redimension/N=(nptsn) yw
    switch(at)
        case 0:     // start
            yw = ywtemp[nptsn - 1 - p]
            break
        case 1:     // end
            break
    endswitch
    return 0
end

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More