Files
paper_2025/python/save_field_data.py
j-hartling 5411a309f7 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>
2026-04-24 16:50:14 +02:00

63 lines
1.6 KiB
Python

import numpy as np
from thunderhopper.filetools import search_files, crop_paths
from thunderhopper.model import configuration, process_signal
from thunderhopper.modeltools import load_data
from IPython import embed
## SETTINGS:
# General:
search_target = '*'
mode = ['song', 'noise'][1]
input_folder = f'../data/field/raw/{mode}/'
output_folder = f'../data/field/processed/{mode}/'
stages = ['raw', 'norm']
if True:
# Overwrites edited:
stages.append('songs')
# Interactivity:
reload_saved = False
gui = True
# Processing:
env_rate = 96000.0
feat_rate = 96000.0
sigmas = [0.001, 0.002, 0.004, 0.008, 0.016, 0.032]
types = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5,
6, -6, 7, -7, 8, -8, 9, -9, 10, -10]
config = configuration(env_rate, feat_rate, types=types, sigmas=sigmas)
config.update({
'channel': None,
'rate_ratio': None,
'env_fcut': 250,
'db_ref': 1,
'inv_fcut': 10,
'feat_thresh': np.load('../data/kernel_thresholds.npy') * 0.2,
'feat_fcut': 0.5,
'label_channels': np.array([0]),
'label_thresh': 0.5,
})
## PREPARATION:
# Fetch WAV recording files:
input_paths = search_files(search_target, ext='wav', dir=input_folder)
path_names = crop_paths(input_paths)
# PROCESSING:
# Run processing pipeline:
for path, name in zip(input_paths, path_names):
print('Processing:', name)
# Fetch and store representations:
save = None if output_folder is None else output_folder + f'{name}.npz'
process_signal(config, stages, path, save=save, label_edit=gui)
# Cross-control:
if reload_saved:
data, params = load_data(save, stages, ['songs'])
embed()
print('Done.')