'eigenvalues.mat', {
        'Omega_mat': Omega_mat,
        'strength_scan': strength_scan,
        'DQ_0_vect': 0 * strength_scan,
        'M00_array': M00_array,
        'omega0': omega0,
        'omega_s': omega_s,
        'l_min': l_min,
        'l_max': l_max,
        'm_max': m_max,
        'N_max': N_max
    })

import matplotlib.pyplot as plt
plt.close('all')
ms.mystyle(fontsz=13, traditional_look=False)

mask_unstable = np.imag(Omega_mat) < -abs_min_imag_unstab
Omega_mat_unstable = Omega_mat.copy()
Omega_mat_unstable[~mask_unstable] = np.nan + 1j * np.nan

i_mode = -1
mask_mode = np.abs(np.real(Omega_mat) / omega_s - i_mode) < 0.5
plt.plot(strength_scan, np.imag(Omega_mat), '.b')
plt.plot(strength_scan, np.imag(Omega_mat), '.b')
Omega_mat_mode = Omega_mat.copy()
Omega_mat_mode[~mask_mode] = np.nan

title = f'l_min={l_min}, l_max={l_max}, m_max={m_max}, N_max={N_max}'

figre = plt.figure(200)
    y_after = np.take(y_after, indsort)
    z_after = np.take(z_after, indsort)
    xp_after = np.take(xp_after, indsort)
    yp_after = np.take(yp_after, indsort)

    x_i[:, ii] = x_after[:n_record]
    xp_i[:, ii] = xp_after[:n_record]
    y_i[:, ii] = y_after[:n_record]
    yp_i[:, ii] = yp_after[:n_record]


from tune_analysis import tune_analysis
qx_i, qy_i, qx_centroid, qy_centroid = tune_analysis(x_i, xp_i, y_i, yp_i)

pl.close('all')
ms.mystyle(fontsz=14)
pl.figure(1)
sp1 = pl.subplot(2, 1, 1)
pl.plot(np.mean(x_i, axis=0), '.-b', markersize=5, linewidth=2, label='PyHT')
pl.ylabel('<x>')
pl.grid('on')
ms.sciy()
pl.legend(prop={'size': 14})
pl.subplot(2, 1, 2, sharex=sp1)
pl.plot(np.mean(y_i, axis=0), '.-b', markersize=5, linewidth=2, label='PyHT')
pl.xlabel('Turn'); pl.ylabel('<y>')
pl.grid('on')
ms.sciy()
#pl.savefig(filename.split('_prb.dat')[0]+'_centroids.png', dpi=200)