Overhauled Thresh-LP analysis and figures (WIP).
This commit is contained in:
@@ -1,31 +1,14 @@
|
||||
import plotstyle_plt
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.transforms import BboxTransformTo
|
||||
from itertools import product
|
||||
from thunderhopper.filetools import search_files
|
||||
from thunderhopper.modeltools import load_data
|
||||
from color_functions import load_colors
|
||||
from plot_functions import hide_axis, ylimits, xlabel, ylabel, plot_line, strip_zeros
|
||||
from plot_functions import hide_axis, ylimits, xlabel, ylabel,\
|
||||
plot_line, strip_zeros, time_bar
|
||||
from IPython import embed
|
||||
|
||||
def time_bar(ax, dur, y0=0.9, y1=0.95, xshift=0.5, parent=None, transform=None, **kwargs):
|
||||
t0, t1 = ax.get_xlim()
|
||||
offset = (t1 - t0 - dur) * xshift
|
||||
x0 = t0 + offset
|
||||
x1 = x0 + dur
|
||||
if parent is None:
|
||||
parent = ax
|
||||
if transform is None:
|
||||
transform = BboxTransformTo(parent.bbox)
|
||||
if transform is not ax.transData:
|
||||
trans = ax.transData + transform.inverted()
|
||||
x0 = trans.transform((x0, 0))[0]
|
||||
x1 = trans.transform((x1, 0))[0]
|
||||
parent.add_artist(plt.Rectangle((x0, y0), x1 - x0, y1 - y0,
|
||||
transform=transform, **kwargs))
|
||||
return None
|
||||
|
||||
def add_snip_axes(fig, grid_kwargs):
|
||||
grid = fig.add_gridspec(**grid_kwargs)
|
||||
axes = np.zeros((grid.nrows, grid.ncols), dtype=object)
|
||||
@@ -46,8 +29,10 @@ def plot_snippets(axes, time, snippets, ymin=None, ymax=None, **kwargs):
|
||||
target = 'Omocestus_rufipes'
|
||||
data_paths = search_files(target, excl='noise', dir='../data/inv/log_hp/')
|
||||
stages = ['env', 'log', 'inv']
|
||||
files = stages + ['scales', 'example_scales', 'limit',
|
||||
'measure_env', 'measure_log', 'measure_inv']
|
||||
load_kwargs = dict(
|
||||
files=stages,
|
||||
keywords=['scales', 'measure']
|
||||
)
|
||||
save_path = '../figures/fig_invariance_log_hp.pdf'
|
||||
|
||||
# GRAPH SETTINGS:
|
||||
@@ -177,8 +162,8 @@ for data_path in data_paths:
|
||||
print(f'Processing {data_path}')
|
||||
|
||||
# Load invariance data:
|
||||
pure_data, config = load_data(data_path, files)
|
||||
noise_data, _ = load_data(data_path.replace('.npz', '_noise.npz'), files)
|
||||
pure_data, config = load_data(data_path, **load_kwargs)
|
||||
noise_data, _ = load_data(data_path.replace('.npz', '_noise.npz'), **load_kwargs)
|
||||
t_full = np.arange(pure_data['env'].shape[0]) / config['env_rate']
|
||||
|
||||
# Prepare overall graph:
|
||||
|
||||
Reference in New Issue
Block a user