Example #1
0
    def _firwin_ord(self, F, W, A, alg):
        #http://www.mikroe.com/chapters/view/72/chapter-2-fir-filters/
        delta_f = abs(F[1] - F[0]) * 2  # referred to f_Ny
        delta_A = np.sqrt(A[0] * A[1])
        if self.fir_window_name == 'kaiser':
            N, beta = sig.kaiserord(20 * np.log10(np.abs(fb.fil[0]['A_SB'])),
                                    delta_f)
            self.led_firwin_1.setText(str(beta))
            fb.fil[0]['wdg_fil'][1] = beta
            self._update_UI()
            #self._load_dict()
            return N

        if self.firWindow == 'hann':
            gamma = 3.11
            sidelobe = 44
        elif self.firWindow == 'hamming':
            gamma = 3.32
            sidelobe = 53
        elif self.firWindow == 'blackman':
            gamma = 5.56
            sidelobe = 75
        else:
            gamma = 1
        N = remezord(F, W, A, Hz=1, alg=alg)[0]
        return N
Example #2
0
 def LPmin(self, fil_dict):
     self.get_params(fil_dict)
     (self.N, F, A, W) = remezord([self.F_PB, self.F_SB], [1, 0],
         [self.A_PB, self.A_SB], Hz = 1, alg = self.alg)
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     self.save(fil_dict, sig.firwin(self.N, fil_dict['F_C'], 
                                    window = self.firWindow, nyq = 0.5))
Example #3
0
 def HPmin(self, fil_dict):
     self._get_params(fil_dict)
     (self.N, F, A, W) = remezord([self.F_SB, self.F_PB], [0, 1],
                                  [self.A_SB, self.A_PB],
                                  Hz=1,
                                  alg=self.alg)
     #        self.N = ceil_odd(N)  # enforce odd order
     fil_dict['W_SB'] = W[0]
     fil_dict['W_PB'] = W[1]
     if (self.N % 2 == 0):  # even order
         self._save(
             fil_dict,
             sig.remez(self.N,
                       F, [0, 1],
                       weight=W,
                       Hz=1,
                       type='hilbert',
                       grid_density=self.grid_density))
     else:
         self._save(
             fil_dict,
             sig.remez(self.N,
                       F, [0, 1],
                       weight=W,
                       Hz=1,
                       type='bandpass',
                       grid_density=self.grid_density))
Example #4
0
 def _firwin_ord(self, F, W, A, alg):
     #http://www.mikroe.com/chapters/view/72/chapter-2-fir-filters/
     delta_f = abs(F[1] - F[0])
     delta_A = np.sqrt(A[0] * A[1])
     if self.fir_window_name == 'kaiser':
         N, beta = sig.kaiserord(fb.fil[0]['A_SB'], delta_f)
         self.led_firwin_1.setText(str(beta))
         fb.fil[0]['wdg_dyn'][1] = beta
         self.firWindow[1] = beta
         self._load_entries()
         return N
     
     if self.firWindow == 'hann':
         gamma = 3.11
         sidelobe = 44
     elif self.firWindow == 'hamming':
         gamma = 3.32
         sidelobe = 53
     elif self.firWindow == 'blackman':
         gamma = 5.56
         sidelobe = 75
     else:
         gamma = 1
     N = remezord(F, W, A, Hz = 1, alg = alg)[0]
     return N
Example #5
0
 def _firwin_ord(self, F, W, A, alg):
     #http://www.mikroe.com/chapters/view/72/chapter-2-fir-filters/
     delta_f = abs(F[1] - F[0])
     delta_A = np.sqrt(A[0] * A[1])
     if self.fir_window_name == 'kaiser':
         N, beta = sig.kaiserord(fb.fil[0]['A_SB'], delta_f)
         self.led_firwin_1.setText(str(beta))
         fb.fil[0]['wdg_fil'][1] = beta
         self.firWindow[1] = beta
         self._load_dict()
         return N
     
     if self.firWindow == 'hann':
         gamma = 3.11
         sidelobe = 44
     elif self.firWindow == 'hamming':
         gamma = 3.32
         sidelobe = 53
     elif self.firWindow == 'blackman':
         gamma = 5.56
         sidelobe = 75
     else:
         gamma = 1
     N = remezord(F, W, A, Hz = 1, alg = alg)[0]
     return N
