test_solver_ADY

test.ASC_SOLVER.test_solver_ADY

This is a pytest module needing documentation

pytest-html report

Functions

T_calc_H2(folder)

This is a pytest needing documentation

T_calc_HiB(folder)

This is a pytest needing documentation

T_plot_H2(folder[, dfile])

Test that runs the plotting code for H2.

T_plot_HiB(folder[, dfile])

This is a pytest needing documentation

get_systemB([folder])

This is a pytest needing documentation

Details

T_calc_H2(folder)[source]

This is a pytest needing documentation

code
 1@pytest.mark.parametrize(
 2    'folder',
 3    [
 4        #'ExampleModels_rescale',
 5        'ExampleModels',
 6        'ExampleModels_working',
 7        'ExampleModels_working_F3',
 8        'ExampleModels_newFOM',
 9        'ExampleModels_newFOM_F3'
10    ]
11)
12def T_calc_H2(folder):
13    sysB = get_systemB(folder = folder)
14    io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
15
16    if '_F3' in folder:
17        FOM_out = ["F3.out", "F2.out"]
18    else:
19        FOM_out = ["FBNS.out", "F2.out"]
20    wn_in = ["S.in", "O.in"]
21    control_in = ["U.in"]
22    meas_out = ["T.out"]
23
24    # currently NO-OP and could be removed
25    sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
26    sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)
27
28    # Scale the DARM output
29    if 'DARM.out' in sysB.sys.outputs.keys():
30        print('scaling DARM')
31        DARM_scale_factor = strain2m * SNR_intg_factor
32        sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)
33
34    params = {}
35    if folder == 'ExampleModels':
36        params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
37    elif folder == 'ExampleModels_newFOM_F3':
38        params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
39    else:
40        params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
41        #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale
42
43    results_H2_bare = compute.calcOpt(
44        sysB.sys,
45        control_in,
46        wn_in,
47        meas_out,
48        FOM_out,
49        params,
50        solver="LQG",
51        plant_orig=sysB.orig_plant,
52    )
53
54    print("Length of H2 results: ", len(results_H2_bare))
55
56
57    plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
58    results_H2 = compute.calcFullResults(
59        results_H2_bare,
60        colormap="jet",
61        plot_omega=plotting_omega,
62        io_scales = io_scales,
63    )
64
65    ofile = "results_H2_ADY.pkl"
66    tfile = tjoin(ofile)
67    buzzutil.save_results(results_H2, tfile)
68
69    ffile = fjoin(folder, ofile)
70    buzzutil.save_results(results_H2, ffile)
71
72    # copy to the data directory if it is missing
73    dfile = fjoin(folder, ofile)
74
75    # should not copy into rootdir, especially for parametrized test
76    # should this be for ffile?
77    # if not os.path.exists(ofile):
78    #     import shutil
79    #     shutil.copy(tfile, ofile) 
80
81    print("Now running plot test")
82    T_plot_H2(folder=folder, dfile=tfile)
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:

test.ASC_SOLVER.test_solver_ADY.T_calc_H2

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.

T_calc_H2[ExampleModels]
output
status: failed
duration: 0.404s
Captured stderr call

  0%|          | 0/30 [00:00<?, ?it/s]
  0%|          | 0/30 [00:00<?, ?it/s]
captured errors:
folder = 'ExampleModels'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_H2(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        # currently NO-OP and could be removed
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        elif folder == 'ExampleModels_newFOM_F3':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
            #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale

>       results_H2_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            solver="LQG",
            plant_orig=sysB.orig_plant,
        )

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/src/buzz/compute.py:140: in calcOpt
    Ctrl = solvers.LQGsolverset(SPOFF_sc, z2=FOM_out, y=meas_out, w=wn_in, u=control_in)
/builds/buzz/src/buzz/solvers.py:682: in LQGsolverset
    F, X = lqe_controller(SO_FB_Red, A, B2, C1, D12)
/builds/buzz/src/buzz/solvers.py:446: in lqe_controller
    X = scipy.linalg.solve_continuous_are(A, B2, C1.T @ C1, RN, s=S)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = array([[-6.28318531e+02,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00,  0.00000000e...  [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00, -1.84887475e+04,  0.00000000e+00]])
b = array([[ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.000...58160694e-02],
       [-5.53464852e-01],
       [-6.81489204e-02],
       [-6.52856307e-01],
       [-4.52845394e+01]])
q = array([[ 0.        ,  0.        ,  0.        , ...,  0.        ,
         0.        , -0.01766631],
       [-0.       ...   ,  0.        ],
       [-0.01766631,  0.        ,  0.        , ...,  0.        ,
         0.        ,  0.9996879 ]])
r = array([[-56.60490931],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
   ... ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ]])
e = None
s = array([  0.,   3.,   3.,   1.,   0.,   0.,   0.,   0.,   0.,   1.,   3.,
         6.,  10.,  11.,   9.,   5.,  -2., -1....,  23.,  20.,  20.,   1.,   4.,
         0.,   3.,   0.,  -8.,   0.,   4.,   1.,   5.,   1.,   3.,   1.,
        -7.])
balanced = True

    def solve_continuous_are(a, b, q, r, e=None, s=None, balanced=True):
        r"""
        Solves the continuous-time algebraic Riccati equation (CARE).

        The CARE is defined as

        .. math::

              X A + A^H X - X B R^{-1} B^H X + Q = 0

        The limitations for a solution to exist are :

            * All eigenvalues of :math:`A` on the right half plane, should be
              controllable.

            * The associated hamiltonian pencil (See Notes), should have
              eigenvalues sufficiently away from the imaginary axis.

        Moreover, if ``e`` or ``s`` is not precisely ``None``, then the
        generalized version of CARE

        .. math::

              E^HXA + A^HXE - (E^HXB + S) R^{-1} (B^HXE + S^H) + Q = 0

        is solved. When omitted, ``e`` is assumed to be the identity and ``s``
        is assumed to be the zero matrix with sizes compatible with ``a`` and
        ``b``, respectively.

        Parameters
        ----------
        a : (M, M) array_like
            Square matrix
        b : (M, N) array_like
            Input
        q : (M, M) array_like
            Input
        r : (N, N) array_like
            Nonsingular square matrix
        e : (M, M) array_like, optional
            Nonsingular square matrix
        s : (M, N) array_like, optional
            Input
        balanced : bool, optional
            The boolean that indicates whether a balancing step is performed
            on the data. The default is set to True.

        Returns
        -------
        x : (M, M) ndarray
            Solution to the continuous-time algebraic Riccati equation.

        Raises
        ------
        LinAlgError
            For cases where the stable subspace of the pencil could not be
            isolated. See Notes section and the references for details.

        See Also
        --------
        solve_discrete_are : Solves the discrete-time algebraic Riccati equation

        Notes
        -----
        The equation is solved by forming the extended hamiltonian matrix pencil,
        as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

            [ A    0    B ]             [ E   0    0 ]
            [-Q  -A^H  -S ] - \lambda * [ 0  E^H   0 ]
            [ S^H B^H   R ]             [ 0   0    0 ]

        and using a QZ decomposition method.

        In this algorithm, the fail conditions are linked to the symmetry
        of the product :math:`U_2 U_1^{-1}` and condition number of
        :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
        eigenvectors spanning the stable subspace with 2-m rows and partitioned
        into two m-row matrices. See [1]_ and [2]_ for more details.

        In order to improve the QZ decomposition accuracy, the pencil goes
        through a balancing step where the sum of absolute values of
        :math:`H` and :math:`J` entries (after removing the diagonal entries of
        the sum) is balanced following the recipe given in [3]_.

        .. versionadded:: 0.11.0

        References
        ----------
        .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
           Riccati Equations.", SIAM Journal on Scientific and Statistical
           Computing, Vol.2(2), :doi:`10.1137/0902010`

        .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
           Equations.", Massachusetts Institute of Technology. Laboratory for
           Information and Decision Systems. LIDS-R ; 859. Available online :
           http://hdl.handle.net/1721.1/1301

        .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
           SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

        Examples
        --------
        Given `a`, `b`, `q`, and `r` solve for `x`:

        >>> import numpy as np
        >>> from scipy import linalg
        >>> a = np.array([[4, 3], [-4.5, -3.5]])
        >>> b = np.array([[1], [-1]])
        >>> q = np.array([[9, 6], [6, 4.]])
        >>> r = 1
        >>> x = linalg.solve_continuous_are(a, b, q, r)
        >>> x
        array([[ 21.72792206,  14.48528137],
               [ 14.48528137,   9.65685425]])
        >>> np.allclose(a.T.dot(x) + x.dot(a)-x.dot(b).dot(b.T).dot(x), -q)
        True

        """

        # Validate input arguments
        a, b, q, r, e, s, m, n, r_or_c, gen_are = _are_validate_args(
                                                         a, b, q, r, e, s, 'care')

        H = np.empty((2*m+n, 2*m+n), dtype=r_or_c)
        H[:m, :m] = a
        H[:m, m:2*m] = 0.
        H[:m, 2*m:] = b
        H[m:2*m, :m] = -q
        H[m:2*m, m:2*m] = -a.conj().T
        H[m:2*m, 2*m:] = 0. if s is None else -s
        H[2*m:, :m] = 0. if s is None else s.conj().T
        H[2*m:, m:2*m] = b.conj().T
        H[2*m:, 2*m:] = r

        if gen_are and e is not None:
            J = block_diag(e, e.conj().T, np.zeros_like(r, dtype=r_or_c))
        else:
            J = block_diag(np.eye(2*m), np.zeros_like(r, dtype=r_or_c))

        if balanced:
            # xGEBAL does not remove the diagonals before scaling. Also
            # to avoid destroying the Symplectic structure, we follow Ref.3
            M = np.abs(H) + np.abs(J)
            np.fill_diagonal(M, 0.)
            _, (sca, _) = matrix_balance(M, separate=1, permute=0)
            # do we need to bother?
            if not np.allclose(sca, np.ones_like(sca)):
                # Now impose diag(D,inv(D)) from Benner where D is
                # square root of s_i/s_(n+i) for i=0,....
                sca = np.log2(sca)
                # NOTE: Py3 uses "Bankers Rounding: round to the nearest even" !!
                s = np.round((sca[m:2*m] - sca[:m])/2)
                sca = 2 ** np.r_[s, -s, sca[2*m:]]
                # Elementwise multiplication via broadcasting.
                elwisescale = sca[:, None] * np.reciprocal(sca)
                H *= elwisescale
                J *= elwisescale

        # Deflate the pencil to 2m x 2m ala Ref.1, eq.(55)
        q, r = qr(H[:, -n:])
        H = q[:, n:].conj().T.dot(H[:, :2*m])
        J = q[:2*m, n:].conj().T.dot(J[:2*m, :2*m])

        # Decide on which output type is needed for QZ
        out_str = 'real' if r_or_c == float else 'complex'

        _, _, _, _, _, u = ordqz(H, J, sort='lhp', overwrite_a=True,
                                 overwrite_b=True, check_finite=False,
                                 output=out_str)

        # Get the relevant parts of the stable subspace basis
        if e is not None:
            u, _ = qr(np.vstack((e.dot(u[:m, :m]), u[m:, :m])))
        u00 = u[:m, :m]
        u10 = u[m:, :m]

        # Solve via back-substituion after checking the condition of u00
        up, ul, uu = lu(u00)
        if 1/cond(uu) < np.spacing(1.):
            raise LinAlgError('Failed to find a finite solution.')

        # Exploit the triangular structure
        x = solve_triangular(ul.conj().T,
                             solve_triangular(uu.conj().T,
                                              u10.conj().T,
                                              lower=True),
                             unit_diagonal=True,
                             ).conj().T.dot(up.conj().T)
        if balanced:
            x *= sca[:m, None] * sca[:m]

        # Check the deviation from symmetry for lack of success
        # See proof of Thm.5 item 3 in [2]
        u_sym = u00.conj().T.dot(u10)
        n_u_sym = norm(u_sym, 1)
        u_sym = u_sym - u_sym.conj().T
        sym_threshold = np.max([np.spacing(1000.), 0.1*n_u_sym])

        if norm(u_sym, 1) > sym_threshold:
