Added loads of units in nearly all graphs.
Overhauled fig_invariance_full.pdf. Added some legends, somewhere.
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
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 misc_functions import sort_files_by_rec, divide_by_zero
|
||||
from IPython import embed
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target_species = [
|
||||
'Chorthippus_biguttulus',
|
||||
'Chorthippus_mollis',
|
||||
'Chrysochraon_dispar',
|
||||
'Euchorthippus_declivus',
|
||||
'Gomphocerippus_rufus',
|
||||
# 'Chorthippus_biguttulus',
|
||||
# 'Chorthippus_mollis',
|
||||
# 'Chrysochraon_dispar',
|
||||
# 'Euchorthippus_declivus',
|
||||
# 'Gomphocerippus_rufus',
|
||||
'Omocestus_rufipes',
|
||||
'Pseudochorthippus_parallelus',
|
||||
# 'Pseudochorthippus_parallelus',
|
||||
]
|
||||
sources = [
|
||||
'BM04',
|
||||
@@ -32,7 +32,7 @@ normalization = [
|
||||
'max',
|
||||
'base',
|
||||
'range',
|
||||
][2]
|
||||
][4]
|
||||
suffix = dict(
|
||||
none='_unnormed',
|
||||
min='_norm-min',
|
||||
@@ -58,7 +58,7 @@ for i, species in enumerate(target_species):
|
||||
for k, path in enumerate(rec_paths):
|
||||
|
||||
# Load invariance data:
|
||||
data, config = load_data(path, 'scales', 'measure')
|
||||
data, config = load_data(path, 'scales', ['measure', 'thresh'])
|
||||
|
||||
if k == 0:
|
||||
# Prepare song file-specific storage:
|
||||
@@ -80,18 +80,22 @@ for i, species in enumerate(target_species):
|
||||
|
||||
if normalization == 'min':
|
||||
# Minimum normalization:
|
||||
data[mkey] /= data[mkey].min(axis=0, keepdims=True)
|
||||
data[mkey] = divide_by_zero(data[mkey], data[mkey].min(axis=0))
|
||||
# data[mkey] /= data[mkey].min(axis=0, keepdims=True)
|
||||
elif normalization == 'max':
|
||||
# Maximum normalization:
|
||||
data[mkey] /= data[mkey].max(axis=0, keepdims=True)
|
||||
data[mkey] = divide_by_zero(data[mkey], data[mkey].max(axis=0))
|
||||
# data[mkey] /= data[mkey].max(axis=0, keepdims=True)
|
||||
elif normalization == 'base':
|
||||
# Noise baseline normalization:
|
||||
data[mkey] /= data[mkey][0]
|
||||
data[mkey] = divide_by_zero(data[mkey], data[mkey][0])
|
||||
# data[mkey] /= data[mkey][0]
|
||||
elif normalization == 'range':
|
||||
# Min-max normalization:
|
||||
min_measure = data[mkey].min(axis=0, keepdims=True)
|
||||
max_measure = data[mkey].max(axis=0, keepdims=True)
|
||||
data[mkey] = (data[mkey] - min_measure) / (max_measure - min_measure)
|
||||
data[mkey] = divide_by_zero(data[mkey] - min_measure, max_measure - min_measure)
|
||||
# data[mkey] = (data[mkey] - min_measure) / (max_measure - min_measure)
|
||||
|
||||
file_data[stage][..., k] = data[mkey]
|
||||
|
||||
@@ -101,7 +105,11 @@ for i, species in enumerate(target_species):
|
||||
rec_sd[f'sd_{stage}'][..., j] = np.nanstd(file_data[stage], axis=-1)
|
||||
|
||||
# Save condensed recording data:
|
||||
archive = dict(scales=data['scales'])
|
||||
archive = dict(
|
||||
scales=data['scales'],
|
||||
thresh_rel=data['thresh_rel'],
|
||||
thresh_abs=data['thresh_abs']
|
||||
)
|
||||
archive.update(rec_mean)
|
||||
archive.update(rec_sd)
|
||||
save_data(save_path + species + suffix, archive, config)
|
||||
|
||||
Reference in New Issue
Block a user