Nearly finished 1st draft of species-specific Thresh-LP invariance figure (WIP).
This commit is contained in:
@@ -1,31 +1,13 @@
|
||||
import plotstyle_plt
|
||||
import glob
|
||||
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, plot_barcode, strip_zeros
|
||||
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)
|
||||
@@ -49,7 +31,7 @@ def plot_bi_snippets(axes, time, binary, **kwargs):
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target = 'Omocestus_rufipes'
|
||||
data_paths = search_files(target, excl='noise', dir='../data/inv/full/')
|
||||
data_paths = glob.glob(f'../data/processed/{target}*.npz')
|
||||
stages = ['filt', 'env', 'log', 'inv', 'conv', 'bi', 'feat']
|
||||
load_kwargs = dict(
|
||||
files=stages,
|
||||
@@ -62,8 +44,8 @@ fig_kwargs = dict(
|
||||
figsize=(32/2.54, 16/2.54),
|
||||
)
|
||||
super_grid_kwargs = dict(
|
||||
nrows=2,
|
||||
ncols=2,
|
||||
nrows=len(stages),
|
||||
ncols=3,
|
||||
wspace=0,
|
||||
hspace=0,
|
||||
left=0,
|
||||
@@ -72,31 +54,20 @@ super_grid_kwargs = dict(
|
||||
top=1
|
||||
)
|
||||
subfig_specs = dict(
|
||||
pure=(0, 0),
|
||||
noise=(1, 0),
|
||||
analysis=(slice(None), 1)
|
||||
**{stage: (slice(0, -1), i) for i, stage in enumerate(stages)},
|
||||
big=(slice(None), -1)
|
||||
)
|
||||
pure_grid_kwargs = dict(
|
||||
nrows=len(stages),
|
||||
stage_grid_kwargs = dict(
|
||||
nrows=1,
|
||||
ncols=None,
|
||||
wspace=0.05,
|
||||
hspace=0.1,
|
||||
hspace=0,
|
||||
left=0.07,
|
||||
right=0.95,
|
||||
bottom=0.15,
|
||||
top=0.9
|
||||
)
|
||||
noise_grid_kwargs = dict(
|
||||
nrows=len(stages),
|
||||
ncols=None,
|
||||
wspace=0.05,
|
||||
hspace=0.1,
|
||||
left=0.07,
|
||||
right=0.95,
|
||||
bottom=0.15,
|
||||
top=0.9
|
||||
)
|
||||
analysis_grid_kwargs = dict(
|
||||
big_grid_kwargs = dict(
|
||||
nrows=1,
|
||||
ncols=1,
|
||||
wspace=0,
|
||||
@@ -106,19 +77,20 @@ analysis_grid_kwargs = dict(
|
||||
bottom=0.1,
|
||||
top=0.95
|
||||
)
|
||||
snip_specs = dict(
|
||||
conv=(0, slice(None)),
|
||||
bi=(1, slice(None)),
|
||||
feat=(2, slice(None))
|
||||
)
|
||||
|
||||
# PLOT SETTINGS:
|
||||
colors = load_colors('../data/stage_colors.npz')
|
||||
lw_snippets = dict(
|
||||
raw=0.25,
|
||||
filt=0.25,
|
||||
env=0.5,
|
||||
log=0.5,
|
||||
inv=0.5,
|
||||
conv=0.5,
|
||||
bi=0.01,
|
||||
feat=2
|
||||
)
|
||||
lw_analysis = 3
|
||||
lw_big = 3
|
||||
xlabels = dict(
|
||||
analysis='scale $\\alpha$',
|
||||
)
|
||||
@@ -148,38 +120,38 @@ ylab_analysis_kwargs = dict(
|
||||
ha='center',
|
||||
va='top',
|
||||
)
|
||||
xloc = dict(
|
||||
analysis=10,
|
||||
)
|
||||
letter_snip_kwargs = dict(
|
||||
x=0.02,
|
||||
y=1,
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
fontweight='bold'
|
||||
)
|
||||
letter_analysis_kwargs = dict(
|
||||
x=0,
|
||||
y=1,
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
fontweight='bold'
|
||||
)
|
||||
bar_time = 5
|
||||
bar_kwargs = dict(
|
||||
y0=0.7,
|
||||
y1=0.8,
|
||||
color='k',
|
||||
lw=0,
|
||||
)
|
||||
spread_kwargs = dict(
|
||||
alpha=0.3,
|
||||
lw=0,
|
||||
zorder=0
|
||||
)
|
||||
kernel_ind = 0
|
||||
# xloc = dict(
|
||||
# analysis=10,
|
||||
# )
|
||||
# letter_snip_kwargs = dict(
|
||||
# x=0.02,
|
||||
# y=1,
|
||||
# ha='left',
|
||||
# va='top',
|
||||
# fontsize=22,
|
||||
# fontweight='bold'
|
||||
# )
|
||||
# letter_analysis_kwargs = dict(
|
||||
# x=0,
|
||||
# y=1,
|
||||
# ha='left',
|
||||
# va='top',
|
||||
# fontsize=22,
|
||||
# fontweight='bold'
|
||||
# )
|
||||
# bar_time = 5
|
||||
# bar_kwargs = dict(
|
||||
# y0=0.7,
|
||||
# y1=0.8,
|
||||
# color='k',
|
||||
# lw=0,
|
||||
# )
|
||||
# spread_kwargs = dict(
|
||||
# alpha=0.3,
|
||||
# lw=0,
|
||||
# zorder=0
|
||||
# )
|
||||
# kernel_ind = 0
|
||||
|
||||
# EXECUTION:
|
||||
for data_path in data_paths:
|
||||
|
||||
Reference in New Issue
Block a user