plot traces and rises in spec
This commit is contained in:
parent
db0f6a4f7b
commit
580dcda2a5
@ -40,9 +40,11 @@ def load_data(folder):
|
||||
idx_v = np.load(base_path / 'idx_v.npy')
|
||||
times_v = np.load(base_path / 'times.npy')
|
||||
|
||||
fish_freq = np.load(base_path / 'analysis' / 'fish_freq.npy')
|
||||
rise_idx = np.load(base_path / 'analysis' / 'rise_idx.npy')
|
||||
|
||||
return fill_freqs, fill_times, fill_spec, EODf_v, ident_v, idx_v, times_v, rise_idx
|
||||
|
||||
return fill_freqs, fill_times, fill_spec, EODf_v, ident_v, idx_v, times_v, fish_freq, rise_idx
|
||||
|
||||
def save_spec_pic(folder, s_trans, times, freq, t_idx0, t_idx1, f_idx0, f_idx1, t_res, f_res):
|
||||
fig_title = (f'{Path(folder).name}__{t0:.0f}s-{t1:.0f}s__{f0:4.0f}-{f1:4.0f}Hz').replace(' ', '0')
|
||||
@ -59,8 +61,6 @@ def save_spec_pic(folder, s_trans, times, freq, t_idx0, t_idx1, f_idx0, f_idx1,
|
||||
|
||||
|
||||
def main(args):
|
||||
|
||||
|
||||
min_freq = 200
|
||||
max_freq = 1500
|
||||
d_freq = 200
|
||||
@ -68,7 +68,7 @@ def main(args):
|
||||
d_time = 60*15
|
||||
time_overlap = 60*5
|
||||
|
||||
freq, times, spec, EODf_v, ident_v, idx_v, times_v, rise_idx = load_data(args.folder)
|
||||
freq, times, spec, EODf_v, ident_v, idx_v, times_v, fish_freq, rise_idx = load_data(args.folder)
|
||||
f_res, t_res = freq[1] - freq[0], times[1] - times[0]
|
||||
|
||||
unique_ids = np.unique(ident_v[~np.isnan(ident_v)])
|
||||
@ -102,20 +102,26 @@ def main(args):
|
||||
|
||||
if not args.dev:
|
||||
save_spec_pic(args.folder, s_trans, times, freq, t_idx0, t_idx1, f_idx0, f_idx1, t_res, f_res)
|
||||
exit()
|
||||
|
||||
else:
|
||||
fig_title = (f'{Path(args.folder).name}__{t0:.0f}s-{t1:.0f}s__{f0:4.0f}-{f1:4.0f}Hz').replace(' ', '0')
|
||||
fig = plt.figure(figsize=(7, 7), num=fig_title)
|
||||
gs = gridspec.GridSpec(1, 2, width_ratios=(8, 1), wspace=0) # , bottom=0, left=0, right=1, top=1
|
||||
fig = plt.figure(figsize=(10, 7), num=fig_title)
|
||||
gs = gridspec.GridSpec(1, 2, width_ratios=(8, 1), wspace=0, left=0.1, bottom=0.1, right=0.9, top=0.95) # , bottom=0, left=0, right=1, top=1
|
||||
ax = fig.add_subplot(gs[0, 0])
|
||||
cax = fig.add_subplot(gs[0, 1])
|
||||
im = ax.imshow(s_trans.squeeze(), cmap='gray', aspect='auto', origin='lower',
|
||||
extent=(times[t_idx0] / 3600, times[t_idx1] / 3600 + t_res, freq[f_idx0], freq[f_idx1] + f_res))
|
||||
|
||||
extent=(times[t_idx0], times[t_idx1] + t_res, freq[f_idx0], freq[f_idx1] + f_res))
|
||||
fig.colorbar(im, cax=cax, orientation='vertical')
|
||||
|
||||
|
||||
times_v_idx0, times_v_idx1 = np.argmin(np.abs(times_v - t0)), np.argmin(np.abs(times_v - t1))
|
||||
for id_idx in range(len(fish_freq)):
|
||||
ax.plot(times_v[times_v_idx0:times_v_idx1], fish_freq[id_idx][times_v_idx0:times_v_idx1], marker='.', color='k')
|
||||
rise_idx_oi = rise_idx[id_idx][(rise_idx[id_idx] >= times_v_idx0) & (rise_idx[id_idx] <= times_v_idx1)]
|
||||
ax.plot(times_v[rise_idx_oi], fish_freq[id_idx][rise_idx_oi], marker='o', color='tab:red')
|
||||
|
||||
plt.show()
|
||||
|
||||
# # ax.imshow(spec[f0:f1, t0:t1], cmap='gray')
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Evaluated electrode array recordings with multiple fish.')
|
||||
|
Loading…
Reference in New Issue
Block a user