From 2628adc30fe7fcf2e9c58f73ee16095d7dad18df Mon Sep 17 00:00:00 2001 From: Jan Clemens Date: Fri, 22 Sep 2023 15:22:10 +0200 Subject: [PATCH] also use 'rate' attr from f['samples'] --- src/xarray_behave/__init__.py | 2 +- src/xarray_behave/io/audio.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/xarray_behave/__init__.py b/src/xarray_behave/__init__.py index 4fe012a..7ed99d9 100644 --- a/src/xarray_behave/__init__.py +++ b/src/xarray_behave/__init__.py @@ -1,5 +1,5 @@ """xarray tools for behavioral data.""" -__version__ = "0.33.27" +__version__ = "0.33.28" from .xarray_behave import assemble, assemble_metrics, load, save import os diff --git a/src/xarray_behave/io/audio.py b/src/xarray_behave/io/audio.py index 68ac986..dc066ab 100644 --- a/src/xarray_behave/io/audio.py +++ b/src/xarray_behave/io/audio.py @@ -85,8 +85,11 @@ def load( if return_nonsong_channels: non_song_channels = list(set(list(range(nb_channels))) - set(song_channels)) non_song = da[:, non_song_channels] + if "rate" in f.attrs: samplerate = f.attrs["rate"] + elif "rate" in f["samples"].attrs: + samplerate = f["samples"].attrs["rate"] else: logger.info(" No sampling rate information in daq.h5 file - setting samplerate to default 10_000Hz.") samplerate = 10_000 @@ -101,6 +104,8 @@ def load( if "rate" in f.attrs: samplerate = f.attrs["rate"] + elif "rate" in f["samples"].attrs: + samplerate = f["samples"].attrs["rate"] else: logger.info(" No sampling rate information in daq.h5 file - setting samplerate to default 10_000Hz.") samplerate = 10_000