Example #1
0
    def __init__(self,scale,sl_len,tr_area,fs,min_win=16,Qvar=1,real=False,recwnd=False,matrixform=False,reducedform=0,multichannel=False,measurefft=False):
        assert fs > 0
        assert sl_len > 0
        assert tr_area >= 0
        assert sl_len > tr_area*2
        assert min_win > 0
        assert 0 <= reducedform <= 2

        assert sl_len%2 == 0

        self.sl_len = sl_len
        self.tr_area = tr_area
        self.fs = fs
        self.real = real
        self.measurefft = measurefft
        self.userecwnd = recwnd
        self.reducedform = reducedform

        self.scale = scale
        self.frqs,self.q = self.scale()

        self.g,self.rfbas,self.M = nsgfwin(self.frqs,self.q,self.fs,self.sl_len,sliced=True,min_win=min_win,Qvar=Qvar)
        
#        print "rfbas",self.rfbas/float(self.sl_len)*self.fs
        
        if matrixform:
            if self.reducedform:
                rm = self.M[self.reducedform:len(self.M)//2+1-self.reducedform]
                self.M[:] = rm.max()
            else:
                self.M[:] = self.M.max()
                
        if multichannel:
            self.channelize = lambda seq: seq
            self.unchannelize = lambda seq: seq
        else:
            self.channelize = lambda seq: ((it,) for it in seq)
            self.unchannelize = lambda seq: (it[0] for it in seq)

        self.wins,self.nn = calcwinrange(self.g,self.rfbas,self.sl_len)
        
        self.gd = nsdual(self.g,self.wins,self.nn,self.M)
        
        self.fwd = lambda fc: nsgtf_sl(fc,self.g,self.wins,self.nn,self.M,real=self.real,reducedform=self.reducedform,measurefft=self.measurefft)
        self.bwd = lambda cc: nsigtf_sl(cc,self.gd,self.wins,self.nn,self.sl_len,real=self.real,reducedform=self.reducedform,measurefft=self.measurefft)
Example #2
0
    def __init__(self,
                 scale,
                 sl_len,
                 tr_area,
                 fs,
                 min_win=16,
                 Qvar=1,
                 real=False,
                 recwnd=False,
                 matrixform=False,
                 reducedform=0,
                 multichannel=False,
                 measurefft=False):
        assert fs > 0
        assert sl_len > 0
        assert tr_area >= 0
        assert sl_len > tr_area * 2
        assert min_win > 0
        assert 0 <= reducedform <= 2

        assert sl_len % 2 == 0

        self.sl_len = sl_len
        self.tr_area = tr_area
        self.fs = fs
        self.real = real
        self.measurefft = measurefft
        self.userecwnd = recwnd
        self.reducedform = reducedform

        self.scale = scale
        self.frqs, self.q = self.scale()

        self.g, self.rfbas, self.M = nsgfwin(self.frqs,
                                             self.q,
                                             self.fs,
                                             self.sl_len,
                                             sliced=True,
                                             min_win=min_win,
                                             Qvar=Qvar)

        #        print "rfbas",self.rfbas/float(self.sl_len)*self.fs

        if matrixform:
            if self.reducedform:
                rm = self.M[self.reducedform:len(self.M) // 2 + 1 -
                            self.reducedform]
                self.M[:] = rm.max()
            else:
                self.M[:] = self.M.max()

        if multichannel:
            self.channelize = lambda seq: seq
            self.unchannelize = lambda seq: seq
        else:
            self.channelize = lambda seq: ((it, ) for it in seq)
            self.unchannelize = lambda seq: (it[0] for it in seq)

        self.wins, self.nn = calcwinrange(self.g, self.rfbas, self.sl_len)

        self.gd = nsdual(self.g, self.wins, self.nn, self.M)

        self.fwd = lambda fc: nsgtf_sl(fc,
                                       self.g,
                                       self.wins,
                                       self.nn,
                                       self.M,
                                       real=self.real,
                                       reducedform=self.reducedform,
                                       measurefft=self.measurefft)
        self.bwd = lambda cc: nsigtf_sl(cc,
                                        self.gd,
                                        self.wins,
                                        self.nn,
                                        self.sl_len,
                                        real=self.real,
                                        reducedform=self.reducedform,
                                        measurefft=self.measurefft)
Example #3
0
    def __init__(self,
                 scale,
                 sl_len,
                 tr_area,
                 fs,
                 min_win=16,
                 Qvar=1,
                 real=False,
                 recwnd=False,
                 matrixform=False,
                 reducedform=0,
                 multichannel=False,
                 measurefft=False,
                 multithreading=False,
                 dtype=float):
        assert fs > 0
        assert sl_len > 0
        assert tr_area >= 0
        assert sl_len > tr_area * 2
        assert min_win > 0
        assert 0 <= reducedform <= 2

        assert sl_len % 4 == 0
        assert tr_area % 2 == 0

        self.sl_len = sl_len
        self.tr_area = tr_area
        self.fs = fs
        self.real = real
        self.measurefft = measurefft
        self.multithreading = multithreading
        self.userecwnd = recwnd
        self.reducedform = reducedform

        self.scale = scale
        self.frqs, self.q = self.scale()

        self.g, self.rfbas, self.M = nsgfwin(self.frqs,
                                             self.q,
                                             self.fs,
                                             self.sl_len,
                                             sliced=True,
                                             min_win=min_win,
                                             Qvar=Qvar,
                                             dtype=dtype)

        #        print "rfbas",self.rfbas/float(self.sl_len)*self.fs
        if real:
            assert 0 <= reducedform <= 2
            sl = slice(reducedform, len(self.g) // 2 + 1 - reducedform)
        else:
            sl = slice(0, None)

        # coefficients per slice
        self.ncoefs = max(
            int(ceil(float(len(gii)) / mii)) * mii
            for mii, gii in zip(self.M[sl], self.g[sl]))

        if matrixform:
            if self.reducedform:
                rm = self.M[self.reducedform:len(self.M) // 2 + 1 -
                            self.reducedform]
                self.M[:] = rm.max()
            else:
                self.M[:] = self.M.max()

        if multichannel:
            self.channelize = lambda seq: seq
            self.unchannelize = lambda seq: seq
        else:
            self.channelize = lambda seq: ((it, ) for it in seq)
            self.unchannelize = lambda seq: (it[0] for it in seq)

        self.wins, self.nn = calcwinrange(self.g, self.rfbas, self.sl_len)

        self.gd = nsdual(self.g, self.wins, self.nn, self.M)

        self.fwd = lambda fc: nsgtf_sl(fc,
                                       self.g,
                                       self.wins,
                                       self.nn,
                                       self.M,
                                       real=self.real,
                                       reducedform=self.reducedform,
                                       measurefft=self.measurefft,
                                       multithreading=self.multithreading)
        self.bwd = lambda cc: nsigtf_sl(cc,
                                        self.gd,
                                        self.wins,
                                        self.nn,
                                        self.sl_len,
                                        real=self.real,
                                        reducedform=self.reducedform,
                                        measurefft=self.measurefft,
                                        multithreading=self.multithreading)
Example #4
0
    def __init__(
        self,
        scale,
        sl_len,
        tr_area,
        fs,
        min_win=16,
        Qvar=1,
        real=False,
        recwnd=False,
        matrixform=False,
        reducedform=0,
        multichannel=False,
        measurefft=False,
        multithreading=False,
        dtype=float,
    ):
        assert fs > 0
        assert sl_len > 0
        assert tr_area >= 0
        assert sl_len > tr_area * 2
        assert min_win > 0
        assert 0 <= reducedform <= 2

        assert sl_len % 4 == 0
        assert tr_area % 2 == 0

        self.sl_len = sl_len
        self.tr_area = tr_area
        self.fs = fs
        self.real = real
        self.measurefft = measurefft
        self.multithreading = multithreading
        self.userecwnd = recwnd
        self.reducedform = reducedform

        self.scale = scale
        self.frqs, self.q = self.scale()

        self.g, self.rfbas, self.M = nsgfwin(
            self.frqs, self.q, self.fs, self.sl_len, sliced=True, min_win=min_win, Qvar=Qvar, dtype=dtype
        )

        #        print "rfbas",self.rfbas/float(self.sl_len)*self.fs
        if real:
            assert 0 <= reducedform <= 2
            sl = slice(reducedform, len(self.g) // 2 + 1 - reducedform)
        else:
            sl = slice(0, None)

        # coefficients per slice
        self.ncoefs = max(int(ceil(float(len(gii)) / mii)) * mii for mii, gii in zip(self.M[sl], self.g[sl]))

        if matrixform:
            if self.reducedform:
                rm = self.M[self.reducedform : len(self.M) // 2 + 1 - self.reducedform]
                self.M[:] = rm.max()
            else:
                self.M[:] = self.M.max()

        if multichannel:
            self.channelize = lambda seq: seq
            self.unchannelize = lambda seq: seq
        else:
            self.channelize = lambda seq: ((it,) for it in seq)
            self.unchannelize = lambda seq: (it[0] for it in seq)

        self.wins, self.nn = calcwinrange(self.g, self.rfbas, self.sl_len)

        self.gd = nsdual(self.g, self.wins, self.nn, self.M)

        self.fwd = lambda fc: nsgtf_sl(
            fc,
            self.g,
            self.wins,
            self.nn,
            self.M,
            real=self.real,
            reducedform=self.reducedform,
            measurefft=self.measurefft,
            multithreading=self.multithreading,
        )
        self.bwd = lambda cc: nsigtf_sl(
            cc,
            self.gd,
            self.wins,
            self.nn,
            self.sl_len,
            real=self.real,
            reducedform=self.reducedform,
            measurefft=self.measurefft,
            multithreading=self.multithreading,
        )