Added some cmap functions.

Selected species-specific  colors.
Quite some progress on fig_invariance_thresh_lp_species.pdf.
This commit is contained in:
j-hartling
2026-03-26 17:26:30 +01:00
parent 1a29b95782
commit 92ee4eda6f
11 changed files with 737 additions and 132 deletions

View File

@@ -30,6 +30,7 @@ def plot_snippets(axes, time, snippets, ymin=None, ymax=None, **kwargs):
# GENERAL SETTINGS:
target = 'Omocestus_rufipes'
data_paths = search_files(target, excl='noise', dir='../data/inv/log_hp/')
species_paths = search_files('*', incl='noise', dir='../data/inv/log_hp/')
stages = ['env', 'log', 'inv']
load_kwargs = dict(
files=stages,
@@ -39,10 +40,6 @@ save_path = '../figures/fig_invariance_log_hp.pdf'
compute_ratios = True
show_diag = True
show_noise = True
if compute_ratios:
ref_data = load_data('../data/processed/white_noise_sd-1.npz', files=stages)[0]
ref_measures = {k: v.std() for k, v in ref_data.items() if not k.endswith('rate')}
# GRAPH SETTINGS:
fig_kwargs = dict(
@@ -221,6 +218,20 @@ noise_kwargs = dict(
zorder=1.5,
)
# PREPARATION:
if compute_ratios:
ref_data = load_data('../data/processed/white_noise_sd-1.npz', files=stages)[0]
ref_measures = {k: v.std() for k, v in ref_data.items() if not k.endswith('rate')}
species_measures = []
for species_path in species_paths:
species_data, _ = load_data(species_path, **load_kwargs)
species_measure = species_data['measure_inv']
if compute_ratios:
species_measure /= ref_measures['inv']
species_measures.append(species_measure)
species_measures = np.array(species_measures).T
# EXECUTION:
for data_path in data_paths:
print(f'Processing {data_path}')
@@ -340,6 +351,9 @@ for data_path in data_paths:
big_axes[1].plot(noise_scales, noise_data['measure_log'], c=colors['log'], lw=lw_big)
big_axes[1].plot(noise_scales, noise_data['measure_inv'], c=colors['inv'], lw=lw_big)
# Plot species measures:
big_axes[1].plot(noise_scales, species_measures, 'k', lw=lw_big, zorder=2.1)
if show_diag:
# Indicate diagonal:
big_axes[0].plot(pure_scales, pure_scales, **diag_kwargs)