>           raise LinAlgError('The associated Hamiltonian pencil has eigenvalues '
                              'too close to the imaginary axis')
E           numpy.linalg.LinAlgError: The associated Hamiltonian pencil has eigenvalues too close to the imaginary axis

/opt/conda/lib/python3.12/site-packages/scipy/linalg/_solvers.py:525: LinAlgError
T_calc_H2[ExampleModels_newFOM]
output
status: failed
duration: 0.248s
Captured stderr call

  0%|          | 0/15 [00:00<?, ?it/s]
  0%|          | 0/15 [00:00<?, ?it/s]
captured errors:
folder = 'ExampleModels_newFOM'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_H2(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        # currently NO-OP and could be removed
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        elif folder == 'ExampleModels_newFOM_F3':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
            #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale

>       results_H2_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            solver="LQG",
            plant_orig=sysB.orig_plant,
        )

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/src/buzz/compute.py:140: in calcOpt
    Ctrl = solvers.LQGsolverset(SPOFF_sc, z2=FOM_out, y=meas_out, w=wn_in, u=control_in)
/builds/buzz/src/buzz/solvers.py:682: in LQGsolverset
    F, X = lqe_controller(SO_FB_Red, A, B2, C1, D12)
/builds/buzz/src/buzz/solvers.py:446: in lqe_controller
    X = scipy.linalg.solve_continuous_are(A, B2, C1.T @ C1, RN, s=S)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = array([[-628.31853072,    0.        ,    0.        , ...,    0.        ,
           0.        ,    0.        ],
      ...1384],
       [   0.        ,    0.        ,    0.        , ...,    0.        ,
         -21.53544776,    0.        ]])
b = array([[ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.000...40702287e-05],
       [-3.02975905e-04],
       [-6.40702287e-05],
       [-3.02975905e-04],
       [-6.40702287e-05]])
q = array([[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00, -5.36278624e...  [-5.36278624e-04,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00,  9.99999712e-01]])
r = array([[-1864.70233185],
       [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.    ... [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.        ]])
e = None
s = array([  0.,   3.,   3.,   1.,   0.,   0.,   0.,   0.,   0.,   1.,   3.,
         6.,  10.,  11.,   9.,   5.,  -2., -1...0.,  50.,  50.,  50.,  48.,  38.,  38.,  38.,  38.,  38.,
        38.,  34.,  34.,  14.,  14.,  14.,  14.,  14.,  14.])
balanced = True

    def solve_continuous_are(a, b, q, r, e=None, s=None, balanced=True):
        r"""
        Solves the continuous-time algebraic Riccati equation (CARE).

        The CARE is defined as

        .. math::

              X A + A^H X - X B R^{-1} B^H X + Q = 0

        The limitations for a solution to exist are :

            * All eigenvalues of :math:`A` on the right half plane, should be
              controllable.

            * The associated hamiltonian pencil (See Notes), should have
              eigenvalues sufficiently away from the imaginary axis.

        Moreover, if ``e`` or ``s`` is not precisely ``None``, then the
        generalized version of CARE

        .. math::

              E^HXA + A^HXE - (E^HXB + S) R^{-1} (B^HXE + S^H) + Q = 0

        is solved. When omitted, ``e`` is assumed to be the identity and ``s``
        is assumed to be the zero matrix with sizes compatible with ``a`` and
        ``b``, respectively.

        Parameters
        ----------
        a : (M, M) array_like
            Square matrix
        b : (M, N) array_like
            Input
        q : (M, M) array_like
            Input
        r : (N, N) array_like
            Nonsingular square matrix
        e : (M, M) array_like, optional
            Nonsingular square matrix
        s : (M, N) array_like, optional
            Input
        balanced : bool, optional
            The boolean that indicates whether a balancing step is performed
            on the data. The default is set to True.

        Returns
        -------
        x : (M, M) ndarray
            Solution to the continuous-time algebraic Riccati equation.

        Raises
        ------
        LinAlgError
            For cases where the stable subspace of the pencil could not be
            isolated. See Notes section and the references for details.

        See Also
        --------
        solve_discrete_are : Solves the discrete-time algebraic Riccati equation

        Notes
        -----
        The equation is solved by forming the extended hamiltonian matrix pencil,
        as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

            [ A    0    B ]             [ E   0    0 ]
            [-Q  -A^H  -S ] - \lambda * [ 0  E^H   0 ]
            [ S^H B^H   R ]             [ 0   0    0 ]

        and using a QZ decomposition method.

        In this algorithm, the fail conditions are linked to the symmetry
        of the product :math:`U_2 U_1^{-1}` and condition number of
        :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
        eigenvectors spanning the stable subspace with 2-m rows and partitioned
        into two m-row matrices. See [1]_ and [2]_ for more details.

        In order to improve the QZ decomposition accuracy, the pencil goes
        through a balancing step where the sum of absolute values of
        :math:`H` and :math:`J` entries (after removing the diagonal entries of
        the sum) is balanced following the recipe given in [3]_.

        .. versionadded:: 0.11.0

        References
        ----------
        .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
           Riccati Equations.", SIAM Journal on Scientific and Statistical
           Computing, Vol.2(2), :doi:`10.1137/0902010`

        .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
           Equations.", Massachusetts Institute of Technology. Laboratory for
           Information and Decision Systems. LIDS-R ; 859. Available online :
           http://hdl.handle.net/1721.1/1301

        .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
           SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

        Examples
        --------
        Given `a`, `b`, `q`, and `r` solve for `x`:

        >>> import numpy as np
        >>> from scipy import linalg
        >>> a = np.array([[4, 3], [-4.5, -3.5]])
        >>> b = np.array([[1], [-1]])
        >>> q = np.array([[9, 6], [6, 4.]])
        >>> r = 1
        >>> x = linalg.solve_continuous_are(a, b, q, r)
        >>> x
        array([[ 21.72792206,  14.48528137],
               [ 14.48528137,   9.65685425]])
        >>> np.allclose(a.T.dot(x) + x.dot(a)-x.dot(b).dot(b.T).dot(x), -q)
        True

        """

        # Validate input arguments
        a, b, q, r, e, s, m, n, r_or_c, gen_are = _are_validate_args(
                                                         a, b, q, r, e, s, 'care')

        H = np.empty((2*m+n, 2*m+n), dtype=r_or_c)
        H[:m, :m] = a
        H[:m, m:2*m] = 0.
        H[:m, 2*m:] = b
        H[m:2*m, :m] = -q
        H[m:2*m, m:2*m] = -a.conj().T
        H[m:2*m, 2*m:] = 0. if s is None else -s
        H[2*m:, :m] = 0. if s is None else s.conj().T
        H[2*m:, m:2*m] = b.conj().T
        H[2*m:, 2*m:] = r

        if gen_are and e is not None:
            J = block_diag(e, e.conj().T, np.zeros_like(r, dtype=r_or_c))
        else:
            J = block_diag(np.eye(2*m), np.zeros_like(r, dtype=r_or_c))

        if balanced:
            # xGEBAL does not remove the diagonals before scaling. Also
            # to avoid destroying the Symplectic structure, we follow Ref.3
            M = np.abs(H) + np.abs(J)
            np.fill_diagonal(M, 0.)
            _, (sca, _) = matrix_balance(M, separate=1, permute=0)
            # do we need to bother?
            if not np.allclose(sca, np.ones_like(sca)):
                # Now impose diag(D,inv(D)) from Benner where D is
                # square root of s_i/s_(n+i) for i=0,....
                sca = np.log2(sca)
                # NOTE: Py3 uses "Bankers Rounding: round to the nearest even" !!
                s = np.round((sca[m:2*m] - sca[:m])/2)
                sca = 2 ** np.r_[s, -s, sca[2*m:]]
                # Elementwise multiplication via broadcasting.
                elwisescale = sca[:, None] * np.reciprocal(sca)
                H *= elwisescale
                J *= elwisescale

        # Deflate the pencil to 2m x 2m ala Ref.1, eq.(55)
        q, r = qr(H[:, -n:])
        H = q[:, n:].conj().T.dot(H[:, :2*m])
        J = q[:2*m, n:].conj().T.dot(J[:2*m, :2*m])

        # Decide on which output type is needed for QZ
        out_str = 'real' if r_or_c == float else 'complex'

        _, _, _, _, _, u = ordqz(H, J, sort='lhp', overwrite_a=True,
                                 overwrite_b=True, check_finite=False,
                                 output=out_str)

        # Get the relevant parts of the stable subspace basis
        if e is not None:
            u, _ = qr(np.vstack((e.dot(u[:m, :m]), u[m:, :m])))
        u00 = u[:m, :m]
        u10 = u[m:, :m]

        # Solve via back-substituion after checking the condition of u00
        up, ul, uu = lu(u00)
        if 1/cond(uu) < np.spacing(1.):
            raise LinAlgError('Failed to find a finite solution.')

        # Exploit the triangular structure
        x = solve_triangular(ul.conj().T,
                             solve_triangular(uu.conj().T,
                                              u10.conj().T,
                                              lower=True),
                             unit_diagonal=True,
                             ).conj().T.dot(up.conj().T)
        if balanced:
            x *= sca[:m, None] * sca[:m]

        # Check the deviation from symmetry for lack of success
        # See proof of Thm.5 item 3 in [2]
        u_sym = u00.conj().T.dot(u10)
        n_u_sym = norm(u_sym, 1)
        u_sym = u_sym - u_sym.conj().T
        sym_threshold = np.max([np.spacing(1000.), 0.1*n_u_sym])

        if norm(u_sym, 1) > sym_threshold:
>           raise LinAlgError('The associated Hamiltonian pencil has eigenvalues '
                              'too close to the imaginary axis')
E           numpy.linalg.LinAlgError: The associated Hamiltonian pencil has eigenvalues too close to the imaginary axis

/opt/conda/lib/python3.12/site-packages/scipy/linalg/_solvers.py:525: LinAlgError
T_calc_H2[ExampleModels_newFOM_F3]
output
status: failed
duration: 0.746s
Captured stderr call

  0%|          | 0/30 [00:00<?, ?it/s]
  0%|          | 0/30 [00:00<?, ?it/s]
captured errors:
folder = 'ExampleModels_newFOM_F3'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_H2(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        # currently NO-OP and could be removed
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        elif folder == 'ExampleModels_newFOM_F3':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
            #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale

>       results_H2_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            solver="LQG",
            plant_orig=sysB.orig_plant,
        )

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/src/buzz/compute.py:140: in calcOpt
    Ctrl = solvers.LQGsolverset(SPOFF_sc, z2=FOM_out, y=meas_out, w=wn_in, u=control_in)
/builds/buzz/src/buzz/solvers.py:682: in LQGsolverset
    F, X = lqe_controller(SO_FB_Red, A, B2, C1, D12)
/builds/buzz/src/buzz/solvers.py:446: in lqe_controller
    X = scipy.linalg.solve_continuous_are(A, B2, C1.T @ C1, RN, s=S)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = array([[-628.31853072,    0.        ,    0.        , ...,    0.        ,
           0.        ,    0.        ],
      ...1384],
       [   0.        ,    0.        ,    0.        , ...,    0.        ,
         -21.53544776,    0.        ]])
b = array([[ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.000...40702287e-05],
       [-3.02975905e-04],
       [-6.40702287e-05],
       [-3.02975905e-04],
       [-6.40702287e-05]])
q = array([[ 0.        ,  0.        ,  0.        , ...,  0.        ,
         0.        , -0.06245445],
       [-0.       ...   ,  0.        ],
       [-0.06245445,  0.        ,  0.        , ...,  0.        ,
         0.        ,  0.99609944]])
r = array([[-16.01166852],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
   ... ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ],
       [  0.        ]])
e = None
s = array([  0.,   3.,   3.,   1.,   0.,   0.,   0.,   0.,   0.,   1.,   3.,
         6.,  10.,  11.,   9.,   5.,  -2., -1....,  44.,  44.,  40.,  30.,
        30.,  30.,  30.,  30.,  30.,  28.,  28.,   8.,   8.,   8.,   8.,
         8.,   8.])
