Added multi-thresh simulation to "full" and "short" (currently running).

Added complete "rect-lp" analysis except figure.
Added multiple appendix figs.
Overhauled normalization options across all condense scripts.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
j-hartling
2026-04-24 16:50:14 +02:00
parent 1a586848e8
commit 5411a309f7
48 changed files with 1549 additions and 300 deletions

View File

@@ -1,6 +1,7 @@
import numpy as np
from scipy.stats import gaussian_kde
from thunderhopper.filetools import crop_paths
from IPython import embed
def shorten_species(name):
genus, species = name.split('_')
@@ -48,6 +49,40 @@ def sort_files_by_rec(paths, sources=['BM04', 'BM93', 'DJN', 'GBC', 'FTN']):
sorted_paths = [path for paths in sorted_paths.values() for path in paths]
return sorted_paths
def get_thresholds(data=None, path=None, perc=None, factor=None,
direct=False, which=None):
def get_inds(nearest, which):
if which == 'floor':
nearest[nearest < 0] = np.inf
return nearest.argmin(axis=0)
elif which == 'ceil':
nearest[nearest > 0] = -np.inf
return nearest.argmax(axis=0)
return np.abs(nearest).argmin(axis=0)
if data is None:
# Load threshold data:
data = dict(np.load(path))
# From SD scaling factor:
if factor is not None:
if direct:
# Scale SDs directly by factor:
return data['sds'] * factor, factor, None
# Link to supra-thresh proportion:
nearest = np.atleast_2d(factor) - data['factors'][:, None]
inds = get_inds(nearest, which)
factors = data['factors'][inds]
return data['sds'] * factors, factors, data['percs'][inds, :]
# From supra-thresh proportion:
nearest = perc - data['percs']
inds = get_inds(nearest, which)
factors = data['factors'][inds]
return data['sds'] * factors, factors, data['percs'][inds, :]
def get_histogram(data, edges=None, nbins=50, pad=0.1, shared=True):
if edges is None:
axis = None if shared else 0