Seriously, no idea. Wild amount of changes. Good luck.
This commit is contained in:
@@ -162,20 +162,30 @@ def add_cross_axes(fig, n, long='col', fill='row', **grid_kwargs):
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target_species = [
|
||||
'Omocestus_rufipes',
|
||||
'Chorthippus_biguttulus',
|
||||
'Chorthippus_mollis',
|
||||
'Chrysochraon_dispar',
|
||||
'Euchorthippus_declivus',
|
||||
'Gomphocerippus_rufus',
|
||||
'Omocestus_rufipes',
|
||||
'Pseudochorthippus_parallelus',
|
||||
]
|
||||
]
|
||||
example_files = {
|
||||
'Chorthippus_biguttulus': 'Chorthippus_biguttulus_GBC_94-17s73.1ms-19s977ms',
|
||||
'Chorthippus_mollis': 'Chorthippus_mollis_DJN_41_T28C-46s4.58ms-1m15s697ms',
|
||||
'Chrysochraon_dispar': 'Chrysochraon_dispar_DJN_26_T28C_DT-32s134ms-34s432ms',
|
||||
'Euchorthippus_declivus': 'Euchorthippus_declivus_FTN_79-2s167ms-2s563ms',
|
||||
'Gomphocerippus_rufus': 'Gomphocerippus_rufus_FTN_91-3-884ms-10s427ms',
|
||||
'Omocestus_rufipes': 'Omocestus_rufipes_DJN_32-40s724ms-48s779ms',
|
||||
'Pseudochorthippus_parallelus': 'Pseudochorthippus_parallelus_GBC_88-6s678ms-9s32.3ms'
|
||||
}
|
||||
n_species = len(target_species)
|
||||
load_kwargs = dict(
|
||||
keywords=['scales', 'measure', 'thresh']
|
||||
keywords=['scales', 'mean', 'thresh']
|
||||
)
|
||||
save_path = '../figures/fig_invariance_thresh_lp_species.pdf'
|
||||
exclude_zero = True
|
||||
show_floor = True
|
||||
show_floor = False
|
||||
|
||||
# SUBSET SETTINGS:
|
||||
thresh_rel = np.array([0.5, 1, 3])[0]
|
||||
@@ -266,14 +276,6 @@ lw = dict(
|
||||
kern=2.5,
|
||||
plateau=3,
|
||||
)
|
||||
zorder = dict(
|
||||
Omocestus_rufipes=2,
|
||||
Chorthippus_biguttulus=2.5,
|
||||
Chorthippus_mollis=2.4,
|
||||
Chrysochraon_dispar=2,
|
||||
Gomphocerippus_rufus=2,
|
||||
Pseudochorthippus_parallelus=2,
|
||||
)
|
||||
space_kwargs = dict(
|
||||
s=30,
|
||||
)
|
||||
@@ -357,21 +359,27 @@ letter_space_kwargs = dict(
|
||||
va='center',
|
||||
fontsize=fs['letter'],
|
||||
)
|
||||
song_bar_time = 1.0
|
||||
spec_bar_times = dict(
|
||||
Chorthippus_biguttulus=1,
|
||||
Chorthippus_mollis=10,
|
||||
Chrysochraon_dispar=1,
|
||||
Euchorthippus_declivus=0.25,
|
||||
Gomphocerippus_rufus=5,
|
||||
Omocestus_rufipes=5,
|
||||
Pseudochorthippus_parallelus=1,
|
||||
)
|
||||
song_bar_kwargs = dict(
|
||||
dur=song_bar_time,
|
||||
y0=-0.1,
|
||||
y1=0,
|
||||
xshift=0,
|
||||
xshift=0.5,
|
||||
color='k',
|
||||
lw=0,
|
||||
clip_on=False,
|
||||
text_pos=(1.25, 0.5),
|
||||
text_str=f'${int(song_bar_time)}\\,\\text{{s}}$',
|
||||
text_pos=(0.5, -0.1),
|
||||
text_kwargs=dict(
|
||||
fontsize=fs['bar'],
|
||||
ha='left',
|
||||
va='center',
|
||||
ha='center',
|
||||
va='top',
|
||||
)
|
||||
)
|
||||
kern_bar_time = 0.05
|
||||
@@ -382,7 +390,7 @@ kern_bar_kwargs = dict(
|
||||
color='k',
|
||||
lw=0,
|
||||
clip_on=False,
|
||||
text_pos=(0.6, -1),
|
||||
text_pos=(0.7, -1),
|
||||
text_str=f'${int(kern_bar_time * 1000)}\\,\\text{{ms}}$',
|
||||
text_kwargs=dict(
|
||||
fontsize=fs['bar'],
|
||||
@@ -502,7 +510,7 @@ for i, species in enumerate(target_species):
|
||||
print(f'Processing {species}')
|
||||
|
||||
# Fetch species-specific recording file:
|
||||
song_path = search_files(species, dir='../data/processed/')[0]
|
||||
song_path = search_files(example_files[species], dir='../data/processed/')[0]
|
||||
|
||||
# Load song data:
|
||||
song_data, _ = load_data(song_path, files='filt')
|
||||
@@ -513,16 +521,18 @@ for i, species in enumerate(target_species):
|
||||
time = np.arange(song.shape[0]) / rate
|
||||
plot_line(song_ax, time, song, ypad=0.05, c='k', lw=lw['song'])
|
||||
title_subplot(song_ax, shorten_species(species), ref=song_subfig, **title_kwargs)
|
||||
time_bar(song_ax, **song_bar_kwargs)
|
||||
song_bar_kwargs['text_pos'] = None
|
||||
time_bar(song_ax, dur=spec_bar_times[species], **song_bar_kwargs,
|
||||
text_str=f'${spec_bar_times[species]}\\,\\text{{s}}$')
|
||||
|
||||
# Fetch species-specific invariance files:
|
||||
pure_path = search_files(species, incl='pure', dir='../data/inv/thresh_lp/')[0]
|
||||
noise_path = search_files(species, incl='noise', dir='../data/inv/thresh_lp/')[0]
|
||||
pure_path = search_files(species, incl='pure', dir='../data/inv/thresh_lp/condensed/')[0]
|
||||
noise_path = search_files(species, incl='noise', dir='../data/inv/thresh_lp/condensed/')[0]
|
||||
|
||||
# Load invariance data:
|
||||
pure_data, config = load_data(pure_path, **load_kwargs)
|
||||
noise_data, _ = load_data(noise_path, **load_kwargs)
|
||||
pure_measure = pure_data['mean_feat'].mean(axis=-1)
|
||||
noise_measure = noise_data['mean_feat'].mean(axis=-1)
|
||||
scales = pure_data['scales']
|
||||
|
||||
# Reduce to kernel subset and a single threshold:
|
||||
@@ -530,8 +540,8 @@ for i, species in enumerate(target_species):
|
||||
kern_inds = find_kern_specs(config['k_specs'], kerns=kern_specs)
|
||||
config['k_specs'] = config['k_specs'][kern_inds]
|
||||
config['kernels'] = config['kernels'][:, kern_inds]
|
||||
pure_measure = pure_data['measure_feat'][:, kern_inds, thresh_ind]
|
||||
noise_measure = noise_data['measure_feat'][:, kern_inds, thresh_ind]
|
||||
pure_measure = pure_measure[:, kern_inds, thresh_ind]
|
||||
noise_measure = noise_measure[:, kern_inds, thresh_ind]
|
||||
if exclude_zero:
|
||||
# Reduce to nonzero scales:
|
||||
nonzero_inds = scales > 0
|
||||
@@ -564,7 +574,6 @@ for i, species in enumerate(target_species):
|
||||
inset.plot(config['k_times'], kern, c=c, lw=lw['kern'])
|
||||
inset.set_xlim(xlims)
|
||||
inset.set_ylim(ylims)
|
||||
# time_bar(insets[0], parent=feat_axes[0, 0], **kern_bar_kwargs)
|
||||
time_bar(insets[0], **kern_bar_kwargs)
|
||||
|
||||
# Plot invariance curves in feature space:
|
||||
@@ -572,13 +581,11 @@ for i, species in enumerate(target_species):
|
||||
for ind, (pure_ax, noise_ax) in enumerate(zip(pure_axes, noise_axes)):
|
||||
irow, icol = row_inds[ind], col_inds[ind]
|
||||
pure_handle = pure_ax.scatter(pure_measure[:, icol], pure_measure[:, irow],
|
||||
c=scales, cmap=scale_cmap, norm=norm,
|
||||
zorder=zorder[species], **space_kwargs)
|
||||
c=scales, cmap=scale_cmap, norm=norm, **space_kwargs)
|
||||
pure_space_handles[pure_ax].append(pure_handle)
|
||||
|
||||
noise_handle = noise_ax.scatter(noise_measure[:, icol], noise_measure[:, irow],
|
||||
c=scales, cmap=scale_cmap, norm=norm,
|
||||
zorder=zorder[species], **space_kwargs)
|
||||
c=scales, cmap=scale_cmap, norm=norm, **space_kwargs)
|
||||
noise_space_handles[noise_ax].append(noise_handle)
|
||||
|
||||
# Indicate scale color code in pure subfigure:
|
||||
|
||||
Reference in New Issue
Block a user