Example #6
0
 def HPmin(self, fil_dict):
     self.get_params(fil_dict)
     (N, F, A, W) = remezord([self.F_SB, self.F_PB], [0, 1],
         [self.A_SB, self.A_PB], Hz = 1, alg = self.alg)
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     self.N = round_odd(N)  # enforce odd order
     self.save(fil_dict, sig.firwin(self.N, fil_dict['F_C'], 
                 window = self.firWindow, pass_zero=False, nyq = 0.5))
Example #7
0
 def LPmin(self, fil_dict):
     self._get_params(fil_dict)
     (self.N, F, A, W) = remezord([self.F_PB, self.F_SB], [1, 0],
         [self.A_PB, self.A_SB], Hz = 1, alg = self.alg)
     fil_dict['W_PB'] = W[0]
     fil_dict['W_SB'] = W[1]
     self._save(fil_dict, sig.remez(self.N, F, [1, 0], weight = W, Hz = 1,
                     grid_density = self.grid_density))
Example #8
0
 def BPmin(self, fil_dict):
     self._get_params(fil_dict)
     self.N = remezord([self.F_SB, self.F_PB, self.F_PB2, self.F_SB2], [0, 1, 0],
         [self.A_SB, self.A_PB, self.A_SB2], Hz = 1, alg = self.alg)[0]
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     fil_dict['F_C2'] = (self.F_SB2 + self.F_PB2)/2 # use average of calculated F_PB and F_SB
     self._save(fil_dict, sig.firwin(self.N, [fil_dict['F_C'], fil_dict['F_C2']],
                         window = self.firWindow, pass_zero=False, nyq = 0.5))
Example #9
0
 def BPmin(self, fil_dict):
     self._get_params(fil_dict)
     self.N = remezord([self.F_SB, self.F_PB, self.F_PB2, self.F_SB2], [0, 1, 0],
         [self.A_SB, self.A_PB, self.A_SB2], Hz = 1, alg = self.alg)[0]
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     fil_dict['F_C2'] = (self.F_SB2 + self.F_PB2)/2 # use average of calculated F_PB and F_SB
     self._save(fil_dict, sig.firwin(self.N, [fil_dict['F_C'], fil_dict['F_C2']],
                         window = self.firWindow, pass_zero=False, nyq = 0.5))
Example #10
0
 def BSmin(self, fil_dict):
     self._get_params(fil_dict)
     N = remezord([self.F_PB, self.F_SB, self.F_SB2, self.F_PB2], [1, 0, 1],
         [self.A_PB, self.A_SB, self.A_PB2], Hz = 1, alg = self.alg)[0]
     self.N = round_odd(N)  # enforce odd order
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     fil_dict['F_C2'] = (self.F_SB2 + self.F_PB2)/2 # use average of calculated F_PB and F_SB
     self._save(fil_dict, sig.firwin(self.N, [fil_dict['F_C'], fil_dict['F_C2']],
                         window = self.firWindow, pass_zero=True, nyq = 0.5))
Example #11
0
 def BSmin(self, fil_dict):
     self._get_params(fil_dict)
     N = remezord([self.F_PB, self.F_SB, self.F_SB2, self.F_PB2], [1, 0, 1],
         [self.A_PB, self.A_SB, self.A_PB2], Hz = 1, alg = self.alg)[0]
     self.N = round_odd(N)  # enforce odd order
     fil_dict['F_C'] = (self.F_SB + self.F_PB)/2 # use average of calculated F_PB and F_SB
     fil_dict['F_C2'] = (self.F_SB2 + self.F_PB2)/2 # use average of calculated F_PB and F_SB
     self._save(fil_dict, sig.firwin(self.N, [fil_dict['F_C'], fil_dict['F_C2']],
                         window = self.firWindow, pass_zero=True, nyq = 0.5))
