improved introplot
This commit is contained in:
parent
677c29b77f
commit
a7a3b26883
@ -1 +1 @@
|
||||
chirpdetection
|
||||
chirpdet
|
||||
|
@ -17,9 +17,9 @@ def main():
|
||||
data = LoadData(datapath)
|
||||
|
||||
# good chirp times for data: 2022-06-02-10_00
|
||||
window_start_seconds = 3 * 60 * 60 + 6 * 60 + 43.5 + 9 + 6.24
|
||||
window_start_seconds = 3 * 60 * 60 + 6 * 60 + 43.5 + 9 + 6.20
|
||||
window_start_index = window_start_seconds * data.raw_rate
|
||||
window_duration_seconds = 0.2
|
||||
window_duration_seconds = 0.4
|
||||
window_duration_index = window_duration_seconds * data.raw_rate
|
||||
|
||||
timescaler = 1000
|
||||
@ -27,8 +27,8 @@ def main():
|
||||
raw = data.raw[window_start_index:window_start_index +
|
||||
window_duration_index, 10]
|
||||
|
||||
fig, ax = plt.subplots(
|
||||
1, 1, figsize=(14 * ps.cm, 6*ps.cm), sharex=True, sharey=True)
|
||||
fig, (ax1, ax2) = plt.subplots(
|
||||
1, 2, figsize=(21 * ps.cm, 8*ps.cm), sharex=True, sharey=True)
|
||||
|
||||
# plot instantaneous frequency
|
||||
filtered1 = bandpass_filter(
|
||||
@ -41,12 +41,9 @@ def main():
|
||||
freqtime2, freq2 = instantaneous_frequency(
|
||||
filtered2, data.raw_rate, smoothing_window=3)
|
||||
|
||||
ax.plot(freqtime1*timescaler, freq1, color=ps.g,
|
||||
lw=2, label="Fish 1")
|
||||
ax.plot(freqtime2*timescaler, freq2, color=ps.gray,
|
||||
ax1.plot(freqtime1*timescaler, freq1, color=ps.g, lw=2, label="Fish 1")
|
||||
ax1.plot(freqtime2*timescaler, freq2, color=ps.gray,
|
||||
lw=2, label="Fish 2")
|
||||
ax.legend(bbox_to_anchor=(0, 1.02, 1, 0.2), loc="lower center",
|
||||
mode="normal", borderaxespad=0, ncol=2)
|
||||
# ax.legend(bbox_to_anchor=(1.04, 1), borderaxespad=0)
|
||||
# # ps.hide_xax(ax1)
|
||||
|
||||
@ -62,7 +59,7 @@ def main():
|
||||
fmask = np.zeros(spec_freqs.shape, dtype=bool)
|
||||
fmask[(spec_freqs > ylims[0]) & (spec_freqs < ylims[1])] = True
|
||||
|
||||
ax.imshow(
|
||||
ax1.imshow(
|
||||
decibel(spec_power[fmask, :]),
|
||||
extent=[
|
||||
spec_times[0]*timescaler,
|
||||
@ -77,47 +74,49 @@ def main():
|
||||
# vmin=-100,
|
||||
# vmax=-80,
|
||||
)
|
||||
# ps.hide_xax(ax2)
|
||||
|
||||
# # plot coarse spectrogram
|
||||
# spec_power, spec_freqs, spec_times = spectrogram(
|
||||
# raw,
|
||||
# ratetime=data.raw_rate,
|
||||
# freq_resolution=10,
|
||||
# overlap_frac=0.3,
|
||||
# )
|
||||
# fmask = np.zeros(spec_freqs.shape, dtype=bool)
|
||||
# fmask[(spec_freqs > ylims[0]) & (spec_freqs < ylims[1])] = True
|
||||
# ax3.imshow(
|
||||
# decibel(spec_power[fmask, :]),
|
||||
# extent=[
|
||||
# spec_times[0]*timescaler,
|
||||
# spec_times[-1]*timescaler,
|
||||
# spec_freqs[fmask][0],
|
||||
# spec_freqs[fmask][-1],
|
||||
# ],
|
||||
# aspect="auto",
|
||||
# origin="lower",
|
||||
# interpolation="gaussian",
|
||||
# alpha=1,
|
||||
# )
|
||||
# # ps.hide_xax(ax3)
|
||||
|
||||
ax.set_xlabel("Time [ms]")
|
||||
ax.set_ylabel("Frequency [Hz]")
|
||||
|
||||
# ax.set_yticks(np.arange(400, 1201, 400))
|
||||
# ax.spines.left.set_bounds((400, 1200))
|
||||
# ax2.set_yticks(np.arange(400, 1201, 400))
|
||||
# ax2.spines.left.set_bounds((400, 1200))
|
||||
# ax3.set_yticks(np.arange(400, 1201, 400))
|
||||
# ax3.spines.left.set_bounds((400, 1200))
|
||||
|
||||
plt.subplots_adjust(left=0.17, right=0.98, top=0.87,
|
||||
bottom=0.24, hspace=0.35)
|
||||
spec_power, spec_freqs, spec_times = spectrogram(
|
||||
raw,
|
||||
ratetime=data.raw_rate,
|
||||
freq_resolution=15,
|
||||
overlap_frac=0.3,
|
||||
)
|
||||
fmask = np.zeros(spec_freqs.shape, dtype=bool)
|
||||
fmask[(spec_freqs > ylims[0]) & (spec_freqs < ylims[1])] = True
|
||||
ax2.imshow(
|
||||
decibel(spec_power[fmask, :]),
|
||||
extent=[
|
||||
spec_times[0]*timescaler,
|
||||
spec_times[-1]*timescaler,
|
||||
spec_freqs[fmask][0],
|
||||
spec_freqs[fmask][-1],
|
||||
],
|
||||
aspect="auto",
|
||||
origin="lower",
|
||||
interpolation="gaussian",
|
||||
alpha=1,
|
||||
)
|
||||
# ps.hide_xax(ax3)
|
||||
ax2.plot(freqtime1*timescaler, freq1, color=ps.g, lw=2, label="_")
|
||||
ax2.plot(freqtime2*timescaler, freq2, color=ps.gray,
|
||||
lw=2, label="_")
|
||||
|
||||
ax2.set_xlim(75, 200)
|
||||
ax1.set_ylim(400, 1200)
|
||||
|
||||
fig.supxlabel("Time [ms]", fontsize=14)
|
||||
fig.supylabel("Frequency [Hz]", fontsize=14)
|
||||
|
||||
handles, labels = ax1.get_legend_handles_labels()
|
||||
ax2.legend(handles, labels, bbox_to_anchor=(1.04, 1), loc="upper left", ncol=1,)
|
||||
|
||||
ps.letter_subplots(xoffset=[-0.27, -0.1], yoffset=1.05)
|
||||
|
||||
plt.subplots_adjust(left=0.12, right=0.85, top=0.89,
|
||||
bottom=0.18, hspace=0.35)
|
||||
|
||||
plt.savefig('../poster/figs/introplot.pdf')
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user