%23%20gallery_category%3A%20Analysis%20%26%20Verification%0A%23%20gallery_title%3A%20Tracking%20the%20modes%20of%20a%20reverberation%20enhancement%20system%0A%23%20gallery_description%3A%20Follow%20the%20dominant%20poles%20of%20an%20FDN-based%20RES%20as%20its%20loop%20gain%20rises%20past%20the%20maximum%20stable%20gain%2C%20and%20see%20which%20channels%20carry%20the%20mode%20that%20goes%20unstable.%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Tracking%20the%20modes%20of%20a%20reverberation%20enhancement%20system%0A%0A%20%20%20%20A%20**reverberation%20enhancement%20system**%20(RES)%20feeds%20microphone%20signals%20through%20a%20reverberator%20to%20loudspeakers%20in%20the%20same%20room%2C%20so%20the%20loudspeakers%20reach%20the%20microphones%20again%3A%20an%20acoustic%20feedback%20loop%20around%20an%20FDN.%20Its%20stability%20is%20decided%20by%20a%20few%20modes.%20As%20the%20electronic%20loop%20gain%20%24g%24%20rises%20they%20move%20towards%20the%20unit%20circle%2C%20ring%20longer%2C%20and%20at%20the%20**maximum%20stable%20gain**%20(MSG)%20the%20first%20one%20crosses.%0A%0A%20%20%20%20The%20whole%20loop%20has%20tens%20of%20thousands%20of%20poles%2C%20so%20a%20full%20modal%20decomposition%20at%20every%20gain%20is%20out%20of%20reach.%20Instead%20we%0A%0A%20%20%20%201.%20find%20the%20few%20**dominant**%20poles%20at%20a%20high%20gain%20with%20%60pyFDN.seed_poles%60%2C%0A%20%20%20%202.%20follow%20them%20down%20the%20gain%20with%20%60pyFDN.track_poles%60%2C%20a%20continuation%20method%20after%20Bai%20and%20Schlecht%20(ICASSP%202026)%2C%0A%20%20%20%203.%20read%20off%20each%20mode's%20decay%20rate%2C%20the%20MSG%2C%20and%20which%20channels%20carry%20the%20critical%20mode.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20torch%0A%20%20%20%20from%20flamo.processor%20import%20system%0A%20%20%20%20from%20scipy.signal%20import%20lfilter%0A%0A%20%20%20%20import%20pyFDN%0A%0A%20%20%20%20return%20lfilter%2C%20np%2C%20plt%2C%20pyFDN%2C%20system%2C%20torch%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20The%20system%0A%0A%20%20%20%20An%20FDN%20with%20four%20delay%20lines%20and%20a%201.5%20s%20reverberation%20time%2C%20four%20microphones%20and%20four%20loudspeakers.%20The%20loudspeaker%20%E2%86%92%20microphone%20coupling%20%24R(z)%24%20is%20a%20%244%20%5Ctimes%204%24%20FIR%20matrix%20of%201024%20taps%3A%20a%20direct%20path%20%241%2Fr%24%20at%20the%20propagation%20delay%20and%20a%20decaying%2C%20low-passed%20noise%20tail%20for%20the%20early%20room%20response.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(lfilter%2C%20np%2C%20pyFDN)%3A%0A%20%20%20%20fs%20%3D%2048_000.0%0A%20%20%20%20rng%20%3D%20np.random.default_rng(2)%0A%20%20%20%20n_lines%20%3D%20n_channels%20%3D%204%0A%20%20%20%20delays%20%3D%20np.array(%5B997%2C%201153%2C%201327%2C%201559%5D)%0A%20%20%20%20line_gains%20%3D%2010%20**%20(-3%20*%20delays%20%2F%20(1.5%20*%20fs))%20%20%23%201.5%20s%20reverberation%20time%0A%20%20%20%20A%20%3D%20pyFDN.random_orthogonal(n_lines%2C%20rng%3Drng)%20*%20line_gains%5BNone%2C%20%3A%5D%0A%20%20%20%20B%20%3D%20rng.standard_normal((n_lines%2C%20n_channels))%20%2F%20n_lines%20%20%23%20mics%20-%3E%20FDN%0A%20%20%20%20C%20%3D%20rng.standard_normal((n_channels%2C%20n_lines))%20%2F%20n_lines%20%20%23%20FDN%20-%3E%20speakers%0A%0A%20%20%20%20_taps%20%3D%201024%0A%20%20%20%20_n%20%3D%20np.arange(_taps)%0A%20%20%20%20_distance%20%3D%20rng.uniform(2.0%2C%205.0%2C%20(n_channels%2C%20n_channels))%20%20%23%20metres%0A%20%20%20%20_lag%20%3D%20np.round(_distance%20%2F%20343%20*%20fs).astype(int)%0A%20%20%20%20coupling%20%3D%20np.zeros((n_channels%2C%20n_channels%2C%20_taps))%0A%20%20%20%20for%20_i%20in%20range(n_channels)%3A%0A%20%20%20%20%20%20%20%20for%20_j%20in%20range(n_channels)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_tail%20%3D%20np.where(_n%20%3E%20_lag%5B_i%2C%20_j%5D%2C%20np.exp(-(_n%20-%20_lag%5B_i%2C%20_j%5D)%20%2F%20600)%2C%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20_noise%20%3D%20lfilter(%5B0.3%5D%2C%20%5B1%2C%20-0.7%5D%2C%200.05%20*%20rng.standard_normal(_taps))%0A%20%20%20%20%20%20%20%20%20%20%20%20coupling%5B_i%2C%20_j%5D%20%3D%20_tail%20*%20_noise%0A%20%20%20%20%20%20%20%20%20%20%20%20coupling%5B_i%2C%20_j%2C%20_lag%5B_i%2C%20_j%5D%5D%20%2B%3D%201%20%2F%20_distance%5B_i%2C%20_j%5D%0A%20%20%20%20return%20A%2C%20B%2C%20C%2C%20coupling%2C%20delays%2C%20fs%2C%20n_channels%2C%20n_lines%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20One%20flat%20loop%0A%0A%20%20%20%20Pole%20tracking%20needs%20the%20RES%20as%20**one**%20FLAMO%20%60Recursion%60%2C%20not%20the%20FDN's%20loop%20nested%20inside%20the%20acoustic%20one%3A%20a%20nested%20loop%20puts%20the%20FDN's%20own%20poles%20into%20%24%5Cdet%20P(z)%24%2C%20right%20next%20to%20the%20closed-loop%20poles%20being%20tracked.%20With%20the%20delay-line%20outputs%20%24x%24%20and%20the%20microphone%20signals%20%24m%24%20as%20the%20loop%20state%2C%20the%20characteristic%20matrix%20is%0A%0A%20%20%20%20%24%24%0A%20%20%20%20P(z)%20%3D%20I%20-%20%5Cbegin%7Bbmatrix%7D%20D_m(z)%20%26%200%20%5C%5C%200%20%26%20R(z)%20%5Cend%7Bbmatrix%7D%0A%20%20%20%20%5Cbegin%7Bbmatrix%7D%20A%20%26%20B%20%5C%5C%20g%5C%2CC%20%26%200%20%5Cend%7Bbmatrix%7D%2C%0A%20%20%20%20%24%24%0A%0A%20%20%20%20with%20%24D_m(z)%24%20the%20delays.%20The%20feedforward%20path%20is%20block-diagonal%3A%20FLAMO's%20%60Parallel%60%20feeds%20both%20branches%20the%20same%20input%2C%20so%20a%20fixed%20selection%20gain%20in%20front%20of%20each%20picks%20its%20part.%20The%20feedback%20path%20is%20the%20mixing%20matrix%20followed%20by%20a%20diagonal%20gain%20that%20holds%20%24g%24%20on%20the%20loudspeaker%20rows%2C%20which%20is%20the%20parameter%20we%20move.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20A%2C%0A%20%20%20%20B%2C%0A%20%20%20%20C%2C%0A%20%20%20%20coupling%2C%0A%20%20%20%20delays%2C%0A%20%20%20%20fs%2C%0A%20%20%20%20n_channels%2C%0A%20%20%20%20n_lines%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pyFDN%2C%0A%20%20%20%20system%2C%0A%20%20%20%20torch%2C%0A)%3A%0A%20%20%20%20_nfft%20%3D%202**10%20%20%23%20not%20used%20for%20probing%3B%20FLAMO%20needs%20one%20to%20build%20modules%0A%20%20%20%20_opt%20%3D%20%7B%22device%22%3A%20%22cpu%22%2C%20%22dtype%22%3A%20torch.float64%7D%20%20%23%20pole%20tracking%20needs%20float64%0A%20%20%20%20_select_x%20%3D%20np.hstack(%5Bnp.eye(n_lines)%2C%20np.zeros((n_lines%2C%20n_channels))%5D)%0A%20%20%20%20_select_s%20%3D%20np.hstack(%5Bnp.zeros((n_channels%2C%20n_lines))%2C%20np.eye(n_channels)%5D)%0A%20%20%20%20_feedforward%20%3D%20system.Parallel(%0A%20%20%20%20%20%20%20%20system.Series(%0A%20%20%20%20%20%20%20%20%20%20%20%20pyFDN.gain_module(_select_x%2C%20_nfft%2C%20**_opt)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20pyFDN.delay_module(delays%2C%20_nfft%2C%20fs%3Dfs%2C%20**_opt)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20system.Series(%0A%20%20%20%20%20%20%20%20%20%20%20%20pyFDN.gain_module(_select_s%2C%20_nfft%2C%20**_opt)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20pyFDN.fir_matrix_module(coupling%2C%20_nfft%2C%20**_opt)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20sum_output%3DFalse%2C%0A%20%20%20%20)%0A%20%20%20%20_mixing%20%3D%20np.block(%5B%5BA%2C%20B%5D%2C%20%5BC%2C%20np.zeros((n_channels%2C%20n_channels))%5D%5D)%0A%20%20%20%20_feedback%20%3D%20system.Series(%0A%20%20%20%20%20%20%20%20pyFDN.gain_module(_mixing%2C%20_nfft%2C%20**_opt)%2C%0A%20%20%20%20%20%20%20%20pyFDN.gain_module(np.eye(n_lines%20%2B%20n_channels)%2C%20_nfft%2C%20**_opt)%2C%0A%20%20%20%20)%0A%20%20%20%20loop%20%3D%20system.Recursion(fF%3D_feedforward%2C%20fB%3D_feedback)%0A%20%20%20%20%23%20degree%20of%20det%20P(z)%3A%20the%20delays%20plus%20the%20coupling%20FIR%20on%20every%20microphone%0A%20%20%20%20order%20%3D%20int(delays.sum()%20%2B%20n_channels%20*%20(coupling.shape%5B-1%5D%20-%201))%0A%20%20%20%20print(%22parameters%3A%22%2C%20%5B_name%20for%20_name%2C%20_%20in%20loop.named_parameters()%5D)%0A%20%20%20%20print(%22order%3A%22%2C%20order)%0A%20%20%20%20return%20loop%2C%20order%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Gain%20path%20and%20dominant%20poles%0A%0A%20%20%20%20The%20path%20moves%20only%20%60feedback.1.param%60%2C%20the%20diagonal%20gain%2C%20from%20%E2%88%9220%20dB%20to%20%E2%88%925%20dB%20in%20steps%20uniform%20in%20dB%20(for%20a%20delay%20loop%2C%20%24%5Clog%20z%24%20moves%20linearly%20in%20%24%5Clog%20g%24%2C%20so%20the%20predictor%20is%20nearly%20exact).%20We%20seed%20the%20eight%20largest%20poles%20at%20the%20**top**%20of%20the%20range%2C%20where%20stability%20is%20decided%2C%20and%20track%20them%20**backwards**%3A%20the%20modes%20that%20matter%20are%20the%20ones%20dominant%20near%20the%20MSG%2C%20not%20at%20low%20gain.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(loop%2C%20n_channels%2C%20n_lines%2C%20np%2C%20order%2C%20pyFDN%2C%20torch)%3A%0A%20%20%20%20low_db%2C%20high_db%20%3D%20-20.0%2C%20-5.0%0A%0A%20%20%20%20def%20path(t)%3A%0A%20%20%20%20%20%20%20%20gain%20%3D%2010%20**%20((low_db%20%2B%20(high_db%20-%20low_db)%20*%20t)%20%2F%2020)%0A%20%20%20%20%20%20%20%20ones%20%3D%20torch.ones(n_lines%2C%20dtype%3Dtorch.float64)%0A%20%20%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22feedback.1.param%22%3A%20torch.diag(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20torch.cat(%5Bones%2C%20gain%20*%20ones.new_ones(n_channels)%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20seeds%20%3D%20pyFDN.seed_poles(loop%2C%208%2C%20path%3Dpath%2C%20t%3D1.0%2C%20order%3Dorder)%0A%20%20%20%20tracks%20%3D%20pyFDN.track_poles(%0A%20%20%20%20%20%20%20%20loop%2C%20path%2C%20seeds%2C%20t0%3D1.0%2C%20t1%3D0.0%2C%20order%3Dorder%2C%20max_step%3D0.04%0A%20%20%20%20)%0A%20%20%20%20gain_db%20%3D%20low_db%20%2B%20(high_db%20-%20low_db)%20*%20tracks.t%0A%20%20%20%20print(%0A%20%20%20%20%20%20%20%20f%22%7Blen(tracks.t)%7D%20steps%2C%20tracks%20lost%3A%20%7Bint(np.isnan(tracks.poles%5B-1%5D).sum())%7D%22%0A%20%20%20%20)%0A%20%20%20%20return%20gain_db%2C%20high_db%2C%20low_db%2C%20path%2C%20tracks%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Decay%20rate%20of%20the%20dominant%20modes%0A%0A%20%20%20%20A%20pole%20%24z_k%24%20decays%20(or%20grows)%20at%20%2420%20f_s%20%5Clog_%7B10%7D%7Cz_k%7C%24%20dB%20per%20second%3B%20its%20%24T_%7B60%7D%24%20is%20%2460%24%20divided%20by%20the%20decay%20rate.%20Each%20mode's%20critical%20gain%2C%20where%20its%20rate%20crosses%20zero%2C%20is%20interpolated%20between%20the%20tracked%20steps%20(about%20half%20a%20dB%20apart).%20The%20MSG%20is%20the%20lowest%20of%20them.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(fs%2C%20gain_db%2C%20np%2C%20plt%2C%20tracks)%3A%0A%20%20%20%20rate%20%3D%2020%20*%20fs%20*%20np.log10(np.abs(tracks.poles))%20%20%23%20dB%2Fs%2C%20%3E%200%20grows%0A%20%20%20%20frequency%20%3D%20np.angle(tracks.poles)%20*%20fs%20%2F%20(2%20*%20np.pi)%0A%20%20%20%20_order%20%3D%20np.argsort(gain_db)%0A%20%20%20%20critical%20%3D%20np.array(%20%20%23%20NaN%3A%20the%20mode%20does%20not%20cross%20within%20the%20range%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20np.interp(0.0%2C%20rate%5B_order%2C%20_k%5D%2C%20gain_db%5B_order%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20rate%5B%3A%2C%20_k%5D.min()%20%3C%200%20%3C%20rate%5B%3A%2C%20_k%5D.max()%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20np.nan%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20_k%20in%20range(rate.shape%5B1%5D)%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20critical_mode%20%3D%20int(np.nanargmin(critical))%0A%20%20%20%20msg_db%20%3D%20float(critical%5Bcritical_mode%5D)%0A%0A%20%20%20%20_fig%2C%20(_ax_rate%2C%20_ax_freq)%20%3D%20plt.subplots(1%2C%202%2C%20figsize%3D(10%2C%204)%2C%20sharex%3DTrue)%0A%20%20%20%20for%20_k%20in%20range(rate.shape%5B1%5D)%3A%0A%20%20%20%20%20%20%20%20_style%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%22lw%22%3A%202.5%2C%20%22color%22%3A%20%22C3%22%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20_k%20%3D%3D%20critical_mode%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%7B%22lw%22%3A%201%2C%20%22color%22%3A%20%220.5%22%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20_ax_rate.plot(gain_db%2C%20rate%5B%3A%2C%20_k%5D%2C%20**_style)%0A%20%20%20%20%20%20%20%20_ax_freq.plot(gain_db%2C%20frequency%5B%3A%2C%20_k%5D%20%2F%201000%2C%20**_style)%0A%20%20%20%20for%20_ax%20in%20(_ax_rate%2C%20_ax_freq)%3A%0A%20%20%20%20%20%20%20%20_ax.axvline(msg_db%2C%20color%3D%22C3%22%2C%20ls%3D%22--%22%2C%20lw%3D1)%0A%20%20%20%20%20%20%20%20_ax.set_xlabel(%22loop%20gain%20(dB)%22)%0A%20%20%20%20_ax_rate.axhline(0%2C%20color%3D%22k%22%2C%20lw%3D0.8)%0A%20%20%20%20_ax_rate.set_ylabel(%22decay%20rate%20(dB%2Fs%2C%20%3E%200%20grows)%22)%0A%20%20%20%20_ax_rate.set_title(f%22MSG%20%3D%20%7Bmsg_db%3A.2f%7D%20dB%22)%0A%20%20%20%20_ax_freq.set_ylabel(%22mode%20frequency%20(kHz)%22)%0A%20%20%20%20_ax_freq.set_title(%22the%20modes%20barely%20move%20in%20frequency%22)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20print(f%22critical%20mode%20at%20%7Bfrequency%5B0%2C%20critical_mode%5D%3A.0f%7D%20Hz%2C%20MSG%20%7Bmsg_db%3A.2f%7D%20dB%22)%0A%20%20%20%20print(%0A%20%20%20%20%20%20%20%20f%22T60%20of%20that%20mode%203%20dB%20below%20the%20MSG%3A%20%7B60%20%2F%20-np.interp(msg_db%20-%203%2C%20gain_db%5B_order%5D%2C%20rate%5B_order%2C%20critical_mode%5D)%3A.1f%7D%20s%22%0A%20%20%20%20)%0A%20%20%20%20_fig%0A%20%20%20%20return%20critical_mode%2C%20msg_db%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Check%3A%20no%20untracked%20mode%20crosses%20first%0A%0A%20%20%20%20Tracking%20eight%20modes%20can%20only%20find%20the%20MSG%20if%20none%20of%20the%20other%20poles%20crosses%20earlier.%20Seeding%20again%20directly%20at%20the%20MSG%2C%20from%20scratch%2C%20must%20give%20the%20critical%20mode%20as%20the%20largest%20pole%2C%20on%20the%20unit%20circle%3A%20a%20decay%20rate%20of%20zero.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(fs%2C%20high_db%2C%20loop%2C%20low_db%2C%20msg_db%2C%20np%2C%20order%2C%20path%2C%20pyFDN)%3A%0A%20%20%20%20_t%20%3D%20(msg_db%20-%20low_db)%20%2F%20(high_db%20-%20low_db)%0A%20%20%20%20_largest%20%3D%20pyFDN.seed_poles(loop%2C%201%2C%20path%3Dpath%2C%20t%3D_t%2C%20order%3Dorder)%5B0%5D%0A%20%20%20%20_rate%20%3D%2020%20*%20fs%20*%20np.log10(abs(_largest))%0A%20%20%20%20print(%0A%20%20%20%20%20%20%20%20f%22largest%20pole%20at%20the%20MSG%3A%20%7Bnp.angle(_largest)%20*%20fs%20%2F%20(2%20*%20np.pi)%3A.0f%7D%20Hz%2C%20%7B_rate%3A%2B.3f%7D%20dB%2Fs%22%0A%20%20%20%20)%0A%20%20%20%20assert%20abs(_rate)%20%3C%200.1%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Which%20channels%20carry%20the%20critical%20mode%0A%0A%20%20%20%20At%20a%20pole%2C%20the%20right%20singular%20vector%20%24r%24%20of%20%24P%24%20satisfies%20%24r%20%3D%20F%20B%20r%24%3A%20it%20is%20the%20loop%20state%20of%20the%20mode%2C%20the%20delay-line%20outputs%20and%20the%20microphone%20signals.%20Its%20magnitudes%20show%20where%20the%20mode%20lives%3A%20which%20microphones%20pick%20up%20the%20feedback%20most%2C%20i.e.%20where%20a%20notch%20or%20a%20gain%20change%20would%20help.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(critical_mode%2C%20gain_db%2C%20msg_db%2C%20n_channels%2C%20n_lines%2C%20np%2C%20plt%2C%20tracks)%3A%0A%20%20%20%20_step%20%3D%20int(np.argmin(np.abs(gain_db%20-%20msg_db)))%0A%20%20%20%20_weight%20%3D%20np.abs(tracks.right%5B_step%2C%20critical_mode%5D)%0A%20%20%20%20_labels%20%3D%20%5Bf%22line%20%7B_i%20%2B%201%7D%22%20for%20_i%20in%20range(n_lines)%5D%20%2B%20%5B%0A%20%20%20%20%20%20%20%20f%22mic%20%7B_i%20%2B%201%7D%22%20for%20_i%20in%20range(n_channels)%0A%20%20%20%20%5D%0A%20%20%20%20_fig%2C%20_ax%20%3D%20plt.subplots(figsize%3D(7%2C%203))%0A%20%20%20%20_ax.bar(%0A%20%20%20%20%20%20%20%20_labels%2C%20_weight%20%2F%20_weight.max()%2C%20color%3D%5B%220.6%22%5D%20*%20n_lines%20%2B%20%5B%22C0%22%5D%20*%20n_channels%0A%20%20%20%20)%0A%20%20%20%20_ax.set_ylabel(%22%7Cr%7C%20(normalised)%22)%0A%20%20%20%20_ax.set_title(%22loop%20state%20of%20the%20critical%20mode%20at%20the%20MSG%22)%0A%20%20%20%20_fig.tight_layout()%0A%20%20%20%20_fig%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
542b89038459031f05412c377f81c362