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.
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
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)
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
If you use noisemonitor in your work please consider citing us.
@inproceedings{fraisse2023noisemonitor, title={noisemonitor: A Python Package For Sound Level Monitor Analysis}, author={Fraisse, Valérian}, booktitle={Acoustics week in Canada}, year={2023}}
- NumPy (http://www.numpy.org/)
- pandas (https://pandas.pydata.org/)
- Matplotlib (https://matplotlib.org/)