示例#1
0
def set_aw(sys,poles):
    """
    Divide in controller in input and feedback part
    for anti-windup

    Usage
    =====
    [sys_in,sys_fbk] = set_aw(sys,poles)

    Inputs
    ------

    sys: controller
    poles : poles for the anti-windup filter

    Outputs
    -------
    sys_in, sys_fbk: controller in input and feedback part
    """
    sys = ct.ss(sys)
    Ts = sys.dt
    den_old = sp.poly(la.eigvals(sys.A))
    sys = ct.tf(sys)
    den = sp.poly(poles)
    tmp =  ct.tf(den_old,den,sys.dt)
    sys_in = tmp*sys
    sys_in = sys_in.minreal()
    sys_in = ct.ss(sys_in)
    sys_fbk = 1-tmp
    sys_fbk  =  sys_fbk.minreal()
    sys_fbk  =  ct.ss(sys_fbk)
    return sys_in, sys_fbk
示例#2
0
def set_aw(sys, poles):
    """Divide in controller in input and feedback part
       for anti-windup

    Usage
    =====
    [sys_in,sys_fbk]=set_aw(sys,poles)

    Inputs
    ------

    sys: controller
    poles : poles for the anti-windup filter

    Outputs
    -------
    sys_in, sys_fbk: controller in input and feedback part
    """
    #   sys=StateSpace(sys);
    sys = ss(sys)
    den_old = poly(eigvals(sys.A))
    den = poly(poles)
    tmp = tf(den_old, den, sys.dt)
    tmpss = tf2ss(tmp)
    #   sys_in=StateSpace(tmp*sys)
    sys_in = ss(tmp * sys)
    sys_in.dt = sys.dt
    #    sys_fbk=StateSpace(1-tmp)
    sys_fbk = ss(1 - tmp)
    sys_fbk.dt = sys.dt
    return sys_in, sys_fbk
示例#3
0
def set_aw(sys,poles):
    """Divide in controller in input and feedback part
       for anti-windup

    Usage
    =====
    [sys_in,sys_fbk]=set_aw(sys,poles)

    Inputs
    ------

    sys: controller
    poles : poles for the anti-windup filter

    Outputs
    -------
    sys_in, sys_fbk: controller in input and feedback part
    """
    sys = ss(sys)
    den_old=poly(eigvals(sys.A))
    sys=tf(sys)
    den = poly(poles)
    tmp= tf(den_old,den,sys.dt)
    sys_in=tmp*sys
    sys_in = sys_in.minreal()
    sys_in = ss(sys_in)
    sys_fbk=1-tmp
    sys_fbk = sys_fbk.minreal()
    sys_fbk = ss(sys_fbk)
    return sys_in, sys_fbk
def set_aw(sys,poles):
    """Divide in controller in input and feedback part
       for anti-windup

    Usage
    =====
    [sys_in,sys_fbk]=set_aw(sys,poles)

    Inputs
    ------

    sys: controller
    poles : poles for the anti-windup filter

    Outputs
    -------
    sys_in, sys_fbk: controller in input and feedback part
    """
    sys=ss(sys);
    den_old=poly(eigvals(sys.A))
    den = poly(poles)
    tmp= tf(den_old,den,sys.Tsamp)
    tmpss=tf2ss(tmp)
    sys_in=ss(tmp*sys)
    sys_in.Tsamp=sys.Tsamp
    sys_fbk=ss(1-tmp)
    sys_fbk.Tsamp=sys.Tsamp
    return sys_in, sys_fbk
示例#5
0
def set_aw(sys, poles):
    """Divide in controller in input and feedback part
       for anti-windup

    Usage
    =====
    [sys_in,sys_fbk]=set_aw(sys,poles)

    Inputs
    ------

    sys: controller
    poles : poles for the anti-windup filter

    Outputs
    -------
    sys_in, sys_fbk: controller in input and feedback part
    """
    den_old = poly(eigvals(sys.A))
    den = poly(poles)
    tmp = tf(den_old, den, sys.Tsamp)
    tmpss = tf2ss(tmp)
    sys_in = minreal(series(sys, tmp))
    sys_in.Tsamp = sys.Tsamp
    sys_fbk = tf2ss(1 - tmp)
    sys_fbk.Tsamp = sys.Tsamp
    return sys_in, sys_fbk
示例#6
0
def notch(fcut, Fs=2.0, nwid=3.0, npo=None, nzo=3):

    f0 = fcut * 2 / Fs
    fw = nwid * 2 / Fs

    z = [np.exp(1j * np.pi * f0), np.exp(-1j * np.pi * f0)]

    # find the polynomial with the specified (multiplicity of) zeros
    b = poly(np.array(z * int(nzo)))
    # the polynomial with the specified (multiplicity of) poles
    if npo is None:
        npo = nzo
    a = poly((1 - fw) * np.array(z * int(npo)))
    return (b, a)
