Beispiel #1
0
                        nperseg=100)
print(t.shape, f.shape, Zxx.shape)
# print(f.shape, f[:10])
# print(t.shape, t[:10])
# print(Zxx.shape, Zxx[:10])
# print(len([stft**2 for stft in Zxx]), [stft**2 for stft in Zxx][:10])

signal_fig = FigData(
    xs=nst.samp_nums,
    ys=[nst.data],
    title=f"(a) Non stationary signal (samp rate = {samp_rate})",
    plot_type="plot",
    xlabel="Time (s)",
    ylabel="Amplitude")

stft_fig = apreset.stft_pcolormesh(t=t,
                                   f=f,
                                   Zxx=Zxx,
                                   title=f"(b) STFT Magnitude",
                                   yscale="linear",
                                   ylim=(0, 50),
                                   colorbar_params={"pad": 0.05})

aplot.single_subplots(grid_size=(1, 2),
                      fig_data={
                          (0, 0): signal_fig,
                          (0, 1): stft_fig
                      },
                      individual_figsize=(5, 3.5),
                      savefig_path="stft_sines.png")
Beispiel #2
0
        azi_line_options[0]["vmax"] = np.max(peaks[i])
        peak_fig = FigData(xs=np.arange(beta + 1),
                           ys=f,
                           zs=peaks[i],
                           title=f"Null magnitude estimation ({est_method})",
                           line_options=azi_line_options,
                           ylim=ylim,
                           **azi_fig_params)

        fig_data[(0, i)] = null_fig
        fig_data[(1, i)] = peak_fig

    stft_src_fig = apreset.stft_pcolormesh(
        t=t,
        f=f,
        Zxx=stft,
        title=f"{channel} Channel STFT Magnitude w/ {window} window\n"
        f"winlen = {nperseg}, noverlap = {noverlap}",
        yscale="linear",
        ylim=ylim)
    fig_data[(2, 0)] = stft_src_fig

    recon_stft_figs = [None for i in range(len(recon_stfts))]
    for i, recon_stft in enumerate(recon_stfts):
        recon_stft_figs[i] = apreset.stft_pcolormesh(
            t=t,
            f=f,
            Zxx=recon_stft,
            title=
            f"Separated source '{sep_names[i]}'\nat d={ds[i]} with width H={Hs[i]}",
            yscale="linear",
            ylim=ylim)
Beispiel #3
0
# Plot the original signal and the STFT
signal_fig = FigData(xs=nst.samp_nums,
                     ys=[nst.data],
                     title="Non stationary signal",
                     plot_type="plot",
                     xlabel="Time (s)",
                     ylabel="Amplitude",
                     figsize=(5, 2.5))
aplot.single_plot(signal_fig,
                  auto_timestamp=False,
                  folder="stft_schematic",
                  # savefig_path="signal.png"
                  )


stft_fig = apreset.stft_pcolormesh(t=t,
                                   f=f,
                                   Zxx=Zxx,
                                   title="STFT Magnitude",
                                   yscale="linear",
                                   figsize=(5, 2.5),
                                   colorbar_params={})
aplot.single_plot(stft_fig,
                  auto_timestamp=False,
                  folder="stft_schematic",
                  savefig_path="stft.png"
                  )


Beispiel #4
0
                         ylim=r_ylim,
                         **azi_fig_params)

azi_line_options[0]["vmax"] = np.max(r_azi_peak_tau)
r_azi_peak_fig = FigData(xs=np.arange(beta + 1),
                         ys=f,
                         zs=r_azi_peak_tau,
                         title=f"Null magnitude estimation ({est_method})",
                         line_options=azi_line_options,
                         ylim=r_ylim,
                         **azi_fig_params)

l_stft_src_fig = apreset.stft_pcolormesh(t=t,
                                         f=f,
                                         Zxx=left_stft,
                                         title=f"Left Channel STFT Magnitude w/ {window} window\n"
                                               f"winlen = {nperseg}, noverlap = {noverlap}",
                                         yscale="linear",
                                         ylim=l_ylim)

r_stft_src_fig = apreset.stft_pcolormesh(t=t,
                                         f=f,
                                         Zxx=right_stft,
                                         title=f"Right Channel STFT Magnitude w/ {window} window\n"
                                               f"winlen = {nperseg}, noverlap = {noverlap}",
                                         yscale="linear",
                                         ylim=r_ylim)

l_stft_rec_fig = apreset.stft_pcolormesh(t=t,
                                         f=f,
                                         Zxx=left_stft_recon,
Beispiel #5
0
azi_fig_params = {
    "options": ["invert_xaxis"],
    "plot_type": "pcolormesh",
    "xlabel": "Azimuth",
    "ylabel": "Frequency"
}
azi_line_options = [{"vmin": 0,
                     "shading": 'gouraud',
                     "cmap": "plasma"}]

for i, (channel, stft, ylim) in enumerate((("Left", left_stft, l_ylim), ("Right", right_stft, r_ylim))):
    channel_stft_fig = apreset.stft_pcolormesh(t=t,
                                               f=f,
                                               Zxx=stft,
                                               title=f"{channel} Channel STFT Magnitude w/ {window} window\n"
                                                     f"winlen = {nperseg}, noverlap = {noverlap}",
                                               yscale="linear",
                                               ylim=ylim,
                                               colorbar_params={})
    fig_data[(0, i)] = channel_stft_fig

for i, tau in enumerate(taus):
    azi_line_options[0]["vmax"] = np.max(nulls[i])
    null_fig = FigData(xs=np.arange(beta + 1),
                       ys=f,
                       zs=nulls[i],
                       title=f"Freq-azi spectrogram (tau={'{:.2f}'.format(tau)}s)",
                       line_options=azi_line_options,
                       ylim=global_ylim,
                       **azi_fig_params)