balanced = True

    def solve_continuous_are(a, b, q, r, e=None, s=None, balanced=True):
        r"""
        Solves the continuous-time algebraic Riccati equation (CARE).

        The CARE is defined as

        .. math::

              X A + A^H X - X B R^{-1} B^H X + Q = 0

        The limitations for a solution to exist are :

            * All eigenvalues of :math:`A` on the right half plane, should be
              controllable.

            * The associated hamiltonian pencil (See Notes), should have
              eigenvalues sufficiently away from the imaginary axis.

        Moreover, if ``e`` or ``s`` is not precisely ``None``, then the
        generalized version of CARE

        .. math::

              E^HXA + A^HXE - (E^HXB + S) R^{-1} (B^HXE + S^H) + Q = 0

        is solved. When omitted, ``e`` is assumed to be the identity and ``s``
        is assumed to be the zero matrix with sizes compatible with ``a`` and
        ``b``, respectively.

        Parameters
        ----------
        a : (M, M) array_like
            Square matrix
        b : (M, N) array_like
            Input
        q : (M, M) array_like
            Input
        r : (N, N) array_like
            Nonsingular square matrix
        e : (M, M) array_like, optional
            Nonsingular square matrix
        s : (M, N) array_like, optional
            Input
        balanced : bool, optional
            The boolean that indicates whether a balancing step is performed
            on the data. The default is set to True.

        Returns
        -------
        x : (M, M) ndarray
            Solution to the continuous-time algebraic Riccati equation.

        Raises
        ------
        LinAlgError
            For cases where the stable subspace of the pencil could not be
            isolated. See Notes section and the references for details.

        See Also
        --------
        solve_discrete_are : Solves the discrete-time algebraic Riccati equation

        Notes
        -----
        The equation is solved by forming the extended hamiltonian matrix pencil,
        as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

            [ A    0    B ]             [ E   0    0 ]
            [-Q  -A^H  -S ] - \lambda * [ 0  E^H   0 ]
            [ S^H B^H   R ]             [ 0   0    0 ]

        and using a QZ decomposition method.

        In this algorithm, the fail conditions are linked to the symmetry
        of the product :math:`U_2 U_1^{-1}` and condition number of
        :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
        eigenvectors spanning the stable subspace with 2-m rows and partitioned
        into two m-row matrices. See [1]_ and [2]_ for more details.

        In order to improve the QZ decomposition accuracy, the pencil goes
        through a balancing step where the sum of absolute values of
        :math:`H` and :math:`J` entries (after removing the diagonal entries of
        the sum) is balanced following the recipe given in [3]_.

        .. versionadded:: 0.11.0

        References
        ----------
        .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
           Riccati Equations.", SIAM Journal on Scientific and Statistical
           Computing, Vol.2(2), :doi:`10.1137/0902010`

        .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
           Equations.", Massachusetts Institute of Technology. Laboratory for
           Information and Decision Systems. LIDS-R ; 859. Available online :
           http://hdl.handle.net/1721.1/1301

        .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
           SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

        Examples
        --------
        Given `a`, `b`, `q`, and `r` solve for `x`:

        >>> import numpy as np
        >>> from scipy import linalg
        >>> a = np.array([[4, 3], [-4.5, -3.5]])
        >>> b = np.array([[1], [-1]])
        >>> q = np.array([[9, 6], [6, 4.]])
        >>> r = 1
        >>> x = linalg.solve_continuous_are(a, b, q, r)
        >>> x
        array([[ 21.72792206,  14.48528137],
               [ 14.48528137,   9.65685425]])
        >>> np.allclose(a.T.dot(x) + x.dot(a)-x.dot(b).dot(b.T).dot(x), -q)
        True

        """

        # Validate input arguments
        a, b, q, r, e, s, m, n, r_or_c, gen_are = _are_validate_args(
                                                         a, b, q, r, e, s, 'care')

        H = np.empty((2*m+n, 2*m+n), dtype=r_or_c)
        H[:m, :m] = a
        H[:m, m:2*m] = 0.
        H[:m, 2*m:] = b
        H[m:2*m, :m] = -q
        H[m:2*m, m:2*m] = -a.conj().T
        H[m:2*m, 2*m:] = 0. if s is None else -s
        H[2*m:, :m] = 0. if s is None else s.conj().T
        H[2*m:, m:2*m] = b.conj().T
        H[2*m:, 2*m:] = r

        if gen_are and e is not None:
            J = block_diag(e, e.conj().T, np.zeros_like(r, dtype=r_or_c))
        else:
            J = block_diag(np.eye(2*m), np.zeros_like(r, dtype=r_or_c))

        if balanced:
            # xGEBAL does not remove the diagonals before scaling. Also
            # to avoid destroying the Symplectic structure, we follow Ref.3
            M = np.abs(H) + np.abs(J)
            np.fill_diagonal(M, 0.)
            _, (sca, _) = matrix_balance(M, separate=1, permute=0)
            # do we need to bother?
            if not np.allclose(sca, np.ones_like(sca)):
                # Now impose diag(D,inv(D)) from Benner where D is
                # square root of s_i/s_(n+i) for i=0,....
                sca = np.log2(sca)
                # NOTE: Py3 uses "Bankers Rounding: round to the nearest even" !!
                s = np.round((sca[m:2*m] - sca[:m])/2)
                sca = 2 ** np.r_[s, -s, sca[2*m:]]
                # Elementwise multiplication via broadcasting.
                elwisescale = sca[:, None] * np.reciprocal(sca)
                H *= elwisescale
                J *= elwisescale

        # Deflate the pencil to 2m x 2m ala Ref.1, eq.(55)
        q, r = qr(H[:, -n:])
        H = q[:, n:].conj().T.dot(H[:, :2*m])
        J = q[:2*m, n:].conj().T.dot(J[:2*m, :2*m])

        # Decide on which output type is needed for QZ
        out_str = 'real' if r_or_c == float else 'complex'

        _, _, _, _, _, u = ordqz(H, J, sort='lhp', overwrite_a=True,
                                 overwrite_b=True, check_finite=False,
                                 output=out_str)

        # Get the relevant parts of the stable subspace basis
        if e is not None:
            u, _ = qr(np.vstack((e.dot(u[:m, :m]), u[m:, :m])))
        u00 = u[:m, :m]
        u10 = u[m:, :m]

        # Solve via back-substituion after checking the condition of u00
        up, ul, uu = lu(u00)
        if 1/cond(uu) < np.spacing(1.):
            raise LinAlgError('Failed to find a finite solution.')

        # Exploit the triangular structure
        x = solve_triangular(ul.conj().T,
                             solve_triangular(uu.conj().T,
                                              u10.conj().T,
                                              lower=True),
                             unit_diagonal=True,
                             ).conj().T.dot(up.conj().T)
        if balanced:
            x *= sca[:m, None] * sca[:m]

        # Check the deviation from symmetry for lack of success
        # See proof of Thm.5 item 3 in [2]
        u_sym = u00.conj().T.dot(u10)
        n_u_sym = norm(u_sym, 1)
        u_sym = u_sym - u_sym.conj().T
        sym_threshold = np.max([np.spacing(1000.), 0.1*n_u_sym])

        if norm(u_sym, 1) > sym_threshold:
>           raise LinAlgError('The associated Hamiltonian pencil has eigenvalues '
                              'too close to the imaginary axis')
E           numpy.linalg.LinAlgError: The associated Hamiltonian pencil has eigenvalues too close to the imaginary axis

/opt/conda/lib/python3.12/site-packages/scipy/linalg/_solvers.py:525: LinAlgError
T_calc_H2[ExampleModels_working_F3]
output
status: failed
duration: 1.815s
Captured stderr call

  0%|          | 0/15 [00:00<?, ?it/s]
  0%|          | 0/15 [00:01<?, ?it/s]
captured errors:
folder = 'ExampleModels_working_F3'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_H2(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        # currently NO-OP and could be removed
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        elif folder == 'ExampleModels_newFOM_F3':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
            #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale

>       results_H2_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            solver="LQG",
            plant_orig=sysB.orig_plant,
        )

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/src/buzz/compute.py:145: in calcOpt
    K_usable, K_usable_zpk = getK_Usable(out_Bunch['K'], SPOFF_full, plant_orig=plant_orig)
/builds/buzz/src/buzz/compute.py:318: in getK_Usable
    K_usable = ssutil.makeSys(K_usable.asSS, K.iod)
/builds/buzz/src/buzz/ssutil.py:111: in makeSys
    return wieldSS(mod, iod=iod)
