Пример #1
0
def createFuzzySpace(space_sz, center, size, left=True, right=True):
    ###   Create an fuzzy Universe arround the center #####
    #
    #     - space_sz   = The size of output array
    #     - center     = The center of triangle. The value must be an integer value compreended in [0:space_sz-1].
    #     - size       = Integer value used to calculate the basis of triangle as "b = (2*size)+1"
    #     - left|right = Boolean to set the left or the right side of triangle.
    #
    #     Usage:
    #       from calebe import fuzzyUtils as fu
    #       fu.createFuzzySpace(10,5,3)
    #       > array([0.  , 0.  , 0.25, 0.5 , 0.75, 1.  , 0.75, 0.5 , 0.25, 0.  ])
    #       fu.createFuzzySpace(10,5,3,left=False)
    #       > array([0.  , 0.  , 0., 0. , 0., 1.  , 0.75, 0.5 , 0.25, 0.  ])
    #       fu.createFuzzySpace(10,5,3,right=False)
    #       > array([0.  , 0.  , 0.25, 0.5 , 0.75, 1.  , 0. , 0. , 0. , 0.  ])
    #
    #    Visualizing:
    #       from calebe import fuzzyUtils as fu
    #       from calebe.plotUtils import plot
    #       plot(fu.createFuzzySpace(10,5,3))
    #
    #######################################################

    # print('Creating FS',space_sz,center,size)
    fu = np.zeros(space_sz)
    triang = tf(1 + (2 * size), True)
    if (left):
        left = center - size
        add_left = -np.min([0, 0 + left])
        fu[left + add_left:center +
           1] = triang[add_left:size + 1] if add_left > 0 else triang[:size +
                                                                      1]
    if (right):
        right = center + size + 1
        remove_right = -np.min([0, space_sz - right])
        fu[center:right - remove_right] = triang[
            size:-remove_right] if remove_right > 0 else triang[size:]
    return fu
R1 = 0.25  # 2500
R2 = 1  # 10**3
C1 = 1  # 100e-6
C2 = C1  # 100e-6

##############################################################################

# Desarrollo de la Transferencia del Filtro Pasa-Banda Pasivo Según la
# Estructura Usada:

NUM = [1 / R2 * C2, 0]
DEN = [
    1, (1 / (C1 * R2) + 1 / (C1 * R1) + 1 / (C2 * R2)), 1 / (R1 * R2 * C1 * C2)
]

# Transferencia Normalizada de mi Filtro Pasa-Banda Pasivo:
my_tf = tf(NUM, DEN)

##############################################################################

# Levanto la Imagen de mi Circuito Pasivo a Utilizar:
fp_imagen = './Circuito_Ejercicio3_PasaBanda.jpg'
i = im.open(fp_imagen, 'r')  # Abro la Imagen.
i.show()  # Muestro la Imagen en una Ventana.

##############################################################################

# Ploteo de la Respuesta de Módulo y Respuesta de Fase y el Retardo de Grupo:
bodePlot(my_tf)
pzmap(my_tf)
grpDelay(my_tf)
Пример #3
0
alfa_min = 40  #dB    Mínima Atenuación en la Banda de Stop.

eps = 1  # Ripple

my_N = [2, 3, 4]  #Orden de mis Filtros.

# Diseño de los Filtros:

# ---------------------------------------------------------------------------

# N = 2:

# Filtro Chebyshev Tipo I:
z1, p1, k1 = sig.cheb1ap(my_N[0], eps)
NUM1, DEN1 = sig.zpk2tf(z1, p1, k1)
tf_ch1 = tf(NUM1, DEN1)

# Filtro Chebyshev Tipo II o Chebyshev Inverso:
z2, p2, k2 = sig.cheb2ap(my_N[0], alfa_min)
NUM2, DEN2 = sig.zpk2tf(z2, p2, k2)
tf_ch2 = tf(NUM2, DEN2)

analyze_sys([tf_ch1, tf_ch2],
            ['Cheby Tipo I Orden 2', 'Cheby Tipo II o Inverso Orden 2'])

# ---------------------------------------------------------------------------

# N = 3:

# Filtro Chebyshev Tipo I:
z1, p1, k1 = sig.cheb1ap(my_N[1], eps)
Пример #4
0
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

# Llevo mi Filtro Prototipo (Low-Pass) a mi Filtro Destino (High-Pass)

if (eps != 1):  # Caso de Máxima Planicidad!!

    wb_hp = 1 / abs(wb_lp)  # Omega de Butterworth High Pass
    NUM_hp, DEN_hp = sig.lp2hp(NUM, DEN, wb_hp)  # Renormalizo con wb_hp

else:
    NUM_hp, DEN_hp = sig.lp2hp(NUM, DEN)  # Caso de Butterworth

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

# Calculo la Transferencia de mi Filtro Objetivo (High-Pass)

my_tf_lp = tf(NUM_lp, DEN_lp)
my_tf_hp = tf(NUM_hp, DEN_hp)

# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------

# Ploteo

bodePlot(my_tf_hp, 'Filtro High Pass')
pzmap(my_tf_hp, 'none', 'Filtro Destino - High Pass')
pzmap(my_tf_lp, 'none', 'Filtro Prototipo - Low Pass')
    z, p, k = sig.cheb1ap (order_filter, ripple_) 
    
    
elif (aprox_name == 'Bessel'):
    
    z, p, k = sig.besselap ( order_filter, norm = 'mag' )
    
    
else:
    
    sys.exit(' No Existe esa Aproximación o Está mal Escrita.')
    

# Genero el Numerador y Denominador de mi Transferencia
NUM, DEN = sig.zpk2tf(z, p, k)

my_tf = tf ( NUM, DEN ) # Genero mi Transferencia


# Ploteo.
bodePlot (my_tf)
pzmap (my_tf)
#grpDelay (my_tf)