test_lqe_thiran

wield.control.SISO.test.test_lqe_thiran

This is a pytest module needing documentation

pytest-html report

Functions

lqe(A, G, C, QN, RN)

NEEDS DOC

test_Thiran_lqe(test_trigger, ...)

This is a pytest needing documentation

Details

lqe(A, G, C, QN, RN)[source][github]

NEEDS DOC

code
docstring
"""
NEEDS DOC
"""
 1def lqe(A, G, C, QN, RN):
 2
 3    A = np.array(A, ndmin=2)
 4    G = np.array(G, ndmin=2)
 5    C = np.array(C, ndmin=2)
 6    QN = np.array(QN, ndmin=2)
 7    RN = np.array(RN, ndmin=2)
 8    import scipy.linalg
 9
10    P = scipy.linalg.solve_continuous_are(A.T, C.T, G @ QN @ G.T, RN)
11    L = P @ C.T @ np.linalg.inv(RN)
12    return L, P
pytest information

This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:

wield.control.SISO.test.test_lqe_thiran.lqe

The full name is useful when building documentation, to link a reference to this page using :func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.

test_Thiran_lqe(test_trigger, tpath_preclear, plot)[source][github]

This is a pytest needing documentation

code
 1def test_Thiran_lqe(test_trigger, tpath_preclear, plot):
 2    ss = SISO.design.delay_thiran_raw(delay_s = 1e-3, order=6).asSS
 3    L, P = lqe(
 4        ss.A,
 5        ss.B,
 6        ss.C,
 7        1 * np.eye(ss.B.shape[1]),  # state noise, in this case driven by U via B
 8        1 * (ss.D.T @ ss.D + np.eye(ss.C.shape[0])), # observation noise (D contribution is from state noise driven by U)
 9    )
10    A2 = ss.A - L @ ss.C
11    dprint(ss.A)
12    dprint(A2)
13    ss2 = SISO.SISOStateSpace(A=A2, B=ss.B, C=ss.C, D=ss.D)
14
15    axB = mplfigB(Nrows=2)
16
17    def trigger(fail, plot):
18        F_Hz = logspaced(1, 1e4, 1000)
19        xfer = ss.fresponse(f=F_Hz)
20        xfer2 = ss2.fresponse(f=F_Hz)
21        #(ss2 + ss)
22        xfer3 = (ss2 * ss).fresponse(f=F_Hz)
23
24        axB = mplfigB(Nrows=2)
25
26        axB.ax0.loglog(*xfer.fplot_mag, label="Direct ZPK")
27        axB.ax1.semilogx(*xfer.fplot_deg135, label="Direct ZPK")
28
29        axB.ax0.loglog(*xfer2.fplot_mag, label="Direct ZPK")
30        axB.ax1.semilogx(*xfer2.fplot_deg135, label="Direct ZPK")
31
32        axB.ax0.loglog(*xfer3.fplot_mag, label="Direct ZPK")
33        axB.ax1.semilogx(*xfer3.fplot_deg135, label="Direct ZPK")
34
35        axB.save(tjoin("test_final"))
36
37    with test_trigger(trigger, plot=plot):
38        pass
39        # np.testing.assert_allclose(xfer, ABCD_xfer, rtol = 1e-5)
40    return
pytest information

This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:

wield.control.SISO.test.test_lqe_thiran.test_Thiran_lqe

The full name is useful when building documentation, to link a reference to this page using :func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.

test_Thiran_lqe
output
status: passed
duration: 0.133s
Captured stderr call
array([[-1.00637290e+04,  7.07106781e-01, -2.01274580e+04,
         0.00000000e+00, -2.01274580e+04,  0.00000000e+00],
       [-1.49985977e+08,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       [ 0.00000000e+00,  0.00000000e+00, -1.49428334e+04,
         7.07106781e-01, -2.98856669e+04,  0.00000000e+00],
       [ 0.00000000e+00,  0.00000000e+00, -1.17961381e+08,
         0.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00, -1.69934376e+04,  7.07106781e-01],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00, -1.06355255e+08,  0.00000000e+00]])
array([[-1.74308899e+04,  7.07106781e-01, -2.74946189e+04,
         0.00000000e+00, -2.74946189e+04,  0.00000000e+00],
       [-1.49985977e+08,  0.00000000e+00,  2.16048936e-06,
         0.00000000e+00,  2.16048936e-06,  0.00000000e+00],
       [-1.09389133e+04,  0.00000000e+00, -2.58817467e+04,
         7.07106781e-01, -4.08245801e+04,  0.00000000e+00],
       [-1.07134523e-06,  0.00000000e+00, -1.17961381e+08,
         0.00000000e+00, -1.07134523e-06,  0.00000000e+00],
       [-1.24400597e+04,  0.00000000e+00, -1.24400597e+04,
         0.00000000e+00, -2.94334973e+04,  7.07106781e-01],
       [ 5.14665811e-07,  0.00000000e+00,  5.14665811e-07,
         0.00000000e+00, -1.06355255e+08,  0.00000000e+00]])