Skip to main content

Long-term sound level measurements analysis in Python

Project description

noisemonitor

Python package for sound level monitor (long-term sound level meter) data analysis. Contains various fonctions to analyze and plot sliding averages, weekly and daily averages for noise descriptors such as the Lden, Leq and statistical indicators such as L10, L50 and L90 (see this paper for more details on these descriptors). The package works with equivalent sound level data (weighted or un-weighted) captured at regular intervals, typically ranging from 1 second to 1 minute.

Installation

You can install with pip as follows

pip install noisemonitor

For the latest releases install from the GitHub repo

pip install git+https://github.com/valerianF/noisemonitor

Usage

Read sound level monitor data

A function is included to read data in the form of either .csv, .xls, .xlsx or .txt files from a sound level monitor and convert them to a DataFrame with datetime or pandas TimeStamp index. Multiple files can be read at once, and the resulting data will be concatenated in a single DataFrame. Note that you must indicate the datasheet's indexes corresponding to date, time and captured equivalent sound level. Reading files with pandas and automatic parsing into datetime values can be computationaly expensive and the process can last a few minutes, depending on the input data.

from datetime import datetime
import noisemonitor as nm

# Load example .xslx data within the github repository
df = nm.load_data(['tests/data/test.xlsx'], datetimeindex=0, valueindex=1)

# Filter out data between or outside specified dates and times if required
df = nm.filter_data(df, datetime(2022,8,10,3), datetime(2022,8,10,4), between=True)

Once sound level data is parsed into a proper dataframe, you can create a NoiseMonitor class instance from it, which will be used for further analyses.

average = nm.NoiseMonitor(df)

Data analysis and plotting

The hard part is over, now you can just compute the descriptors you want from the NoiseMonitor class instance. Individual average descriptors are returned as dictionnaries.

# Equivalent level and percentiles between 7am and 12am
leq_am = average.leq(7, 12) 

# Same between 3pm and 7pm on weekends
leq_pm_weekends = average.leq(15, 19, day1='saturday', day2='sunday') 

# Lden overall
lden_all = average.lden() 

# Lden from mondays to fridays
lden_weekdays = average.lden(day1='monday', day2='friday') 

General, daily or weekly sliding averages are returned as DataFrames with datetime (for general averages) or time (for daily and weekly averages) index, and with columns including the corresponding Leq, L10, L50 and L90 values, respectively.

# sliding average with a window size of 3600s (1 hour) and a step size of 1200s (20 minutes)
general = average.sliding_average(win=3600, step=1200) 

# daily average from 9pm to 7am
daily = average.daily(21, 7, win=3600, step=1200)

# weekday average from 2am to 11pm
weekday = average.weekly(2, 23, 'monday', 'friday', win=3600, step=1200)

# weekend average from 2am to 11pm
weekend = average.weekly(2, 23, 'saturday', 'sunday', win=3600, step=1200)

These sliding averages can be plotted using level_plot function.

nm.level_plot(general, 'Leq') # Showing general Leq values
nm.level_plot(daily, 'Leq', 'L10', 'L50', 'L90') # Showing daily night values
nm.level_plot(weekday, 'L10', 'L50', 'L90') # Showing weekday percentiles values
nm.level_plot(weekend, 'L10', 'L50', 'L90') # Showing weekend percentiles values

Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noisemonitor-0.0.2.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noisemonitor-0.0.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file noisemonitor-0.0.2.tar.gz.

File metadata

  • Download URL: noisemonitor-0.0.2.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for noisemonitor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 afa352a3fa8626a00928378cd3d88762723e3b4a53fd28ad78abbad25379f062
MD5 4f7d13bf8c494cc9a9f447814b18c75e
BLAKE2b-256 a85cf415d31f39f2772820390e28b9b6236cbfebc22bdce7961eb80204831285

See more details on using hashes here.

File details

Details for the file noisemonitor-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: noisemonitor-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for noisemonitor-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9faab556fee21a62455b9919b7144d51b77aea63444b592755180ec6f6b0fbc4
MD5 f5f94febb21e61d45f0d1fc0ca54806b
BLAKE2b-256 dfe1ff29785e7462e5e126e2186932071eed9c16535fb111bc1da6ab4658c116

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page