LANL-Seismoacoustics / infrapy

An infrasound array processing toolkit
Other
39 stars 7 forks source link

Plot beam on Infraview Beamforming table instead of selected waveform #7

Open fkdannemann opened 4 years ago

fkdannemann commented 4 years ago

@jwebster-LANL it would help with picking to plot the beamed signal in the beamforming tab instead of just a selected trace. The bottom section of /examples/test_beamforming highlights how to pull out the beam and residual, and plot.

    back_az = beam_results[np.argmax(beam_results[:, 2]), 0]
    tr_vel = beam_results[np.argmax(beam_results[:, 2]), 1]

    X, S, f = beamforming_new.fft_array_data(x, t, window=[sig_start, sig_end], fft_window="boxcar")
    sig_est, residual = beamforming_new.extract_signal(X, f, np.array([back_az, tr_vel]), geom)

    plt.figure(3)
    plt.loglog(f, abs(sig_est), '-b', linewidth=1.0)
    plt.loglog(f, np.mean(abs(residual), axis=0), '-k', linewidth=0.5)

    signal_wvfrm = np.fft.irfft(sig_est) / (t[1] - t[0])
    resid_wvfrms = np.fft.irfft(residual, axis=1) / (t[1] - t[0])
    t_mask = np.logical_and(sig_start < t, t < sig_end)

    plt.figure(4)
    for m in range(M):
        plt.subplot(M + 1, 1, m + 1)
        plt.xlim([t[t_mask][0], t[t_mask][-1]])
        plt.plot(t[t_mask], x[m, t_mask], '0.5')
        plt.plot(t[t_mask], resid_wvfrms[m, :len(t[t_mask])], 'k-')
        plt.setp(plt.subplot(M + 1, 1, m + 1).get_xticklabels(), visible=False)
    plt.subplot(M + 1, 1, M + 1)
    plt.xlim([t[t_mask][0], t[t_mask][-1]])
    plt.plot(t[t_mask], signal_wvfrm[:len(t[t_mask])], 'b-')
jwebster-LANL commented 4 years ago

so after the beamformer runs, replace the trace with the beamed signal? Would it be useful to plot both the trace and the beamed signal? maybe be able to toggle back and forth?

in the code above, is it signal_wvfrm you want? Or resid_wvfrms?

fkdannemann commented 4 years ago

Yeah I was just thinking about this, and maybe a toggle between the trace and beam would be best. Or an option 'plot beam' or 'plot trace'? Some people may not need the additional beam step.

signal_wvfrm is what should be plotted. But actually it may be helpful to also have an option to plot both signal_wvfrm and resid_wvfrm (in different colors)