Skip to main content

No project description provided

Project description

pycoustic - Toolkit for Analysing Noise Survey Data

Overview

pycoustic is a Python-based toolkit designed to assist acoustic consultants and engineers in analyzing noise survey data. The library provides various tools and utilities for processing, interpreting, and visualizing noise measurements.

Requirements

This toolkit was written in Python 3.12. See the pyrpoject.toml for the latest dependencies.

Features

  • Import and process noise survey data from .csv files
  • Analyse and recompute sound levels and statistical meausres (Leq, Lmax, L90 etc.)
  • Handle large datasets from multiple measurement positions efficiently
  • Visualise noise data through customisable plots (WIP)
  • Generate reports with summary statistics (WIP)

Installation

The library is not currently available through pip or Anaconda (we're working on it). You can pull the code from git, or simply download the files on this GitHub page.

Usage

Before you start Make sure your input data is in the correct format. See the file UA1_py.csv for reference. Namely:

  • Your data must be in .csv format.
  • Timestamps should ideally be in the format dd-mm-yyyy hh:mm, other formats may work, but their performance is not tried and tested.
  • Column headers should be in the Tuple-like format as per the example csv files attached. The measurement index should be first, and the frequency band or weighting should be second. e.g. the LAeq column should have the header "Leq A", the L90 column at 125 Hz should have the header "L90 125", and so on.
  • Make sure you past your data and columns into a fresh csv tab. If you end up having to chop the data and delete columns or rows, repaste it into a fresh tab when it is ready to be presented to the toolkit. Failure to do so can result in a ValueError. See Troubleshooting below.
  • If you do use this toolkit, please attribute it appropriately, and carry out your own checks to ensure you are satisfied with the outputs. See Terms of Use below.

Basic Workflow

  1. Import the library
    Import the library into your script or active console.

    from pycoustic import*
    
  2. Load Data
    A single measurement position can be loaded into a Log object.

    log1 = Log(path="path/to/data_for_pos1.csv")
    log2 = Log(path="path/to/data_for_pos2.csv")
    
  3. Combine Data
    The data from multiple measurement positions can be combined together within a Survey object. First we need to create a Survey object, and then add each Log one at a time.

    surv = Survey()
    surv.add_log(data=log1, name="Position 1")
    surv.add_log(data=log2, name="Position 2")
    
  4. Analyse the Survey Data The following are methods of the Survey() object representing the typical use cases for acoustic consultants in the UK.

    Survey.resi_summary()

    This method provides a summary of the measurement data for residential projects, with a focus on typical assessment procedures in the UK. It presents A-weighted Leqs for each day and night period (and evenings, if enabled), as well as the nth-highest LAmax during each night-time period. Optional arguments are:
    leq_cols List of tuples (default [("Leq", "A")] Which column(s) you want to present as Leqs - this can be any Leq or statistical column.
    max_cols List of tuples (default [("Leq", "A")] Which column(s) you want to present as an nth-highest value - this can be any column.
    lmax_n Int (default 10) The nth-highest value to present.
    lmax_t Str (default "2min") The time period T over which Lmaxes are presented. This must be equal to or longer than the period of the raw data.

    Survey.modal_l90()

    Compute the modal L90 for daytime, evening (if enabled) and night-time periods. By default, this is set to T=60min for (23:00 to 07:00) periods, and T=15min for night-time (23:00 to 07:00) periods, as per BS 4142:2014.

    Survey.lmax_spectra()

    Compute the Lmax Event spectra for the nth-highest Lmax during each night-time period.
    Note the date presented alongside the Lmax event is actually the starting date of the night-time period. i.e. an Lmax event with a stamp of 20/12/2024 at 01:22 would actually have occurred on 21/12/2024 at 01:22. These stamps can also sometimes be out by a minute (known bug).

    Survey.typical_leq_spectra()

    Compute the Leq spectra for daytime, evening (if enabled) and night-time periods. This will present the overall Leqs across the survey, not the Leq for each day.

Other methods

Known issues

  • Lmax night-time timestamps can sometimes by out by a minute.
  • [RESOLVED 07/02/2025] modal_L90 keyword 'cols' does not work due to headers not being properly allocated.

Troubleshooting

ValueError: NaTType does not support time

This error occurs when trying to create a Log() object with a csv file. It occurs because the source csv file contains empty cells which were previously allocated (filled). It usually happens when you have entered data into some row(s) or column(s) and then deleted it, leaving previously-full cells which are now empty.
Solution: Create a new tab in your source csv file, and paste in your headers and data as you wish it to be presented to the toolkit, avoiding having to delete any columns and rows. Delete the old tab. If you do have to delete any data in the new tab, you will need to repeat the process to ensure this error is not thrown up again.

Terms of use

The pycoustic toolkit was built by Tony Trup of Timbral. Neither I nor Timbral Ltd. accept any liability for the outputs of this toolkit. You use it at your own risk, and you should carry out your own checks and balances to ensure you are satistfied that the output is accurate. This is an open source project, and I welcome suggestions for changes, improvements or new features. You can also write your own methods or functions and share them with me, either by getting in touch offline, or by creating a new branch from this Git repository. You may use this toolkit subject to the licence conditions below. For clarity, you may use this toolkit or adaptations of it in your day-to-day engineering work, but incorporating it into a commercial software product or service is not permitted. This project is being shared under a Creative Commons CC BY-NC-SA 4.0 Licence. Attribution — You must give appropriate credit , provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial — You may not use the material for commercial purposes. ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

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

pycoustic-0.1.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

pycoustic-0.1.3-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pycoustic-0.1.3.tar.gz.

File metadata

  • Download URL: pycoustic-0.1.3.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.9 Windows/11

File hashes

Hashes for pycoustic-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f48c56279b0277dc714d451dd6bbeff62b516ccb7280ad9a4fa1e035168defe0
MD5 5902c9b691949f702dce91cc2e784d78
BLAKE2b-256 b1c2e6c8eec62301988afa9cab753db77b01e3d4259e6f0ecda4487fc117fb7d

See more details on using hashes here.

File details

Details for the file pycoustic-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pycoustic-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.9 Windows/11

File hashes

Hashes for pycoustic-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe4ea2624e823327f824ae1698aec7e59e8c0d684c87c42fa66c7009097bd5e
MD5 fc62d9b93526437a9bbb0cd1d6dbcfeb
BLAKE2b-256 69b0bce9f2bbd3e6aa36b017b482763739000d3f68dc3e84aca5e4b34114b991

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