| Home | Trees | Indices | Help |
|---|
|
|
Filter non-equidistant signals (spectra, timeseries...).
Currently implemented:
Example usage:
Generate some data:
>>> x = np.linspace(0,150,10000) >>> x_= np.linspace(0,150,100) >>> y = np.sin(2*pi/20.*x)+np.random.normal(size=len(x))
Apply some filter:
>>> x1,y1,pnts = filter_signal(x,y,"gauss",sigma=1) >>> x2,y2,pnts = filter_signal(x,y,"pijpers",delta=1) >>> x3,y3,pnts = filter_signal(x,y,"box",window_width=10) >>> x3_,y3_,pnts = filter_signal(x,y,"box",window_width=10,x_template=x_,threads=2)
>>> import pylab as pl >>> p = pl.plot(x,y,'ko') >>> p = pl.plot(x1,y1,'ro',mec='r',label='Gauss') >>> p = pl.plot(x2,y2,'bo',mec='b',label='Pijpers') >>> p = pl.plot(x3,y3,'go',mec='g',label='Box') >>> p = pl.plot(x3_,y3_,'gs',label='Box with template') >>> p = pl.legend()
|
|||
|
|||
| Main filter program for convolution-based filters | |||
|---|---|---|---|
| tuple |
|
||
| Basic functions for convolution-based filters | |||
| (float,float) |
|
||
| Convolution-based filter kernels and Windows | |||
| (float,float) |
|
||
|
|||
| float |
|
||
| (float,float) |
|
||
|
|||
| (float,float) |
|
||
|
|||
| (float,float) |
|
||
|
|||
|
|||
logger = logging.getLogger("TS.FILTERING")
|
|||
|
|||
Filter a signal. Handles equidistant and non-equidistant data. It is possible to define a new template For some filters, it is possible to set an adjustable window: that is,
you can give an array to the Example usage: Generate some data: >>> import time >>> x = np.linspace(0,150,10000) >>> y = np.sin(2*np.pi/20.*x)+np.random.normal(size=len(x)) Apply some filter: >>> c0 = time.time() >>> x1,y1,pnts = filter_signal(x,y,"gauss",sigma=1) >>> print time.time()-c0 >>> c0 = time.time() >>> x1,y1,pnts = filter_signal(x,y,"gauss",sigma=1,threads=2) >>> print time.time()-c0 Output parameter
|
Define general window
|
Define Gaussian_window
|
Define Gaussian kernel.
#Import necessary modules:
#>>> from pylab import plot,figure,title,subplot
#>>> from sigproc.timeseries import tfreq
#Generate some data:
#>>> x = linspace(0,150,10000)
#>>> y = random.normal(size=len(x))
#Apply Gaussian filter twice, subtract and calculate periodogram:
#>>> y1,pnts = filter_signal(x,y,"gauss",sigma=1)
#>>> y2,pnts = filter_signal(x,y,"gauss",sigma=3)
#Plot the results:
#>>> p=figure(figsize=(8,18))
#>>> p=subplot(311);p=title("GAUSSIAN FILTER")
#>>> p=plot(x,y,'ko')
#>>> p=plot(x,y1,'r-',linewidth=2)
#>>> p=plot(x,y2,'b-',linewidth=2)
#>>> p=subplot(312)
#>>> p=plot(x,y1-y2,'ko')
#>>> p=subplot(313)
#>>> p=plot(per1[0],per1[1],'k-')
#>>> p=plot(per2[0],per2[1],'r-')
@rtype: (ndarray,)
|
Median Absolute Deviation of a 1D array: median(abs(a - median(a))) / c
|
Defines the INL window
|
Iterative Nonlinear Filter (Aigrain).
Example usage:
#Import necessary modules:
#>>> from pylab import plot,figure,title,subplot
#>>> from sigproc.timeseries import tfreq
#Generate some data:
#>>> x = linspace(0,150,10000)
#>>> y = sin(2*pi*x/20.*x)+random.normal(size=len(x))
#Apply INL filter twice, subtract and calculate periodogram:
#>>> y1,pnts1,mads = filter_signal(x,y,"inl",window_width=1)
#>>> y2,pnts2,mads = filter_signal(x,y,"inl",window_width=10)
#>>> freq1,per1,stat1 = tfreq.scargle(x,y,norm='amplitude',fn=4)
#>>> freq2,per2,stat2 = tfreq.scargle(x,y1-y2,norm='amplitude',fn=4)
#Plot the results:
#>>> p=figure(figsize=(8,18))
#>>> p=subplot(311);p=title("INL FILTER")
#>>> p=plot(x,y,'ko')
#>>> p=plot(x,y1,'r-',linewidth=2)
#>>> p=plot(x,y2,'b-',linewidth=2)
#>>> p=subplot(312)
#>>> p=plot(x,y1-y2,'ko')
#>>> p=subplot(313)
#>>> p=plot(per1[0],per1[1],'k-')
#>>> p=plot(per2[0],per2[1],'r-')
@rtype: (ndarray,ndarray)
@return: continuum,sigma
|
Defines the window for the Pijpers filter.
|
Defines the Pijpers (2006) filter kernel.
Equals box-multiplying in the frequency domain.
Example usage:
#Import necessary modules:
#>>> from pylab import plot,figure,title,subplot
#>>> from sigproc.timeseries import tfreq
#Generate some data:
#>>> x = linspace(0,150,10000)
#>>> y = random.normal(size=len(x))
#Apply Gaussian filter twice, subtract and calculate periodogram:
#>>> y1,pnts1 = filter_signal(x,y,"pijpers",delta=1)
#>>> y2,pnts2 = filter_signal(x,y,"pijpers",delta=3)
#>>> freq1,per1,stat1 = tfreq.scargle(x,y,norm='amplitude',fn=4)
#>>> freq2,per2,stat2 = tfreq.scargle(x,y1-y2,norm='amplitude',fn=4)
#Plot the results:
#>>> p=figure(figsize=(8,18))
#>>> p=subplot(311);p=title("PIJPERS FILTER")
#>>> p=plot(x,y,'ko')
#>>> p=plot(x,y1,'r-',linewidth=2)
#>>> p=plot(x,y2,'b-',linewidth=2)
#>>> p=subplot(312)
#>>> p=plot(x,y1-y2,'ko')
#>>> p=subplot(313)
#>>> p=plot(per1[0],per1[1],'k-')
#>>> p=plot(per2[0],per2[1],'r-')
@rtype: (ndarray,)
@return: convolved signal
|
Defines the window for the box-filter.
|
Defines the Box filter kernel (moving average).
Equals sinc-multiplication of frequency domain.
Example usage:
#Import necessary modules:
#>>> from pylab import plot,figure,title,subplot
#>>> from sigproc.timeseries import tfreq
#Generate some data:
#>>> x = linspace(0,150,10000)
#>>> y = random.normal(size=len(x))
#Apply Gaussian filter twice, subtract and calculate periodogram:
#>>> y1,pnts = filter_signal(x,y,"box",window_width=1)
#>>> y2,pnts = filter_signal(x,y,"box",window_width=3)
@rtype: (ndarray,)
@return: convolved signal
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Fri Mar 30 10:45:19 2018 | http://epydoc.sourceforge.net |