def acker(A,B,poles):
    """Pole placemenmt using Ackermann method

    Call:
    k=acker(A,B,poles)

    Parameters
    ----------
    A, B : State and input matrix of the system
    poles: desired poles

    Returns
    -------
    k: matrix
    State feedback gains

    """
    a=mat(A)
    b=mat(B)
    p=real(poly(poles))
    ct=ctrb(A,B)
    if det(ct)==0:
        k=0
        print "Pole placement invalid"
    else:
        n=size(p)
        pmat=p[n-1]*a**0
        for i in arange(1,n):
            pmat=pmat+p[n-i-1]*a**i
        k=inv(ct)*pmat
        k=k[-1][:]
    return k
示例#8
0
def acker(A,B,poles):
    """Pole placemenmt using Ackermann method

    Call:
    k=acker(A,B,poles)

    Parameters
    ----------
    A, B : State and input matrix of the system
    poles: desired poles

    Returns
    -------
    k: matrix
    State feedback gains

    """
    a=mat(A)
    b=mat(B)
    p=real(poly(poles))
    ct=ctrb(A,B)
    if det(ct)==0:
        k=0
        print "Pole placement invalid"
    else:
        n=size(p)
        pmat=p[n-1]*a**0
        for i in arange(1,n):
            pmat=pmat+p[n-i-1]*a**i
        k=inv(ct)*pmat
        k=k[-1][:]
    return k
示例#9
0
def Weights(yCor,x,ind):
    ww = sp.zeros(4)
    base = 1
    extx = sp.concatenate(([x[-2]-1],x,[x[1]+1]))
    if yCor == x[ind]:
        ww[2] = 1
    else:
        for k in range(0,4):
            poly = sp.poly1d(sp.poly(extx[[i for i in range(base+ind-2,base+ind+2) if i != base+ind+k-2]]))
            ww[k] = poly(yCor)/poly(extx[base+ind+k-2])
        
    return ww
示例#10
0
def funcionNewton( f, a ):
     Ai = 0
     polyDef = []
     for i in range( len(a) ):
         Ai = AiNewt( f, i, a, Ai)
         b = []
         for j in range( len(a) ):
              b.append(a[i]) if j!=i
         lista = np.poly(b)
         pol = [ Ai*x for x in lista]

         polyDef = P.polyadd(poly, polyDef);

     return polyDef
示例#11
0
# Test the magToDb <-> dbToMag
i = scipy.arange(1, 7, dtype = 'f4')
a = loudia.magToDb(i)
o = loudia.dbToMag(a)

print 'magToDb/dbToMag:', scipy.allclose(i, o)

# Test the transform of windows
transf = loudia.hammingTransform(24, 10, 1024, 4096)


# Test the poly function
a = scipy.array([1, 2, 3, 4, 5])

rr = loudia.poly( a )
rs = scipy.poly( a )

print 'poly:', scipy.allclose(rr, rs)

a = scipy.array([2, 0])

rr = loudia.poly( a )
rs = scipy.poly( a[:-1] )

print 'poly, plus zero:', scipy.allclose(rr[0,:-1], rs)


# Test the zpk <--> coeffs functions
z = scipy.array([1, -0.96, 0.80])
p = scipy.array([1, 0.5, 0.5])
k = 1.2
示例#12
0
# Test the magToDb <-> dbToMag
i = scipy.arange(1, 7, dtype='f4')
a = loudia.magToDb(i)
o = loudia.dbToMag(a)

print 'magToDb/dbToMag:', scipy.allclose(i, o)

# Test the transform of windows
transf = loudia.hammingTransform(24, 10, 1024, 4096)

# Test the poly function
a = scipy.array([1, 2, 3, 4, 5])

rr = loudia.poly(a)
rs = scipy.poly(a)

print 'poly:', scipy.allclose(rr, rs)

a = scipy.array([2, 0])

rr = loudia.poly(a)
rs = scipy.poly(a[:-1])

print 'poly, plus zero:', scipy.allclose(rr[0, :-1], rs)

# Test the zpk <--> coeffs functions
z = scipy.array([1, -0.96, 0.80])
p = scipy.array([1, 0.5, 0.5])
k = 1.2
示例#13
0
#!/usr/bin/env python

# Create input
import scipy
import loudia

a = scipy.array([1, 2, 3, 4, 5])

rr = loudia.poly( a )
rs = scipy.poly( a )

print rr[0]
print rs
print scipy.allclose(rr[0], rs, rtol = 1e1)