/builds/buzz/src/buzz/ssutil.py:43: in wieldSS
    isDescriptor(args[0], error=False, print_error=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

sys = <wield.control.SISO.ss.SISOStateSpace object at 0x7fcc2064de20>
error = False, print_error = True

    def isDescriptor(sys, error=True, print_error=True):
        """Check if the system is a descriptor system. A descriptor system is a system where the E matrix is not None and not all zeros.

        Args:
            sys (wield.MIMO | wield.SISO): MIMO or SISO system to check if it is a descriptor system
            error (bool, optional): If True, an error will be raised if the system is not a descriptor system. Defaults to True.

        Returns:
            bool: True if the system is a descriptor system, False if the system is not a descriptor system
        """
        if hasattr(sys, 'E'):
            if sys.e is not None:
                if True or error:
>                   raise TypeError('The given state space system is a descriptor system with an E matrix. This is not supported')
E                   TypeError: The given state space system is a descriptor system with an E matrix. This is not supported

/builds/buzz/src/buzz/ssutil.py:1842: TypeError
T_calc_H2[ExampleModels_working]
output
status: failed
duration: 0.511s
Captured stderr call

  0%|          | 0/15 [00:00<?, ?it/s]
  0%|          | 0/15 [00:00<?, ?it/s]
captured errors:
folder = 'ExampleModels_working'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_H2(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        # currently NO-OP and could be removed
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        elif folder == 'ExampleModels_newFOM_F3':
            params["F1_gain"] = np.geomspace(1e-0, 1e6, 30) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(1e2, 1e6, 15) * 1/FBNS_scale
            #params["F1_gain"] = np.geomspace(1e2, 5e7, 30) * 1/FBNS_scale

>       results_H2_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            solver="LQG",
            plant_orig=sysB.orig_plant,
        )

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/src/buzz/compute.py:140: in calcOpt
    Ctrl = solvers.LQGsolverset(SPOFF_sc, z2=FOM_out, y=meas_out, w=wn_in, u=control_in)
/builds/buzz/src/buzz/solvers.py:682: in LQGsolverset
    F, X = lqe_controller(SO_FB_Red, A, B2, C1, D12)
/builds/buzz/src/buzz/solvers.py:446: in lqe_controller
    X = scipy.linalg.solve_continuous_are(A, B2, C1.T @ C1, RN, s=S)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = array([[-6.28318531e+02,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00,  0.00000000e...  [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00, -1.84887475e+04,  0.00000000e+00]])
b = array([[ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.00000000e+00],
       [ 0.000...58160694e-02],
       [-5.53464852e-01],
       [-6.81489204e-02],
       [-6.52856307e-01],
       [-4.52845394e+01]])
q = array([[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00, -7.50330523e...  [-7.50330523e-04,  0.00000000e+00,  0.00000000e+00, ...,
         0.00000000e+00,  0.00000000e+00,  9.99999437e-01]])
r = array([[-1332.74599555],
       [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.    ... [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.        ],
       [    0.        ]])
e = None
s = array([  0.,   3.,   3.,   1.,   0.,   0.,   0.,   0.,   0.,   1.,   3.,
         6.,  10.,  11.,   9.,   5.,  -2., -1....,  28.,  26.,  25.,   6.,   8.,
         5.,   8.,   5.,  -3.,   4.,   8.,   6.,  10.,   6.,   8.,   6.,
        -2.])
balanced = True

    def solve_continuous_are(a, b, q, r, e=None, s=None, balanced=True):
        r"""
        Solves the continuous-time algebraic Riccati equation (CARE).

        The CARE is defined as

        .. math::

              X A + A^H X - X B R^{-1} B^H X + Q = 0

        The limitations for a solution to exist are :

            * All eigenvalues of :math:`A` on the right half plane, should be
              controllable.

            * The associated hamiltonian pencil (See Notes), should have
              eigenvalues sufficiently away from the imaginary axis.

        Moreover, if ``e`` or ``s`` is not precisely ``None``, then the
        generalized version of CARE

        .. math::

              E^HXA + A^HXE - (E^HXB + S) R^{-1} (B^HXE + S^H) + Q = 0

        is solved. When omitted, ``e`` is assumed to be the identity and ``s``
        is assumed to be the zero matrix with sizes compatible with ``a`` and
        ``b``, respectively.

        Parameters
        ----------
        a : (M, M) array_like
            Square matrix
        b : (M, N) array_like
            Input
        q : (M, M) array_like
            Input
        r : (N, N) array_like
            Nonsingular square matrix
        e : (M, M) array_like, optional
            Nonsingular square matrix
        s : (M, N) array_like, optional
            Input
        balanced : bool, optional
            The boolean that indicates whether a balancing step is performed
            on the data. The default is set to True.

        Returns
        -------
        x : (M, M) ndarray
            Solution to the continuous-time algebraic Riccati equation.

        Raises
        ------
        LinAlgError
            For cases where the stable subspace of the pencil could not be
            isolated. See Notes section and the references for details.

        See Also
        --------
        solve_discrete_are : Solves the discrete-time algebraic Riccati equation

        Notes
        -----
        The equation is solved by forming the extended hamiltonian matrix pencil,
        as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

            [ A    0    B ]             [ E   0    0 ]
            [-Q  -A^H  -S ] - \lambda * [ 0  E^H   0 ]
            [ S^H B^H   R ]             [ 0   0    0 ]

        and using a QZ decomposition method.

        In this algorithm, the fail conditions are linked to the symmetry
        of the product :math:`U_2 U_1^{-1}` and condition number of
        :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
        eigenvectors spanning the stable subspace with 2-m rows and partitioned
        into two m-row matrices. See [1]_ and [2]_ for more details.

        In order to improve the QZ decomposition accuracy, the pencil goes
        through a balancing step where the sum of absolute values of
        :math:`H` and :math:`J` entries (after removing the diagonal entries of
        the sum) is balanced following the recipe given in [3]_.

        .. versionadded:: 0.11.0

        References
        ----------
        .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
           Riccati Equations.", SIAM Journal on Scientific and Statistical
           Computing, Vol.2(2), :doi:`10.1137/0902010`

        .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
           Equations.", Massachusetts Institute of Technology. Laboratory for
           Information and Decision Systems. LIDS-R ; 859. Available online :
           http://hdl.handle.net/1721.1/1301

        .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
           SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

        Examples
        --------
        Given `a`, `b`, `q`, and `r` solve for `x`:

        >>> import numpy as np
        >>> from scipy import linalg
        >>> a = np.array([[4, 3], [-4.5, -3.5]])
        >>> b = np.array([[1], [-1]])
        >>> q = np.array([[9, 6], [6, 4.]])
        >>> r = 1
        >>> x = linalg.solve_continuous_are(a, b, q, r)
        >>> x
        array([[ 21.72792206,  14.48528137],
               [ 14.48528137,   9.65685425]])
        >>> np.allclose(a.T.dot(x) + x.dot(a)-x.dot(b).dot(b.T).dot(x), -q)
        True

        """

        # Validate input arguments
        a, b, q, r, e, s, m, n, r_or_c, gen_are = _are_validate_args(
                                                         a, b, q, r, e, s, 'care')

        H = np.empty((2*m+n, 2*m+n), dtype=r_or_c)
        H[:m, :m] = a
        H[:m, m:2*m] = 0.
        H[:m, 2*m:] = b
        H[m:2*m, :m] = -q
        H[m:2*m, m:2*m] = -a.conj().T
        H[m:2*m, 2*m:] = 0. if s is None else -s
        H[2*m:, :m] = 0. if s is None else s.conj().T
        H[2*m:, m:2*m] = b.conj().T
        H[2*m:, 2*m:] = r

        if gen_are and e is not None:
            J = block_diag(e, e.conj().T, np.zeros_like(r, dtype=r_or_c))
        else:
            J = block_diag(np.eye(2*m), np.zeros_like(r, dtype=r_or_c))

        if balanced:
            # xGEBAL does not remove the diagonals before scaling. Also
            # to avoid destroying the Symplectic structure, we follow Ref.3
            M = np.abs(H) + np.abs(J)
            np.fill_diagonal(M, 0.)
            _, (sca, _) = matrix_balance(M, separate=1, permute=0)
            # do we need to bother?
            if not np.allclose(sca, np.ones_like(sca)):
                # Now impose diag(D,inv(D)) from Benner where D is
                # square root of s_i/s_(n+i) for i=0,....
                sca = np.log2(sca)
                # NOTE: Py3 uses "Bankers Rounding: round to the nearest even" !!
                s = np.round((sca[m:2*m] - sca[:m])/2)
                sca = 2 ** np.r_[s, -s, sca[2*m:]]
                # Elementwise multiplication via broadcasting.
                elwisescale = sca[:, None] * np.reciprocal(sca)
                H *= elwisescale
                J *= elwisescale

        # Deflate the pencil to 2m x 2m ala Ref.1, eq.(55)
        q, r = qr(H[:, -n:])
        H = q[:, n:].conj().T.dot(H[:, :2*m])
        J = q[:2*m, n:].conj().T.dot(J[:2*m, :2*m])

        # Decide on which output type is needed for QZ
        out_str = 'real' if r_or_c == float else 'complex'

        _, _, _, _, _, u = ordqz(H, J, sort='lhp', overwrite_a=True,
                                 overwrite_b=True, check_finite=False,
                                 output=out_str)

        # Get the relevant parts of the stable subspace basis
        if e is not None:
            u, _ = qr(np.vstack((e.dot(u[:m, :m]), u[m:, :m])))
        u00 = u[:m, :m]
        u10 = u[m:, :m]

        # Solve via back-substituion after checking the condition of u00
        up, ul, uu = lu(u00)
        if 1/cond(uu) < np.spacing(1.):
            raise LinAlgError('Failed to find a finite solution.')

        # Exploit the triangular structure
        x = solve_triangular(ul.conj().T,
                             solve_triangular(uu.conj().T,
                                              u10.conj().T,
                                              lower=True),
                             unit_diagonal=True,
                             ).conj().T.dot(up.conj().T)
        if balanced:
            x *= sca[:m, None] * sca[:m]

        # Check the deviation from symmetry for lack of success
        # See proof of Thm.5 item 3 in [2]
        u_sym = u00.conj().T.dot(u10)
        n_u_sym = norm(u_sym, 1)
        u_sym = u_sym - u_sym.conj().T
        sym_threshold = np.max([np.spacing(1000.), 0.1*n_u_sym])

        if norm(u_sym, 1) > sym_threshold:
>           raise LinAlgError('The associated Hamiltonian pencil has eigenvalues '
                              'too close to the imaginary axis')
E           numpy.linalg.LinAlgError: The associated Hamiltonian pencil has eigenvalues too close to the imaginary axis

/opt/conda/lib/python3.12/site-packages/scipy/linalg/_solvers.py:525: LinAlgError
T_calc_HiB(folder)[source]

This is a pytest needing documentation

code
  1@pytest.mark.parametrize(
  2    'folder',
  3    [
  4        #'ExampleModels_rescale',
  5        'ExampleModels',
  6        'ExampleModels_working',
  7        'ExampleModels_working_F3',
  8        'ExampleModels_newFOM',
  9        'ExampleModels_newFOM_F3'
 10    ]
 11)
 12def T_calc_HiB(folder):
 13    sysB = get_systemB(folder = folder)
 14    io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
 15
 16    if '_F3' in folder:
 17        FOM_out = ["F3.out", "F2.out"]
 18    else:
 19        FOM_out = ["FBNS.out", "F2.out"]
 20    wn_in = ["S.in", "O.in"]
 21    Zinf = ["Zinf.in"]
 22    control_in = ["U.in"]
 23    meas_out = ["T.out"]
 24
 25    sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
 26    sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)
 27
 28    # Scale the DARM output
 29    if 'DARM.out' in sysB.sys.outputs.keys():
 30        print('scaling DARM')
 31        DARM_scale_factor = strain2m * SNR_intg_factor
 32        sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)
 33
 34    params = {}
 35    if folder == 'ExampleModels':
 36        params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
 37    # elif folder == 'ExampleModels_newFOM_F3':
 38    #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
 39    else:
 40        params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
 41        #params["F1_gain"] = np.array([0.09146101038546522])
 42
 43    params["igsq_capture"] = [
 44        1e-4,  # gain-100 limit
 45        1.8e-2,  # 1 deg, around gain-10
 46        1e-1,  # 6 deg
 47        0.20,  # 11.5 deg
 48        0.3,  # 17 deg
 49        0.5,  # 30 deg
 50        0.7653668647301797,  # 45 deg
 51        0.85,  # 50.0 deg
 52        0.90,  # 53.5 deg
 53        0.95,  # 56.5 deg
 54        # above this it gets very hairy
 55        # these are 10 solutions
 56    ]
 57
 58    # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
 59    # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])
 60
 61    plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
 62    results_Hib_bare = compute.calcOpt(
 63        sysB.sys,
 64        control_in,
 65        wn_in,
 66        meas_out,
 67        FOM_out,
 68        params,
 69        Zinf=Zinf,
 70        solver="HB",
 71        plant_orig=sysB.orig_plant,
 72        BH_solver = BH1solverset,
 73        debug_mode=True,
 74    )
 75
 76    print("Calculating Full Results Now:")
 77    results_Hib = compute.calcFullResults(
 78        results_Hib_bare,
 79        colormap="RdYlGn",
 80        plot_omega=plotting_omega,
 81        color_param="igsq",
 82        label=False,
 83        io_scales = io_scales,
 84    )
 85
 86    ofile = "results_Hib_ADY.pkl"
 87    tfile = tjoin(ofile)
 88    buzzutil.save_results(results_Hib, tfile)
 89
 90    ffile = fjoin(folder, ofile)
 91    buzzutil.save_results(results_Hib, ffile)
 92
 93    # TODO, should also check if the data is identical and warn that it should be copied
 94    # copy to the data directory if it is missing
 95    dfile = fjoin(folder, ofile)
 96    # should not save into the root folder for parametrized test - Lee
 97    # if not os.path.exists(ofile):
 98    #     import shutil
 99    #     shutil.copy(tfile, ofile) 
100
101    print("Now running plot test")
102    T_plot_HiB(folder=folder, dfile=tfile)
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:

test.ASC_SOLVER.test_solver_ADY.T_calc_HiB

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.

T_calc_HiB[ExampleModels_newFOM]
output
LPL []
MPL []
eq37 Before S: 657987603460.6472
eq37  S: 237023356.53176352
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Reset #2, asq_eff=7.6e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.63e+14, N_step=8
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 150450527584.05466
eq37  S: 874001.6120196386
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 34400893164.65984
eq37  S: 178897.62118642687
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Reset #2, asq_eff=7.6e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.63e+14, N_step=7
Steps remaining: 99, asq_eff=4.2e+14, igsq=0.1
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=6
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 786585111750.5571
eq37  S: 49289.35568661333
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Reset #2, asq_eff=7.6e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.63e+14, N_step=10
Reset #1, asq_eff=7.0e+14, igsq=0.85
Reset #2, asq_eff=7.6e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.63e+14, N_step=9
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Reset #2, asq_eff=7.6e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.63e+14, N_step=8

LPL []
MPL []
eq37 Before S: 179854672687.17575
eq37  S: 1182.0757954238645
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Reset #2, asq_eff=7.6e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.63e+14, N_step=7
Reset #1, asq_eff=7.0e+14, igsq=0.5
Reset #2, asq_eff=7.6e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.63e+14, N_step=8
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 41124225216.29056
eq37  S: 81.89080809735802
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5
Calculating Full Results Now:
Now running plot test
Captured stderr call

  0%|          | 0/6 [00:00<?, ?it/s]
 17%|█▋        | 1/6 [00:30<02:30, 30.06s/it]
 33%|███▎      | 2/6 [00:57<01:53, 28.45s/it]
 50%|█████     | 3/6 [01:28<01:28, 29.46s/it]
 67%|██████▋   | 4/6 [01:59<01:00, 30.23s/it]
 83%|████████▎ | 5/6 [02:29<00:30, 30.04s/it]
100%|██████████| 6/6 [02:56<00:00, 29.27s/it]
100%|██████████| 6/6 [02:56<00:00, 29.49s/it]

0it [00:00, ?it/s]
0it [00:00, ?it/s]
captured errors:
folder = 'ExampleModels_newFOM'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_HiB(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        Zinf = ["Zinf.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
        # elif folder == 'ExampleModels_newFOM_F3':
        #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
            #params["F1_gain"] = np.array([0.09146101038546522])

        params["igsq_capture"] = [
            1e-4,  # gain-100 limit
            1.8e-2,  # 1 deg, around gain-10
            1e-1,  # 6 deg
            0.20,  # 11.5 deg
            0.3,  # 17 deg
            0.5,  # 30 deg
            0.7653668647301797,  # 45 deg
            0.85,  # 50.0 deg
            0.90,  # 53.5 deg
            0.95,  # 56.5 deg
            # above this it gets very hairy
            # these are 10 solutions
        ]

        # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
        # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])

        plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
        results_Hib_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            Zinf=Zinf,
            solver="HB",
            plant_orig=sysB.orig_plant,
            BH_solver = BH1solverset,
            debug_mode=True,
        )

        print("Calculating Full Results Now:")
        results_Hib = compute.calcFullResults(
            results_Hib_bare,
            colormap="RdYlGn",
            plot_omega=plotting_omega,
            color_param="igsq",
            label=False,
            io_scales = io_scales,
        )

        ofile = "results_Hib_ADY.pkl"
        tfile = tjoin(ofile)
        buzzutil.save_results(results_Hib, tfile)

        ffile = fjoin(folder, ofile)
        buzzutil.save_results(results_Hib, ffile)

        # TODO, should also check if the data is identical and warn that it should be copied
        # copy to the data directory if it is missing
        dfile = fjoin(folder, ofile)
        # should not save into the root folder for parametrized test - Lee
        # if not os.path.exists(ofile):
        #     import shutil
        #     shutil.copy(tfile, ofile)

        print("Now running plot test")
>       T_plot_HiB(folder=folder, dfile=tfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:469: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: in T_plot_HiB
    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_calc_HiB[ExampleModels_newFOM_F3]
output
LPL []
MPL []
eq37 Before S: 657987603460.649
eq37  S: 538385731.7583944
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 150450527584.0541
eq37  S: 42586556489.93234
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 34400893164.65989
eq37  S: 175057591.01201174
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 786585111750.5569
eq37  S: 872692535.1205466
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 179854672687.17578
eq37  S: 10824440278.58744
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 41124225216.29054
eq37  S: 7848068144.444835
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5
Calculating Full Results Now:
Now running plot test
Captured stderr call

  0%|          | 0/6 [00:00<?, ?it/s]
 17%|█▋        | 1/6 [02:04<10:23, 124.61s/it]
 33%|███▎      | 2/6 [04:10<08:20, 125.09s/it]
 50%|█████     | 3/6 [06:17<06:18, 126.00s/it]
 67%|██████▋   | 4/6 [08:28<04:16, 128.04s/it]
 83%|████████▎ | 5/6 [10:33<02:07, 127.19s/it]
100%|██████████| 6/6 [12:46<00:00, 128.87s/it]
100%|██████████| 6/6 [12:46<00:00, 127.68s/it]

0it [00:00, ?it/s]
0it [00:00, ?it/s]
captured errors:
folder = 'ExampleModels_newFOM_F3'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_HiB(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        Zinf = ["Zinf.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
        # elif folder == 'ExampleModels_newFOM_F3':
        #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
            #params["F1_gain"] = np.array([0.09146101038546522])

        params["igsq_capture"] = [
            1e-4,  # gain-100 limit
            1.8e-2,  # 1 deg, around gain-10
            1e-1,  # 6 deg
            0.20,  # 11.5 deg
            0.3,  # 17 deg
            0.5,  # 30 deg
            0.7653668647301797,  # 45 deg
            0.85,  # 50.0 deg
            0.90,  # 53.5 deg
            0.95,  # 56.5 deg
            # above this it gets very hairy
            # these are 10 solutions
        ]

        # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
        # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])

        plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
        results_Hib_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            Zinf=Zinf,
            solver="HB",
            plant_orig=sysB.orig_plant,
            BH_solver = BH1solverset,
            debug_mode=True,
        )

        print("Calculating Full Results Now:")
        results_Hib = compute.calcFullResults(
            results_Hib_bare,
            colormap="RdYlGn",
            plot_omega=plotting_omega,
            color_param="igsq",
            label=False,
            io_scales = io_scales,
        )

        ofile = "results_Hib_ADY.pkl"
        tfile = tjoin(ofile)
        buzzutil.save_results(results_Hib, tfile)

        ffile = fjoin(folder, ofile)
        buzzutil.save_results(results_Hib, ffile)

        # TODO, should also check if the data is identical and warn that it should be copied
        # copy to the data directory if it is missing
        dfile = fjoin(folder, ofile)
        # should not save into the root folder for parametrized test - Lee
        # if not os.path.exists(ofile):
        #     import shutil
        #     shutil.copy(tfile, ofile)

        print("Now running plot test")
>       T_plot_HiB(folder=folder, dfile=tfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:469: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: in T_plot_HiB
    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_calc_HiB[ExampleModels_working]
output
LPL []
MPL []
eq37 Before S: 85247386186.12807
eq37  S: 499707591.38901365
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.00e+14, N_step=5

LPL []
MPL []
eq37 Before S: 1949203018325.8093
eq37  S: 3709865521.1958466
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.00e+14, N_step=5

LPL []
MPL []
eq37 Before S: 445690193756.19305
eq37  S: 557039299754.3375
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 101908188599.58783
eq37  S: 5487991961037877.0
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 2330156473967.72
eq37  S: 1.6018978521769254e+16
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.30084
eq37  S: 1.1564648619993346e+17
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5
Calculating Full Results Now:
Now running plot test
Captured stderr call

  0%|          | 0/6 [00:00<?, ?it/s]
 17%|█▋        | 1/6 [01:10<05:52, 70.44s/it]
 33%|███▎      | 2/6 [01:56<03:44, 56.24s/it]
 50%|█████     | 3/6 [02:44<02:36, 52.25s/it]
 67%|██████▋   | 4/6 [03:30<01:39, 49.91s/it]
 83%|████████▎ | 5/6 [04:17<00:48, 48.68s/it]
100%|██████████| 6/6 [05:18<00:00, 52.90s/it]
100%|██████████| 6/6 [05:18<00:00, 53.02s/it]

0it [00:00, ?it/s]
0it [00:00, ?it/s]
captured errors:
folder = 'ExampleModels_working'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_HiB(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        Zinf = ["Zinf.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
        # elif folder == 'ExampleModels_newFOM_F3':
        #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
            #params["F1_gain"] = np.array([0.09146101038546522])

        params["igsq_capture"] = [
            1e-4,  # gain-100 limit
            1.8e-2,  # 1 deg, around gain-10
            1e-1,  # 6 deg
            0.20,  # 11.5 deg
            0.3,  # 17 deg
            0.5,  # 30 deg
            0.7653668647301797,  # 45 deg
            0.85,  # 50.0 deg
            0.90,  # 53.5 deg
            0.95,  # 56.5 deg
            # above this it gets very hairy
            # these are 10 solutions
        ]

        # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
        # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])

        plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
        results_Hib_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            Zinf=Zinf,
            solver="HB",
            plant_orig=sysB.orig_plant,
            BH_solver = BH1solverset,
            debug_mode=True,
        )

        print("Calculating Full Results Now:")
        results_Hib = compute.calcFullResults(
            results_Hib_bare,
            colormap="RdYlGn",
            plot_omega=plotting_omega,
            color_param="igsq",
            label=False,
            io_scales = io_scales,
        )

        ofile = "results_Hib_ADY.pkl"
        tfile = tjoin(ofile)
        buzzutil.save_results(results_Hib, tfile)

        ffile = fjoin(folder, ofile)
        buzzutil.save_results(results_Hib, ffile)

        # TODO, should also check if the data is identical and warn that it should be copied
        # copy to the data directory if it is missing
        dfile = fjoin(folder, ofile)
        # should not save into the root folder for parametrized test - Lee
        # if not os.path.exists(ofile):
        #     import shutil
        #     shutil.copy(tfile, ofile)

        print("Now running plot test")
>       T_plot_HiB(folder=folder, dfile=tfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:469: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: in T_plot_HiB
    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_calc_HiB[ExampleModels_working_F3]
output
LPL []
MPL []
eq37 Before S: 85247386186.12808
eq37  S: 2779734626.465889
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 1949203018325.81
eq37  S: 46449504383.79963
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 445690193756.1933
eq37  S: 956095349381.873
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 101908188599.58774
eq37  S: 1838578405917789.2
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 2330156473967.718
eq37  S: 3.989105628137364e+16
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.3014
eq37  S: 4.3996743327650664e+16
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5
Calculating Full Results Now:
Now running plot test
Captured stderr call

  0%|          | 0/6 [00:00<?, ?it/s]
 17%|█▋        | 1/6 [02:12<11:03, 132.79s/it]
 33%|███▎      | 2/6 [04:24<08:48, 132.16s/it]
 50%|█████     | 3/6 [06:36<06:36, 132.27s/it]
 67%|██████▋   | 4/6 [08:45<04:22, 131.01s/it]
 83%|████████▎ | 5/6 [11:00<02:12, 132.38s/it]
100%|██████████| 6/6 [13:11<00:00, 131.65s/it]
100%|██████████| 6/6 [13:11<00:00, 131.84s/it]

0it [00:00, ?it/s]
0it [00:00, ?it/s]
captured errors:
folder = 'ExampleModels_working_F3'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_HiB(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        Zinf = ["Zinf.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
        # elif folder == 'ExampleModels_newFOM_F3':
        #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
            #params["F1_gain"] = np.array([0.09146101038546522])

        params["igsq_capture"] = [
            1e-4,  # gain-100 limit
            1.8e-2,  # 1 deg, around gain-10
            1e-1,  # 6 deg
            0.20,  # 11.5 deg
            0.3,  # 17 deg
            0.5,  # 30 deg
            0.7653668647301797,  # 45 deg
            0.85,  # 50.0 deg
            0.90,  # 53.5 deg
            0.95,  # 56.5 deg
            # above this it gets very hairy
            # these are 10 solutions
        ]

        # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
        # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])

        plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
        results_Hib_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            Zinf=Zinf,
            solver="HB",
            plant_orig=sysB.orig_plant,
            BH_solver = BH1solverset,
            debug_mode=True,
        )

        print("Calculating Full Results Now:")
        results_Hib = compute.calcFullResults(
            results_Hib_bare,
            colormap="RdYlGn",
            plot_omega=plotting_omega,
            color_param="igsq",
            label=False,
            io_scales = io_scales,
        )

        ofile = "results_Hib_ADY.pkl"
        tfile = tjoin(ofile)
        buzzutil.save_results(results_Hib, tfile)

        ffile = fjoin(folder, ofile)
        buzzutil.save_results(results_Hib, ffile)

        # TODO, should also check if the data is identical and warn that it should be copied
        # copy to the data directory if it is missing
        dfile = fjoin(folder, ofile)
        # should not save into the root folder for parametrized test - Lee
        # if not os.path.exists(ofile):
        #     import shutil
        #     shutil.copy(tfile, ofile)

        print("Now running plot test")
>       T_plot_HiB(folder=folder, dfile=tfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:469: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: in T_plot_HiB
    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_calc_HiB[ExampleModels]
output
LPL []
MPL []
eq37 Before S: 5327961636.63301
eq37  S: 40456742.86615539
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.00e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.30066
eq37  S: 1159640755.6566525
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.00e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.00e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.3007
eq37  S: 239772041632.3049
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.3009
eq37  S: 1.842390915553795e+16
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5

LPL []
MPL []
eq37 Before S: 532796163663.30084
eq37  S: 1.1564648619993346e+17
LINF: 2.4e+07
LINF full: 2.4e+07, vs: 1.0e+00
Reset #1, asq_eff=7.0e+14, igsq=0.0001
Non-optimal solve at igsq=1.00e-04 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.018
Non-optimal solve at igsq=1.80e-02 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.1
Non-optimal solve at igsq=1.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.2
Non-optimal solve at igsq=2.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.3
Non-optimal solve at igsq=3.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.5
Non-optimal solve at igsq=5.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.7653668647301797
Non-optimal solve at igsq=7.65e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.85
Non-optimal solve at igsq=8.50e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.9
Non-optimal solve at igsq=9.00e-01 and asq=7.01e+14, N_step=5
Reset #1, asq_eff=7.0e+14, igsq=0.95
Non-optimal solve at igsq=9.50e-01 and asq=7.01e+14, N_step=5
Calculating Full Results Now:
Now running plot test
Captured stderr call

  0%|          | 0/5 [00:00<?, ?it/s]
 20%|██        | 1/5 [00:47<03:08, 47.06s/it]
 40%|████      | 2/5 [01:35<02:22, 47.62s/it]
 60%|██████    | 3/5 [02:20<01:33, 46.54s/it]
 80%|████████  | 4/5 [03:05<00:46, 46.09s/it]
100%|██████████| 5/5 [04:04<00:00, 50.67s/it]
100%|██████████| 5/5 [04:04<00:00, 48.90s/it]

0it [00:00, ?it/s]
0it [00:00, ?it/s]
captured errors:
folder = 'ExampleModels'

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_calc_HiB(folder):
        sysB = get_systemB(folder = folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function

        if '_F3' in folder:
            FOM_out = ["F3.out", "F2.out"]
        else:
            FOM_out = ["FBNS.out", "F2.out"]
        wn_in = ["S.in", "O.in"]
        Zinf = ["Zinf.in"]
        control_in = ["U.in"]
        meas_out = ["T.out"]

        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[0], FBNS_scale)
        sysB.sys = ssutil.scale_io(sysB.sys, FOM_out[1], FFlat_scale)

        # Scale the DARM output
        if 'DARM.out' in sysB.sys.outputs.keys():
            print('scaling DARM')
            DARM_scale_factor = strain2m * SNR_intg_factor
            sysB.sys = ssutil.scale_io(sysB.sys, 'DARM.out', DARM_scale_factor)

        params = {}
        if folder == 'ExampleModels':
            params['F1_gain'] = np.geomspace(1e1, 1e5, 5) * 1/FBNS_scale # was 1e1 3e3
        # elif folder == 'ExampleModels_newFOM_F3':
        #     params['F1_gain'] = np.geomspace(1e-6, 1e-3, 5) * 1/FBNS_scale
        else:
            params["F1_gain"] = np.geomspace(4e1, 1e5, 6) * 1/FBNS_scale
            #params["F1_gain"] = np.array([0.09146101038546522])

        params["igsq_capture"] = [
            1e-4,  # gain-100 limit
            1.8e-2,  # 1 deg, around gain-10
            1e-1,  # 6 deg
            0.20,  # 11.5 deg
            0.3,  # 17 deg
            0.5,  # 30 deg
            0.7653668647301797,  # 45 deg
            0.85,  # 50.0 deg
            0.90,  # 53.5 deg
            0.95,  # 56.5 deg
            # above this it gets very hairy
            # these are 10 solutions
        ]

        # params["igsq_capture"] = np.geomspace(1e-6, 0.99, 40)
        # params["igsq_capture"] = np.concatenate([np.geomspace(1e-6, 0.1, 6), np.geomspace(.1, 0.95, 6)])

        plotting_omega = np.logspace(-3, 4, 1000) * 2 * np.pi
        results_Hib_bare = compute.calcOpt(
            sysB.sys,
            control_in,
            wn_in,
            meas_out,
            FOM_out,
            params,
            Zinf=Zinf,
            solver="HB",
            plant_orig=sysB.orig_plant,
            BH_solver = BH1solverset,
            debug_mode=True,
        )

        print("Calculating Full Results Now:")
        results_Hib = compute.calcFullResults(
            results_Hib_bare,
            colormap="RdYlGn",
            plot_omega=plotting_omega,
            color_param="igsq",
            label=False,
            io_scales = io_scales,
        )

        ofile = "results_Hib_ADY.pkl"
        tfile = tjoin(ofile)
        buzzutil.save_results(results_Hib, tfile)

        ffile = fjoin(folder, ofile)
        buzzutil.save_results(results_Hib, ffile)

        # TODO, should also check if the data is identical and warn that it should be copied
        # copy to the data directory if it is missing
        dfile = fjoin(folder, ofile)
        # should not save into the root folder for parametrized test - Lee
        # if not os.path.exists(ofile):
        #     import shutil
        #     shutil.copy(tfile, ofile)

        print("Now running plot test")
>       T_plot_HiB(folder=folder, dfile=tfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:469: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: in T_plot_HiB
    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_H2(folder, dfile=None)[source]

Test that runs the plotting code for H2. This test can be run from another test

code
docstring
"""
Test that runs the plotting code for H2. This test can be run from another test
"""
  1@pytest.mark.parametrize(
  2    'folder', [
  3        #'ExampleModels_rescale',
  4        'ExampleModels',
  5        'ExampleModels_working',
  6        'ExampleModels_working_F3',
  7        'ExampleModels_newFOM',
  8        'ExampleModels_newFOM_F3'
  9    ]
 10)
 11def T_plot_H2(folder, dfile = None):
 12
 13
 14    if folder is None:
 15        folder = "ExampleModels"
 16
 17    io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
 18    sysB = get_systemB(folder=folder)
 19
 20    if dfile is None:
 21        ofile = "results_H2_ADY.pkl"
 22        dfile = fjoin(folder, ofile)
 23    print('dfile: ', dfile)
 24    H2_results = buzzutil.load_results(dfile)
 25
 26    print('len H2_results: ', len(H2_results))
 27
 28    # add a gamma value to the results for plotting
 29    for point in H2_results:
 30        if point["gamma"] == None:
 31            point["gamma"] = np.inf
 32
 33    # Remove the labels from the results
 34    for datadict in H2_results:
 35        datadict["label1"] = None
 36        datadict["label2"] = None
 37
 38    # Adding the current controller to the plot
 39    module_gain = -40 # this is the gain of the filter module
 40    filter_list = np.array([1, 3, 4, 5, 6]) # this is a list of the filters in the module that are on
 41
 42    zpksys, filtinfo = readFilter.readFilterSys_Scipy(
 43        fjoin("H1ASC.txt"), "ASC_DHARD_Y", np.array(filter_list)
 44    )
 45
 46    z, p, k = FilteringUtils.d2c(
 47        (zpksys.zeros, zpksys.poles, zpksys.gain), fs=1 / zpksys.dt
 48    )
 49
 50    k = k.real * module_gain
 51    K_mod = SISO.zpk(z, p, k, angular=True, fiducial_rtol=1e-5, fiducial_atol=1e-10).asSS
 52    K_iod = {"C.in": 0, "C.out": 0}
 53    K = wieldSS(K_mod, K_iod)
 54
 55    axB = ssutil.bode(ssutil.asSISO(K)*sysB.orig_plant.siso("P.out", "P.in"), label="K_hand * orig_plant Controller")
 56    axC = ssutil.bode(K, label="K_hand")
 57
 58    K = (ssutil.asSISO(K) * sysB.sys["S.out", "SA.in"]).mimo(
 59        "C.out", "C.in"
 60    ) # Add in the part of P that was moved to env. noise block
 61    K = ssutil.balance_sys_gain(K)
 62
 63    axB = ssutil.bode(-1*ssutil.asSISO(K)*H2_results[0]['plant'].siso("P.out", "P.in"), axB =axB, label="K_hand * S_anex * P")
 64    axB = ssutil.bode(H2_results[1]['K'].siso("C.out", "C.in")*H2_results[1]['plant'].siso("P.out", "P.in"), axB =axB, label="K_H2[-15] * P")
 65    axB.save(tjoin("bode_KP.pdf"))
 66    axB.save(tjoin("bode_KP.png"))
 67
 68    axC = ssutil.bode(H2_results[1]['K_usable'], axB =axC, label="K_useable")
 69    axB = ssutil.bode(ssutil.asSISO(H2_results[1]['K'])*sysB.sys.siso("S.out", "SA.in")**(-1), axB =axC, label="K / S_anex")
 70    axC.save(tjoin("bode_K.pdf"))
 71    axC.save(tjoin("bode_K.png"))
 72
 73    curdict = H2_results[0].copy()
 74    curdict["Ac"] = K.A
 75    curdict["Bc"] = K.B
 76    curdict["Cc"] = K.C
 77    curdict["Dc"] = K.D
 78    curdict["K"] = K
 79    curdict["label"] = "Hand Tuned Controller"
 80
 81    extraplots = compute.calcFullResults(
 82        [curdict], 
 83        color="dimgrey", 
 84        label="Hand Tuned Controller", 
 85        plot_omega=curdict["plot_omega"],
 86        io_scales = io_scales,
 87    )
 88    extraplots[0]["F1_gain"] = sum(buzzutil.listparams(H2_results, "F1_gain"))
 89    extraplots[0]["linecolor"] = "Black"  #'DodgerBlue'
 90    extraplots[0]["linestyle"] = "--"
 91    extraplots[0]["solver"] = "Hand Tuned"
 92    extraplots[0]["rms_marker"] = "^"
 93
 94    f_Hz_range = extraplots[0]['FOM1_wn_ASD_Hz']
 95    budget_range = gwinc.load_budget('aLIGO', freq=f_Hz_range)
 96    trace_range = budget_range.run(freq=f_Hz_range)
 97
 98    plt.loglog(f_Hz_range, extraplots[0]['FOM1_wn_ASD']*4000, label='white noise to darm out with hand tuned controller')
 99    plt.loglog(f_Hz_range, trace_range.psd**0.5*4000, label='aLIGO')
100    plt.legend()
101    plt.xlabel('Frequency [Hz]')
102    plt.ylabel('ASD [m/rtHz]')
103    plt.xlim([6, 6e2])
104    plt.ylim([4e-21, 3e-17])
105    plt.savefig(tjoin('DARM_spec.png'), bbox_inches='tight')
106    plt.savefig(tjoin('DARM_spec.pdf'), bbox_inches='tight')
107    plt.close()
108
109    H2_results_E = H2_results + extraplots
110
111    every_nth = 1  # removes every nth element
112    H2_results_E_short = H2_results[every_nth - 1:: every_nth] + extraplots
113
114    setname_H2 = "ADY_H2"
115    fig_rms_H2 = plotting.plotRMS(
116        H2_results_E_short,
117        setname=setname_H2,
118        outlineparam="pm",
119        text="pm",
120        f1line=False,
121        h2line=False,
122        plotrange=True,
123        test=True,
124    )
125    fig_rms_H2[0].savefig(tjoin("rms_H2.pdf"), bbox_inches="tight")
126    fig_rms_H2[0].savefig(tjoin("rms_H2.png"), bbox_inches="tight")
127
128    fig_rms_H2_range_PSD = plotting.plotRMS(
129        H2_results_E_short,
130        setname=setname_H2,
131        outlineparam="pm",
132        text="pm",
133        f1line=False,
134        h2line=False,
135        plotrange='PSD',
136        test=True,
137    )
138    fig_rms_H2_range_PSD[0].savefig(tjoin("rms_H2_range_PSD.pdf"), bbox_inches="tight")
139    fig_rms_H2_range_PSD[0].savefig(tjoin("rms_H2_range_PSD.png"), bbox_inches="tight")
140
141
142    print('Plotting RMS Plot with lost range')
143    fig_rms_lost_range_H2 = plotting.plotRMS(
144        H2_results_E,
145        setname=setname_H2,
146        outlineparam='pm',
147        text='pm',
148        f1line=True,
149        h2line=True,
150        plotrange='diff',
151        test=True,
152        #xlim=xlim,
153        #ylim=ylim
154    )
155    fig_rms_lost_range_H2[0].savefig(tjoin("rms_H2_lost_range.pdf"), bbox_inches="tight")
156    fig_rms_lost_range_H2[0].savefig(tjoin("rms_H2_lost_range.png"), bbox_inches="tight")
157
158    print('Plotting RMS Plot with lost range (PSD computation)')
159    fig_rms_lost_range_H2_psd = plotting.plotRMS(
160        H2_results_E,
161        setname=setname_H2,
162        outlineparam='pm',
163        text='pm',
164        f1line=True,
165        h2line=True,
166        plotrange='diff_psd',
167        test=True,
168        #xlim=xlim,
169        #ylim=ylim
170    )
171    fig_rms_lost_range_H2_psd[0].savefig(tjoin("rms_H2_lost_range_PSD.pdf"), bbox_inches="tight")
172    fig_rms_lost_range_H2_psd[0].savefig(tjoin("rms_H2_lost_range_PSD.png"), bbox_inches="tight")
173
174
175    ylim = [1e-4, 1e8]
176    fig_ol_H2, ax = plotting.plotLoop(H2_results_E_short, "OL", setname=setname_H2, ylim=ylim, UG_line=True, test=True)
177    fig_ol_H2.savefig(tjoin("ol_H2.pdf"), bbox_inches="tight")
178    fig_ol_H2.savefig(tjoin("ol_H2.png"), bbox_inches="tight")
179
180    fig_cl_H2, ax = plotting.plotLoop(H2_results_E_short, "CL", setname=setname_H2, UG_line=True, test=True)
181    fig_cl_H2.savefig(tjoin("cl_H2.pdf"), bbox_inches="tight")
182    fig_cl_H2.savefig(tjoin("cl_H2.png"), bbox_inches="tight")
183
184    noise_plot_fig, noise_plot_axs = plotting.plot_CLnoises(H2_results_E_short[0], test=True)
185    noise_plot_fig.savefig(tjoin("noise_H2.pdf"), bbox_inches="tight")
186    noise_plot_fig.savefig(tjoin("noise_H2.png"), bbox_inches="tight")
187
188    fig_darm_H2, ax = plotting.plotDARM(H2_results_E_short, setname=setname_H2, test=True)
189    fig_darm_H2.savefig(tjoin("All_DARM_Spec.pdf"), bbox_inches="tight")
190    fig_darm_H2.savefig(tjoin("All_DARM_Spec.png"), bbox_inches="tight")
191
192    setname_vega = 'ASC_vega'
193    vega_chart = plotting.vega_plot(H2_results_E, setname=setname_vega, h2line=False, size=500, plotrange=False, test=True)
194    vega_chart.save(tjoin("vega_results_plot.html"))
195
196    if 'FBNS.DARM.out' in extraplots[0]['CL_all_io'].iod:
197        DARM_out_name = 'FBNS.DARM.out'
198        darm_in_mod = True
199    elif 'F3.DARM.out' in extraplots[0]['CL_all_io'].iod:
200        DARM_out_name = 'F3.DARM.out'
201        darm_in_mod = True
202    else:
203        DARM_out_name = None
204
205    if DARM_out_name:
206        DARM_plot_omega = np.logspace(-2, 3, 1000) * 2 * np.pi
207        DARM_noise_plot_fig, DARM_noise_plot_axs = plotting.plot_CLnoises(extraplots[0], extra_fom=DARM_out_name, extra_only=True, plot_omega=DARM_plot_omega, test=True, scale=1/io_scales.w2_rescale)
208        DARM_noise_plot_fig.savefig(tjoin("DARM_noise_H2.pdf"), bbox_inches="tight")
209        DARM_noise_plot_fig.savefig(tjoin("DARM_noise_H2.png"), bbox_inches="tight")
210    else:
211        print('DARM not in outputs. Not plotting DARM noise')
212        print(extraplots[0]['CL_all_io'].outputs)
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:

test.ASC_SOLVER.test_solver_ADY.T_plot_H2

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.

T_plot_H2[ExampleModels]
output
dfile:  /builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl
captured errors:
folder = 'ExampleModels'
dfile = '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

    @pytest.mark.parametrize(
        'folder', [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_H2(folder, dfile = None):
        """
        Test that runs the plotting code for H2. This test can be run from another test
        """

        if folder is None:
            folder = "ExampleModels"

        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
        sysB = get_systemB(folder=folder)

        if dfile is None:
            ofile = "results_H2_ADY.pkl"
            dfile = fjoin(folder, ofile)
        print('dfile: ', dfile)
>       H2_results = buzzutil.load_results(dfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_H2[ExampleModels_working_F3]
output
dfile:  /builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl
captured errors:
folder = 'ExampleModels_working_F3'
dfile = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

    @pytest.mark.parametrize(
        'folder', [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_H2(folder, dfile = None):
        """
        Test that runs the plotting code for H2. This test can be run from another test
        """

        if folder is None:
            folder = "ExampleModels"

        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
        sysB = get_systemB(folder=folder)

        if dfile is None:
            ofile = "results_H2_ADY.pkl"
            dfile = fjoin(folder, ofile)
        print('dfile: ', dfile)
>       H2_results = buzzutil.load_results(dfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_H2[ExampleModels_newFOM_F3]
output
dfile:  /builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl
captured errors:
folder = 'ExampleModels_newFOM_F3'
dfile = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

    @pytest.mark.parametrize(
        'folder', [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_H2(folder, dfile = None):
        """
        Test that runs the plotting code for H2. This test can be run from another test
        """

        if folder is None:
            folder = "ExampleModels"

        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
        sysB = get_systemB(folder=folder)

        if dfile is None:
            ofile = "results_H2_ADY.pkl"
            dfile = fjoin(folder, ofile)
        print('dfile: ', dfile)
>       H2_results = buzzutil.load_results(dfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_H2[ExampleModels_newFOM]
output
dfile:  /builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl
captured errors:
folder = 'ExampleModels_newFOM'
dfile = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

    @pytest.mark.parametrize(
        'folder', [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_H2(folder, dfile = None):
        """
        Test that runs the plotting code for H2. This test can be run from another test
        """

        if folder is None:
            folder = "ExampleModels"

        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
        sysB = get_systemB(folder=folder)

        if dfile is None:
            ofile = "results_H2_ADY.pkl"
            dfile = fjoin(folder, ofile)
        print('dfile: ', dfile)
>       H2_results = buzzutil.load_results(dfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_H2[ExampleModels_working]
output
dfile:  /builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl
captured errors:
folder = 'ExampleModels_working'
dfile = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

    @pytest.mark.parametrize(
        'folder', [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_H2(folder, dfile = None):
        """
        Test that runs the plotting code for H2. This test can be run from another test
        """

        if folder is None:
            folder = "ExampleModels"

        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
        sysB = get_systemB(folder=folder)

        if dfile is None:
            ofile = "results_H2_ADY.pkl"
            dfile = fjoin(folder, ofile)
        print('dfile: ', dfile)
>       H2_results = buzzutil.load_results(dfile)

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:176: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_HiB(folder, dfile=None)[source]

This is a pytest needing documentation

code
docstring
"""HinfBounded_results_E = HinfBounded_results + extraplots
H2_results_E = H2_results + extraplots
every_nth = 2 # removes every nth element
H2_results_E_short = H2_results[every_nth-1::every_nth]+ extraplots"""
  1@pytest.mark.parametrize(
  2    'folder',
  3    [
  4        #'ExampleModels_rescale',
  5        'ExampleModels',
  6        'ExampleModels_working',
  7        'ExampleModels_working_F3',
  8        'ExampleModels_newFOM',
  9        'ExampleModels_newFOM_F3'
 10    ]
 11)
 12def T_plot_HiB(folder, dfile = None):
 13    if folder is None:
 14        folder = "ExampleModels"
 15
 16    sysB = get_systemB(folder=folder)
 17    io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function
 18
 19
 20
 21    H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))
 22    print('save fldr: ', fjoin(folder, "results_H2_ADY.pkl"))
 23
 24    if dfile is None:
 25        ofile = "results_Hib_ADY.pkl"
 26        dfile = fjoin(folder, ofile)
 27    results_Hib = buzzutil.load_results(dfile)
 28
 29
 30    # print('Gamma:', buzzutil.listparams(HinfBounded_results, 'gamma'))
 31    # print('igsq:', np.unique(buzzutil.listparams(HinfBounded_results, 'igsq')))
 32    # print('F1_gain', np.unique(buzzutil.listparams(HinfBounded_results, 'F1_gain')))
 33    # print('F1_gain', buzzutil.listparams(HinfBounded_results, 'F1_gain'))
 34
 35    HinfBounded_results = results_Hib
 36    # H2_results = results_H2
 37
 38    # f1_gains = np.unique(buzzutil.listparams(HinfBounded_results, 'F1_gain'))
 39
 40    # HinfBounded_results =  buzzutil.filtparam(HinfBounded_results, "F1_gain", f1_gains[3], compare="eq")
 41
 42    for point in HinfBounded_results:
 43        if point["gamma"] == None:
 44            point["gamma"] = np.inf
 45
 46    # Remove labels
 47    for datadict in HinfBounded_results:
 48        datadict["label1"] = None
 49        datadict["label2"] = None
 50
 51    # Adding the current controller to the plot
 52    module_gain = -40 # this is the gain of the filter module
 53    filter_list = np.array([1, 3, 4, 5, 6]) # this is a list of the filters in the module that are on
 54
 55    zpksys, filtinfo = readFilter.readFilterSys_Scipy(
 56        fjoin("H1ASC.txt"), "ASC_DHARD_Y", np.array(filter_list)
 57    )
 58
 59    z, p, k = FilteringUtils.d2c(
 60        (zpksys.zeros, zpksys.poles, zpksys.gain), fs=1 / zpksys.dt
 61    )
 62
 63    k = k.real * module_gain
 64    K_mod = SISO.zpk(z, p, k, angular=True, fiducial_rtol=1e-5, fiducial_atol=1e-10).asSS
 65    K_iod = {"C.in": 0, "C.out": 0}
 66    K = wieldSS(K_mod, K_iod)
 67    K = (K.siso("C.out", "C.in") * sysB.sys["S.out", "SA.in"]).mimo(
 68        "C.out", "C.in"
 69    ) # Add in the part of P that was moved to env. noise block
 70    K = ssutil.balance_sys_gain(K)
 71
 72    curdict = HinfBounded_results[0].copy()
 73    curdict["Ac"] = K.A
 74    curdict["Bc"] = K.B
 75    curdict["Cc"] = K.C
 76    curdict["Dc"] = K.D
 77    curdict["K"] = K
 78    curdict["label"] = "Hand Tuned Controller"
 79
 80    extraplots = compute.calcFullResults(
 81        [curdict], color="dimgrey", 
 82        label="Hand Tuned Controller", 
 83        plot_omega=curdict["plot_omega"],
 84        io_scales=io_scales,
 85    )
 86    extraplots[0]["F1_gain"] = sum(buzzutil.listparams(HinfBounded_results, "F1_gain"))
 87    extraplots[0]["linecolor"] = "DodgerBlue"
 88    extraplots[0]["linestyle"] = "--"
 89    extraplots[0]["solver"] = "Hand Tuned"
 90    extraplots[0]["rms_marker"] = "^"
 91
 92    HinfBounded_results_E = HinfBounded_results + extraplots
 93    H2_results_E = H2_results + extraplots
 94
 95    every_nth = 2  # removes every nth element
 96    H2_results_E_short = H2_results[every_nth - 1 :: every_nth] + extraplots
 97
 98
 99    xlim= [0.2, 0.5]
100    ylim = [3e-14, 9e-14]
101    # Adding the current controller to the plot
102    setname_Hib = "ADY_Hib"
103
104    if len(HinfBounded_results_E + H2_results)>100:
105        plot_text=False
106    else:
107        plot_text='pm'
108
109    print('Plotting RMS Plot')
110    fig_rms_Hib = plotting.plotRMS(
111        HinfBounded_results_E + H2_results,
112        setname=setname_Hib,
113        outlineparam='pm',
114        text=plot_text,
115        f1line=True,
116        h2line=True,
117        plotrange=False,
118        #xlim=xlim,
119        #ylim=ylim
120        test=True,
121    )
122
123    fig_rms_Hib[0].savefig(tjoin("rms_HiB.pdf"), bbox_inches="tight")
124    fig_rms_Hib[0].savefig(tjoin("rms_HiB.png"), bbox_inches="tight")
125
126    print('Plotting RMS Plot with lost range')
127    fig_rms_lost_range_Hib = plotting.plotRMS(
128        HinfBounded_results_E + H2_results,
129        setname=setname_Hib,
130        outlineparam='pm',
131        text=plot_text,
132        f1line=True,
133        h2line=True,
134        plotrange='diff',
135        test=True,
136        #xlim=xlim,
137        #ylim=ylim
138    )
139
140    fig_rms_lost_range_Hib[0].savefig(tjoin("rms_HiB_lost_range.pdf"), bbox_inches="tight")
141    fig_rms_lost_range_Hib[0].savefig(tjoin("rms_HiB_lost_range.png"), bbox_inches="tight")
142
143    print('Plotting RMS Plot with lost range (PSD computation)')
144    fig_rms_lost_range_Hib_psd = plotting.plotRMS(
145        HinfBounded_results_E + H2_results,
146        setname=setname_Hib,
147        outlineparam='pm',
148        text=plot_text,
149        f1line=True,
150        h2line=True,
151        plotrange='diff_psd',
152        test=True,
153        #xlim=xlim,
154        #ylim=ylim
155    )
156
157    fig_rms_lost_range_Hib_psd[0].savefig(tjoin("rms_HiB_lost_range_PSD.pdf"), bbox_inches="tight")
158    fig_rms_lost_range_Hib_psd[0].savefig(tjoin("rms_HiB_lost_range_PSD.png"), bbox_inches="tight")
159
160
161    f1gains_Hib = np.unique(buzzutil.listparams(HinfBounded_results, "F1_gain"))
162    try:
163        HinfBounded_results_single_f1gain = buzzutil.filtparam(HinfBounded_results, "F1_gain", f1gains_Hib[-4], compare="eq")
164    except:
165        HinfBounded_results_single_f1gain = buzzutil.filtparam(HinfBounded_results, "F1_gain", f1gains_Hib[0], compare="eq")
166    HinfBounded_results_single_f1gain = (
167        compute.calcFullResults(
168            HinfBounded_results_single_f1gain,
169            colormap="RdYlGn",
170            plot_omega=HinfBounded_results[0]["plot_omega"],
171            color_param="igsq",
172            label=False,
173            io_scales=io_scales,
174        )
175        + extraplots
176    )
177
178    print('Plotting RMS Plot With Range')
179    fig_rms_range_Hib = plotting.plotRMS(
180        HinfBounded_results + H2_results,
181        setname=setname_Hib,
182        outlineparam='pm',
183        text=plot_text,
184        f1line=True,
185        h2line=True,
186        plotrange=True,
187        test=True,
188        #xlim=xlim,
189        #ylim=ylim
190    )
191
192    fig_rms_range_Hib[0].savefig(tjoin("rms_HiB_range.pdf"), bbox_inches="tight")
193    fig_rms_range_Hib[0].savefig(tjoin("rms_HiB_range.png"), bbox_inches="tight")
194
195    xlim_PSD=[4.725, 4.805]
196    print('Plotting RMS Plot With Range from PSD')
197    fig_rms_range_PSD_Hib = plotting.plotRMS(
198        HinfBounded_results + H2_results,
199        setname=setname_Hib,
200        outlineparam='pm',
201        text=plot_text,
202        f1line=True,
203        h2line=True,
204        plotrange='PSD',
205        xlim=xlim_PSD,
206        test=True,
207        #ylim=ylim
208    )
209
210    fig_rms_range_PSD_Hib[0].savefig(tjoin("rms_HiB_range_from_PSD.pdf"), bbox_inches="tight")
211    fig_rms_range_PSD_Hib[0].savefig(tjoin("rms_HiB_range_from_PSD.png"), bbox_inches="tight")
212
213    print('Plotting Heatmap')
214    fig_rmsheatmap = plotting.plotHeatmap(HinfBounded_results + H2_results, test=True)
215    fig_rmsheatmap[0].savefig(tjoin("heatmap.pdf"), bbox_inches="tight")
216    fig_rmsheatmap[0].savefig(tjoin("heatmap.png"), bbox_inches="tight")
217
218    try:
219        print('Plotting RMS Plot with Heatmap')
220        fig_rmsheatmap_Hib = plotting.plotRMS(
221            HinfBounded_results_E + H2_results,
222            setname=setname_Hib,
223            outlineparam='pm',
224            text=False,
225            f1line=True,
226            h2line=True,
227            plotrange=True,
228            heatmap=True,
229            test=True,
230        )
231
232        fig_rmsheatmap_Hib[0].savefig(tjoin("rms_heatmap_HiB.pdf"), bbox_inches="tight")
233        fig_rmsheatmap_Hib[0].savefig(tjoin("rms_heatmap_HiB.png"), bbox_inches="tight")
234    except Exception as e:
235        print("Heatmap Failed:, ", e)
236
237    print('Plotting RMS Range Plot single result')
238    fig_single_Hib = plotting.plotRMS(
239        HinfBounded_results_single_f1gain + H2_results,
240        setname=setname_Hib,
241        outlineparam='pm',
242        text=False,
243        f1line=True,
244        h2line=True,
245        plotrange=True,
246        heatmap=False,
247        test=True,
248    )
249
250    fig_single_Hib[0].savefig(tjoin("rms_HiB_singlef1gain_range.pdf"), bbox_inches="tight")
251    fig_single_Hib[0].savefig(tjoin("rms_HiB_singlef1gain_range.png"), bbox_inches="tight")
252
253
254
255
256    print('Plotting Open Loop')
257    ylim = [3e-4, 1e5]
258    fig_ol_Hib, ax_ol_Hib = plotting.plotLoop(
259        HinfBounded_results_single_f1gain, "OL", setname=setname_Hib, ylim=ylim, UG_line=True, test=True,
260    )
261    fig_ol_Hib.savefig(tjoin("ol_HiB.pdf"), bbox_inches="tight")
262    fig_ol_Hib.savefig(tjoin("ol_HiB.png"), bbox_inches="tight")
263
264    print('Plotting Closed Loop')
265    xlim = [1e-1, 1e4]
266    fig_cl_Hib, ax_cl_Hib = plotting.plotLoop(
267        HinfBounded_results_single_f1gain, "CL", setname=setname_Hib, UG_line=True, xlim=xlim, test=True,
268    )
269    fig_cl_Hib.savefig(tjoin("cl_HiB.pdf"), bbox_inches="tight")
270    fig_cl_Hib.savefig(tjoin("cl_HiB.png"), bbox_inches="tight")
271
272    print('Plotting gm pm plot')
273    ylim = None  # [0, 12]
274    plt.clf()
275    fig_gm_pm, ax_gm_pm = plotting.plot_gm_pm(
276        HinfBounded_results_E, setname="", f1line=True, text=None, ylim=[0.5,2.5], xlim=[2.5,20], io_scales=io_scales, test=True,
277    )
278    fig_gm_pm.savefig(tjoin("gm_HiB.pdf"), bbox_inches="tight")
279    fig_gm_pm.savefig(tjoin("gm_HiB.png"), bbox_inches="tight")
280
281    print('Plotting vegaplot')
282    setname_vega = 'ASC_vega'
283    vega_chart = plotting.vega_plot(HinfBounded_results_E + H2_results, setname=setname_vega, h2line=False, size=500, plotrange=False, test=True)
284    vega_chart.save(tjoin("vega_results_plot.html"))
285
286    DARM_out_name = 'DARM.out'
287    if DARM_out_name in extraplots[0]['CL_all_io'].outputs.keys():
288        print('Plotting DARM noise')
289        DARM_plot_omega = np.logspace(-2, 3, 1000) * 2 * np.pi
290        DARM_noise_plot_fig, DARM_noise_plot_axs = plotting.plot_CLnoises(extraplots[0], extra_fom=DARM_out_name, extra_only=True, plot_omega=DARM_plot_omega, test=True, scale=1/io_scales.w2_rescale)
291        DARM_noise_plot_fig.savefig(tjoin("DARM_noise_H2.pdf"), bbox_inches="tight")
292        DARM_noise_plot_fig.savefig(tjoin("DARM_noise_H2.png"), bbox_inches="tight")
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:

test.ASC_SOLVER.test_solver_ADY.T_plot_HiB

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.

T_plot_HiB[ExampleModels]
output
status: failed
duration: 0.005s
captured errors:
folder = 'ExampleModels', dfile = None

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_HiB(folder, dfile = None):
        if folder is None:
            folder = "ExampleModels"

        sysB = get_systemB(folder=folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function



>       H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_HiB[ExampleModels_newFOM_F3]
output
status: failed
duration: 0.005s
captured errors:
folder = 'ExampleModels_newFOM_F3', dfile = None

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_HiB(folder, dfile = None):
        if folder is None:
            folder = "ExampleModels"

        sysB = get_systemB(folder=folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function



>       H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_HiB[ExampleModels_newFOM]
output
status: failed
duration: 0.005s
captured errors:
folder = 'ExampleModels_newFOM', dfile = None

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_HiB(folder, dfile = None):
        if folder is None:
            folder = "ExampleModels"

        sysB = get_systemB(folder=folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function



>       H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_newFOM/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_HiB[ExampleModels_working]
output
status: failed
duration: 0.005s
captured errors:
folder = 'ExampleModels_working', dfile = None

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_HiB(folder, dfile = None):
        if folder is None:
            folder = "ExampleModels"

        sysB = get_systemB(folder=folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function



>       H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
T_plot_HiB[ExampleModels_working_F3]
output
status: failed
duration: 0.005s
captured errors:
folder = 'ExampleModels_working_F3', dfile = None

    @pytest.mark.parametrize(
        'folder',
        [
            #'ExampleModels_rescale',
            'ExampleModels',
            'ExampleModels_working',
            'ExampleModels_working_F3',
            'ExampleModels_newFOM',
            'ExampleModels_newFOM_F3'
        ]
    )
    def T_plot_HiB(folder, dfile = None):
        if folder is None:
            folder = "ExampleModels"

        sysB = get_systemB(folder=folder)
        io_scales = file_io.load(fjoin(folder, 'io_scales.yml')) # Saved by the normalization in the make function



>       H2_results = buzzutil.load_results(fjoin(folder, "results_H2_ADY.pkl"))

/builds/buzz/test/ASC_SOLVER/test_solver_ADY.py:491: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

    def load_results(filename):
        """Loads the results from a pickle file

        Args:
            filename (str): filename to load the results from

        Returns:
            list: list of results dictionaries
        """
>       with open(filename, 'rb') as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/builds/buzz/test/ASC_SOLVER/ExampleModels_working_F3/results_H2_ADY.pkl'

/builds/buzz/src/buzz/buzzutil.py:230: FileNotFoundError
get_systemB(folder='ExampleModels')[source]

This is a pytest needing documentation

code
1def get_systemB(folder = 'ExampleModels'):
2    fname = fjoin(folder, "ADY_Sanex.mat")
3    sys = ssutil.loadSys(fname)
4
5    orig_plant_fname = fjoin(folder, "ADY_plant.mat")
6    orig_plant = ssutil.loadSys(orig_plant_fname)
7
8    return Bunch(locals())
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:

test.ASC_SOLVER.test_solver_ADY.get_systemB

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.