Holiday syncing :)
This commit is contained in:
@@ -5,6 +5,7 @@ from itertools import product
|
||||
from thunderhopper.filetools import search_files
|
||||
from thunderhopper.modeltools import load_data
|
||||
from thunderhopper.filtertools import find_kern_specs
|
||||
from misc_functions import get_saturation
|
||||
from color_functions import load_colors, shade_colors
|
||||
from plot_functions import shift_subplot, hide_axis, ylimits, xlabel, ylabel,\
|
||||
super_ylabel, plot_line, plot_barcode, strip_zeros,\
|
||||
@@ -64,7 +65,7 @@ load_kwargs = dict(
|
||||
files=stages,
|
||||
keywords=['scales', 'snip', 'measure', 'thresh']
|
||||
)
|
||||
save_path = '../figures/fig_invariance_thresh_lp_single.pdf'
|
||||
save_path = None#'../figures/fig_invariance_thresh_lp_single.pdf'
|
||||
exclude_zero = True
|
||||
|
||||
# GRAPH SETTINGS:
|
||||
@@ -79,7 +80,7 @@ super_grid_kwargs = dict(
|
||||
left=0,
|
||||
right=1,
|
||||
bottom=0,
|
||||
top=1
|
||||
top=1,
|
||||
)
|
||||
input_rows = 1
|
||||
snip_rows = 2
|
||||
@@ -111,10 +112,10 @@ input_grid_kwargs = dict(
|
||||
top=0.75,
|
||||
)
|
||||
big_grid_kwargs = dict(
|
||||
nrows=1,
|
||||
nrows=2,
|
||||
ncols=1,
|
||||
wspace=0,
|
||||
hspace=0,
|
||||
hspace=0.3,
|
||||
left=0.17,
|
||||
right=0.96,
|
||||
bottom=0.1,
|
||||
@@ -141,7 +142,8 @@ lw = dict(
|
||||
big=4,
|
||||
)
|
||||
xlabels = dict(
|
||||
big='scale $\\alpha$',
|
||||
alpha='scale $\\alpha$',
|
||||
sigma='$\\sigma_{\\text{adapt}}$',
|
||||
)
|
||||
ylabels = dict(
|
||||
inv='$x_{\\text{adapt}}$',
|
||||
@@ -150,11 +152,17 @@ ylabels = dict(
|
||||
feat='$f_i$',
|
||||
big='$\\mu_f$',
|
||||
)
|
||||
xlab_big_kwargs = dict(
|
||||
y=0,
|
||||
xlab_alpha_kwargs = dict(
|
||||
y=-0.15,
|
||||
fontsize=fs['lab_norm'],
|
||||
ha='center',
|
||||
va='bottom',
|
||||
va='top',
|
||||
)
|
||||
xlab_sigma_kwargs = dict(
|
||||
y=-0.12,
|
||||
fontsize=fs['lab_tex'],
|
||||
ha=xlab_alpha_kwargs['ha'],
|
||||
va=xlab_alpha_kwargs['va'],
|
||||
)
|
||||
ylab_snip_kwargs = dict(
|
||||
x=0.08,
|
||||
@@ -178,7 +186,7 @@ ylab_big_kwargs = dict(
|
||||
ypad = dict(
|
||||
inv=0.05,
|
||||
conv=0.05,
|
||||
big=0.075
|
||||
big=0.1
|
||||
)
|
||||
yloc = dict(
|
||||
inv=(2, 200),
|
||||
@@ -242,6 +250,13 @@ leg_kwargs = dict(
|
||||
handlelength=1.5,
|
||||
columnspacing=1,
|
||||
)
|
||||
plateau_settings = dict(
|
||||
low=0.05,
|
||||
high=0.95,
|
||||
first=True,
|
||||
last=True,
|
||||
condense=None,
|
||||
)
|
||||
kern_specs = np.array([
|
||||
[1, 0.008],
|
||||
[2, 0.004],
|
||||
@@ -281,6 +296,7 @@ for data_path in data_paths:
|
||||
# Reduce to nonzero scales:
|
||||
nonzero_inds = scales > 0
|
||||
scales = scales[nonzero_inds]
|
||||
noise_data['measure_inv'] = noise_data['measure_inv'][nonzero_inds]
|
||||
noise_data['measure_feat'] = noise_data['measure_feat'][nonzero_inds, :]
|
||||
pure_data['measure_feat'] = pure_data['measure_feat'][nonzero_inds, :]
|
||||
|
||||
@@ -293,7 +309,7 @@ for data_path in data_paths:
|
||||
)
|
||||
|
||||
# Adjust grid parameters to loaded data:
|
||||
super_grid_kwargs['nrows'] = snip_rows * thresh_rel.size + 1
|
||||
super_grid_kwargs['nrows'] = snip_rows * thresh_rel.size + input_rows
|
||||
input_grid_kwargs['ncols'] = plot_scales.size
|
||||
snip_grid_kwargs['ncols'] = plot_scales.size
|
||||
|
||||
@@ -325,8 +341,6 @@ for data_path in data_paths:
|
||||
ax1.yaxis.set_major_locator(plt.MultipleLocator(yloc[stage][0]))
|
||||
ax2.yaxis.set_major_locator(plt.MultipleLocator(yloc[stage][1]))
|
||||
ylabel(ax1, ylabels[stage], transform=snip_subfig.transSubfigure, **ylab_snip_kwargs)
|
||||
# for ax, scale in zip(axes[0, :], plot_scales):
|
||||
# title_subplot(ax, f'$\\alpha={strip_zeros(scale)}$', ref=snip_subfig, **title_kwargs)
|
||||
if i == thresh_rel.size - 1:
|
||||
axes[-1, -1].set_xlim(t_full[0], t_full[-1])
|
||||
time_bar(axes[-1, -1], **bar_kwargs)
|
||||
@@ -334,17 +348,27 @@ for data_path in data_paths:
|
||||
snip_axes.append(axes)
|
||||
letter_subplots(snip_subfigs, 'bcd', **letter_snip_kwargs)
|
||||
|
||||
# Prepare analysis axis:
|
||||
# Prepare analysis axes:
|
||||
big_subfig = fig.add_subfigure(super_grid[subfig_specs['big']])
|
||||
big_grid = big_subfig.add_gridspec(**big_grid_kwargs)
|
||||
big_ax = big_subfig.add_subplot(big_grid[0, 0])
|
||||
big_ax.set_xlim(scales[0], scales[-1])
|
||||
big_ax.set_xscale('symlog', linthresh=scales[scales > 0][0], linscale=0.5)
|
||||
ylimits(noise_data['measure_feat'], big_ax, minval=0, pad=ypad['big'])
|
||||
big_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
xlabel(big_ax, xlabels['big'], transform=big_subfig.transSubfigure, **xlab_big_kwargs)
|
||||
ylabel(big_ax, ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
letter_subplot(big_subfig, 'e', **letter_big_kwargs, ref=input_subfig)
|
||||
|
||||
alpha_ax = big_subfig.add_subplot(big_grid[0, 0])
|
||||
alpha_ax.set_xlim(scales[0], scales[-1])
|
||||
alpha_ax.set_xscale('symlog', linthresh=scales[scales > 0][0], linscale=0.5)
|
||||
ylimits(pure_data['measure_feat'], alpha_ax, minval=0, pad=ypad['big'])
|
||||
alpha_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
xlabel(alpha_ax, xlabels['alpha'], **xlab_alpha_kwargs)
|
||||
ylabel(alpha_ax, ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
|
||||
sigma_ax = big_subfig.add_subplot(big_grid[1, 0])
|
||||
sigma_ax.set_xlim(noise_data['measure_inv'].min(), noise_data['measure_inv'].max())
|
||||
# sigma_ax.set_xscale('log')
|
||||
sigma_ax.set_xlim(scales[0], scales[-1])
|
||||
sigma_ax.set_xscale('symlog', linthresh=scales[scales > 0][0], linscale=0.5)
|
||||
ylimits(pure_data['measure_feat'], sigma_ax, minval=0, pad=ypad['big'])
|
||||
sigma_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
xlabel(sigma_ax, xlabels['sigma'], **xlab_sigma_kwargs)
|
||||
ylabel(sigma_ax, ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
|
||||
# Plot intensity-adapted snippets:
|
||||
plot_snippets(input_axes, t_full, noise_data['snip_inv'],
|
||||
@@ -375,18 +399,25 @@ for data_path in data_paths:
|
||||
ymin=0, ymax=1, c=shaded['feat'][i], lw=lw['feat'])
|
||||
[set_clip_box(h[0], ax, bounds=[[0, -0.05], [1, 1.05]]) for h, ax in zip(handles, axes[2, :])]
|
||||
|
||||
# Plot pure-song analysis results:
|
||||
handles = big_ax.plot(scales, pure_data['measure_feat'], lw=lw['big'], ls='dotted')
|
||||
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
|
||||
# Get threshold-specific saturation:
|
||||
for i in range(thresh_rel.size):
|
||||
ind = get_saturation(noise_data['measure_feat'][:, i], **plateau_settings)[1]
|
||||
|
||||
# Plot noise-song analysis results:
|
||||
handles = big_ax.plot(scales, noise_data['measure_feat'], lw=lw['big'])
|
||||
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
|
||||
# Plot analysis results:
|
||||
for ax, x in zip([alpha_ax, sigma_ax], [scales, noise_data['measure_inv']]):
|
||||
# Plot pure-song analysis results:
|
||||
handles = ax.plot(x, pure_data['measure_feat'], lw=lw['big'], ls='dotted')
|
||||
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
|
||||
|
||||
# Add proxy legend:
|
||||
h1 = big_ax.plot([], [], c='k', lw=lw['big'], label='$\\alpha\\cdot s(t) + \\eta(t)$')[0]
|
||||
h2 = big_ax.plot([], [], c='k', lw=lw['big'], ls='dotted', label='$\\alpha\\cdot s(t)$')[0]
|
||||
big_ax.legend(handles=[h1, h2], **leg_kwargs)
|
||||
# Plot noise-song analysis results:
|
||||
handles = ax.plot(x, noise_data['measure_feat'], lw=lw['big'])
|
||||
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
|
||||
|
||||
# Add proxy legend:
|
||||
if ax == alpha_ax:
|
||||
h1 = ax.plot([], [], c='k', lw=lw['big'], label='$\\alpha\\cdot s(t) + \\eta(t)$')[0]
|
||||
h2 = ax.plot([], [], c='k', lw=lw['big'], ls='dotted', label='$\\alpha\\cdot s(t)$')[0]
|
||||
ax.legend(handles=[h1, h2], **leg_kwargs)
|
||||
|
||||
if save_path is not None:
|
||||
fig.savefig(save_path)
|
||||
|
||||
Reference in New Issue
Block a user