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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

noisemonitor-0.0.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: noisemonitor-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61f76bfbf742865c27940106ea17806d2abed2b8baef537d46b1ac723404d79b
MD5 5bc21fbb01ec56869bd4b9421aae3f4d
BLAKE2b-256 c747ab70efab61454b261b680899f532301e9d908c2d4b1f79c4bfeb5ef72ee6

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