Seriously, no idea. Wild amount of changes. Good luck.
This commit is contained in:
46
python/collect_inv_data_log-hp.py
Normal file
46
python/collect_inv_data_log-hp.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import numpy as np
|
||||
from thunderhopper.filetools import search_files
|
||||
from thunderhopper.modeltools import load_data, save_data
|
||||
from misc_functions import sort_files_by_rec
|
||||
from IPython import embed
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target_species = [
|
||||
'Chorthippus_biguttulus',
|
||||
'Chorthippus_mollis',
|
||||
'Chrysochraon_dispar',
|
||||
'Euchorthippus_declivus',
|
||||
'Gomphocerippus_rufus',
|
||||
'Omocestus_rufipes',
|
||||
'Pseudochorthippus_parallelus',
|
||||
]
|
||||
search_path = '../data/inv/log_hp/'
|
||||
save_path = '../data/inv/log_hp/collected/'
|
||||
|
||||
# EXECUTION:
|
||||
for i, species in enumerate(target_species):
|
||||
print(f'Processing {species}')
|
||||
|
||||
# Fetch all species-specific song files:
|
||||
all_paths = search_files(species, incl='noise', ext='npz', dir=search_path)
|
||||
|
||||
# Run through files:
|
||||
for j, path in enumerate(all_paths):
|
||||
|
||||
# Load invariance data:
|
||||
data, config = load_data(path, ['scales', 'measure_inv'])
|
||||
scales, measure = data['scales'], data['measure_inv']
|
||||
|
||||
if j == 0:
|
||||
# Prepare species-specific storage:
|
||||
spec_data = np.zeros((measure.shape + (len(all_paths),)), dtype=float)
|
||||
|
||||
# Log file data:
|
||||
spec_data[..., j] = measure
|
||||
|
||||
# Save collected file data:
|
||||
save_name = save_path + species
|
||||
archive = dict(scales=scales, measure_inv=spec_data)
|
||||
save_data(save_name, archive, config, overwrite=True)
|
||||
|
||||
print('Done.')
|
||||
Reference in New Issue
Block a user