Example #12
0
 def BSmin(self, fil_dict):
     self._get_params(fil_dict)
     (N, F, A, W) = remezord([self.F_PB, self.F_SB,
                             self.F_SB2, self.F_PB2], [1, 0, 1],
         [self.A_PB, self.A_SB, self.A_PB2], Hz = 1, alg = self.alg)
     self.N = round_odd(N)  # enforce odd order
     fil_dict['W_PB']  = W[0]
     fil_dict['W_SB']  = W[1]
     fil_dict['W_PB2'] = W[2]
     self._save(fil_dict, sig.remez(self.N,F,[1, 0, 1], weight = W, Hz = 1,
                                   grid_density = self.grid_density))
Example #13
0
    def HPmin(self, fil_dict):
        self._get_params(fil_dict)
        (self.N, F, A, W) = remezord([self.F_SB, self.F_PB], [0, 1],
            [self.A_SB, self.A_PB], Hz = 1, alg = self.alg)
#        self.N = ceil_odd(N)  # enforce odd order
        fil_dict['W_SB'] = W[0]
        fil_dict['W_PB'] = W[1]
        if (self.N % 2 == 0): # even order
            self._save(fil_dict, sig.remez(self.N, F,[0, 1], weight = W, Hz = 1, 
                        type = 'hilbert', grid_density = self.grid_density))
        else:
            self._save(fil_dict, sig.remez(self.N, F,[0, 1], weight = W, Hz = 1, 
                        type = 'bandpass', grid_density = self.grid_density))
Example #14
0
 def LPmin(self, fil_dict):
     self._get_params(fil_dict)
     (self.N, F, A, W) = remezord([self.F_PB, self.F_SB], [1, 0],
                                  [self.A_PB, self.A_SB],
                                  Hz=1,
                                  alg=self.alg)
     fil_dict['W_PB'] = W[0]
     fil_dict['W_SB'] = W[1]
     self._save(
         fil_dict,
         sig.remez(self.N,
                   F, [1, 0],
                   weight=W,
                   Hz=1,
                   grid_density=self.grid_density))
Example #15
0
 def BSmin(self, fil_dict):
     self._get_params(fil_dict)
     (N, F, A, W) = remezord([self.F_PB, self.F_SB, self.F_SB2, self.F_PB2],
                             [1, 0, 1], [self.A_PB, self.A_SB, self.A_PB2],
                             Hz=1,
                             alg=self.alg)
     self.N = round_odd(N)  # enforce odd order
     fil_dict['W_PB'] = W[0]
     fil_dict['W_SB'] = W[1]
     fil_dict['W_PB2'] = W[2]
     self._save(
         fil_dict,
         sig.remez(self.N,
                   F, [1, 0, 1],
                   weight=W,
                   Hz=1,
                   grid_density=self.grid_density))
Example #16
0
 def BPmin(self, fil_dict):
     self._get_params(fil_dict)
     (self.N, F, A,
      W) = remezord([self.F_SB, self.F_PB, self.F_PB2, self.F_SB2],
                    [0, 1, 0], [self.A_SB, self.A_PB, self.A_SB2],
                    Hz=1,
                    alg=self.alg)
     if not self._test_N():
         return -1
     fil_dict['W_SB'] = W[0]
     fil_dict['W_PB'] = W[1]
     fil_dict['W_SB2'] = W[2]
     self._save(
         fil_dict,
         sig.remez(self.N,
                   F, [0, 1, 0],
                   weight=W,
                   Hz=1,
                   grid_density=self.grid_density))