Parse metadata from ARUs including the AudioMoth
Project description
aru_metadata_parser
Parse audio file metadata from common ARUs including the AudioMoth
This package aims to provide support for parsing metadata from common ARU (autonomous recording unit) audio files. Currently, AudioMoth metadata from firmware versions up to 1.8.1 are supported.
Please use Issues to report failures in metadata parsing, and to request parsing for other metadata formats. r
Installation:
The package is available on PyPI and can be installed with PIP:
pip install aru_metadata_parser
Usage
Parse start time from any ARU filename
The top-level parse_aru_file_start_time function supports AudioMoth, Song Meter, OwlSense, and Swift recorders. If no recorder_type is specified, it tries all known formats automatically before falling back to fuzzy date parsing.
from aru_metadata_parser import parse
# Auto-detect recorder type
dt = parse.parse_aru_file_start_time("SMM03873_20220719_000000.wav")
# Specify recorder type explicitly
dt = parse.parse_aru_file_start_time(
"SMM03873_20220719_000000.wav",
recorder_type="songmeter", # one of: 'audiomoth', 'songmeter', 'owlsense', 'swift'
filename_timezone="US/Eastern", # timezone the recorder used when naming the file
output_timezone="UTC", # convert result to this timezone
)
Recorder-specific parsing
AudioMoth — supports both hex filenames (old firmware) and human-readable filenames (new firmware):
# New firmware (human-readable)
dt = parse.audiomoth_start_time("20200404_102500.WAV")
# With timezone info
dt = parse.audiomoth_start_time("20200404_102500.WAV", filename_timezone="UTC", output_timezone="US/Eastern")
# Old firmware (hexadecimal filename, always UTC)
dt = parse.audiomoth_start_time("5E886A48.WAV", filename_timezone="UTC")
Song Meter (SM2/3/4, Mini, Micro) — filename pattern: SMM03873_20220719_000000.wav:
dt = parse.songmeter_start_time("SMM03873_20220719_000000.wav")
dt = parse.songmeter_start_time("SMM03873_20220719_000000.wav", filename_timezone="US/Eastern", output_timezone="UTC")
OwlSense — filename pattern: OWL_123456_2022-07-19_T00-00-00.WAV:
dt = parse.owlsense_start_time("OWL_123456_2022-07-19_T00-00-00.WAV")
dt = parse.owlsense_start_time("OWL_123456_2022-07-19_T00-00-00.WAV", filename_timezone="UTC", output_timezone="US/Eastern")
Swift — filename pattern: SwiftOne_20220719_000000_-0400.wav (UTC offset embedded in filename):
dt = parse.swift_start_time("SwiftOne_20220719_000000_-0400.wav")
dt = parse.swift_start_time("SwiftOne_20220719_000000_-0400.wav", output_timezone="UTC")
Parse AudioMoth WAV file metadata
Reads and parses metadata from the WAV header of an AudioMoth recording. Returns a dictionary with keys including gain_setting, battery_state, recording_start_time, device_id, and (for firmware >=1.4.0) temperature_C:
# From a file path
metadata = parse.parse_audiomoth_metadata_from_path("audiomoth_recording.WAV")
print(metadata["gain_setting"]) # e.g. 'medium' or 2
print(metadata["battery_state"]) # e.g. 4.7 (volts)
print(metadata["recording_start_time"]) # localized datetime
print(metadata["temperature_C"]) # e.g. 11.2
# From an already-loaded metadata dictionary
metadata = parse.parse_audiomoth_metadata(metadata_dict)
Timezone handling
filename_timezone: the timezone the recorder used when constructing its filename (e.g."UTC","US/Eastern"). IfNone, returns a naive datetime object.output_timezone: timezone to convert the result to. Requiresfilename_timezoneto be set (except for Swift, which embeds UTC offset in the filename).- Timezone strings must be valid pytz timezone names (see
pytz.all_timezones).
Contribution:
We use Poetry for development, with black formatting and pytest testing. Contributions to the code base are welcome.
License and attribution:
This package is provided under the MIT Open-source license.
Suggested citation:
Lapp, Syunkova, and Kitzes, 2023. ARU Metadata Parser v0.1.0. github.com/kitzeslab/aru_metadata_parser.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aru_metadata_parser-1.0.0.tar.gz.
File metadata
- Download URL: aru_metadata_parser-1.0.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ea359ec60761d0a359dbc40fb0f934d1e20324bcac2f6eb4a38e6449ae81203
|
|
| MD5 |
165e39b1340f9856b4bb564dcbcfcec8
|
|
| BLAKE2b-256 |
947ea315052007fe3d5adbcd6ba12829f6b23eb117dd976b400242cfed92425d
|
File details
Details for the file aru_metadata_parser-1.0.0-py3-none-any.whl.
File metadata
- Download URL: aru_metadata_parser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c16be485054a577eaa165b1f2a1e8cce3c0892fb9e9711083a11b6f45a0d13
|
|
| MD5 |
3a6801d5757dd0f8a9a90c10668f3c9e
|
|
| BLAKE2b-256 |
3dbfae411ebdc26ee97673b012a3e0e4147af736cda27456a46215e0c73c041a
|