Syncing to home.

This commit is contained in:
j-hartling
2026-05-05 18:19:09 +02:00
parent 05e808ba30
commit a48457d967
9 changed files with 189 additions and 151 deletions

View File

@@ -266,6 +266,12 @@ leg_kwargs = dict(
handlelength=1.5,
columnspacing=1,
)
cap_kwargs = dict(
color='k',
alpha=0.5,
lw=0,
zorder=5,
)
plateau_settings = dict(
low=0.05,
high=0.95,
@@ -293,6 +299,12 @@ kern_specs = np.array([
[3, 0.002],
])[np.array([1])]
# PREPARATION:
# Get saturation level of invariant envelope from log-hp analysis:
inv_path = search_files(example_file, dir='../data/inv/log_hp/')[0]
sigma_cap = load_data(inv_path, files='measure_inv')[0]['measure_inv'][-1]
# EXECUTION:
print(f'Processing {data_path}')
@@ -444,31 +456,45 @@ for i in range(thresh_rel.size):
ind = get_saturation(noise_data['measure_feat'][:, i], **plateau_settings)[1]
saturation_inds.append(ind)
# 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'])]
# Plot pure-song analysis results over alpha:
handles = alpha_ax.plot(scales, pure_data['measure_feat'], lw=lw['big'], ls='dotted')
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
# 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'])]
# Plot noise-song analysis results over alpha:
handles = alpha_ax.plot(scales, noise_data['measure_feat'], lw=lw['big'])
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
# Indicate threshold-specific saturation:
for i, ind in enumerate(saturation_inds):
color = shaded['feat'][i]
ax.plot(x[ind], 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
transform=ax.get_xaxis_transform())
ax.plot(x[ind], 0, mfc=color, mec='k', alpha=0.75, zorder=6,
**plateau_dot_kwargs, transform=ax.get_xaxis_transform())
ax.vlines(x[ind], ax.get_ylim()[0], noise_data['measure_feat'][ind, i],
color=color, **plateau_line_kwargs)
# Indicate threshold-specific saturation:
for i, ind in enumerate(saturation_inds):
color = shaded['feat'][i]
alpha_ax.plot(scales[ind], 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
transform=alpha_ax.get_xaxis_transform())
alpha_ax.plot(scales[ind], 0, mfc=color, mec='k', alpha=0.75, zorder=6,
**plateau_dot_kwargs, transform=alpha_ax.get_xaxis_transform())
alpha_ax.vlines(scales[ind], alpha_ax.get_ylim()[0], noise_data['measure_feat'][ind, i],
color=color, **plateau_line_kwargs)
# 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)
# Add proxy legend:
h1 = alpha_ax.plot([], [], c='k', lw=lw['big'], label='$\\alpha\\cdot s(t) + \\eta(t)$')[0]
h2 = alpha_ax.plot([], [], c='k', lw=lw['big'], ls='dotted', label='$\\alpha\\cdot s(t)$')[0]
alpha_ax.legend(handles=[h1, h2], **leg_kwargs)
# Plot noise-song analysis results over sigma:
handles = sigma_ax.plot(noise_data['measure_inv'], noise_data['measure_feat'], lw=lw['big'])
[h.set_color(c) for h, c in zip(handles, shaded['feat'])]
# Indicate threshold-specific saturation:
for i, ind in enumerate(saturation_inds):
color = shaded['feat'][i]
sigma_ax.plot(scales[ind], 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
transform=sigma_ax.get_xaxis_transform())
sigma_ax.plot(scales[ind], 0, mfc=color, mec='k', alpha=0.75, zorder=6,
**plateau_dot_kwargs, transform=sigma_ax.get_xaxis_transform())
sigma_ax.vlines(scales[ind], sigma_ax.get_ylim()[0], noise_data['measure_feat'][ind, i],
color=color, **plateau_line_kwargs)
# Indicate sigma range capped by log-hp mechanism:
sigma_ax.axvspan(sigma_cap, sigma_ax.get_xlim()[1], **cap_kwargs)
if save_path is not None:
fig.savefig(save_path)