pycoustic 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycoustic-0.1.3/PKG-INFO +103 -0
- pycoustic-0.1.3/README.md +85 -0
- pycoustic-0.1.3/pycoustic/__init__.py +3 -0
- {pycoustic-0.1.2 → pycoustic-0.1.3}/pycoustic/log.py +1 -1
- {pycoustic-0.1.2 → pycoustic-0.1.3}/pycoustic/survey.py +13 -0
- {pycoustic-0.1.2 → pycoustic-0.1.3}/pycoustic/tkgui.py +1 -0
- {pycoustic-0.1.2 → pycoustic-0.1.3}/pycoustic/weather.py +7 -2
- {pycoustic-0.1.2 → pycoustic-0.1.3}/pyproject.toml +2 -2
- pycoustic-0.1.2/PKG-INFO +0 -19
- pycoustic-0.1.2/README.md +0 -0
- pycoustic-0.1.2/pycoustic/__init__.py +0 -2
pycoustic-0.1.3/PKG-INFO
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: pycoustic
|
3
|
+
Version: 0.1.3
|
4
|
+
Summary:
|
5
|
+
Author: thumpercastle
|
6
|
+
Author-email: tony.ryb@gmail.com
|
7
|
+
Requires-Python: >=3.10,<4.0
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
13
|
+
Requires-Dist: numpy (==2.2.6)
|
14
|
+
Requires-Dist: openpyxl (==3.1.5)
|
15
|
+
Requires-Dist: pandas (==2.2.3)
|
16
|
+
Requires-Dist: requests (>=2.32.4,<3.0.0)
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
|
19
|
+
# pycoustic - Toolkit for Analysing Noise Survey Data
|
20
|
+
## Overview
|
21
|
+
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.
|
22
|
+
|
23
|
+
## Requirements
|
24
|
+
This toolkit was written in Python 3.12. See the pyrpoject.toml for the latest dependencies.
|
25
|
+
|
26
|
+
## Features
|
27
|
+
- Import and process noise survey data from .csv files
|
28
|
+
- Analyse and recompute sound levels and statistical meausres (Leq, Lmax, L90 etc.)
|
29
|
+
- Handle large datasets from multiple measurement positions efficiently
|
30
|
+
- Visualise noise data through customisable plots (WIP)
|
31
|
+
- Generate reports with summary statistics (WIP)
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
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.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
**Before you start**
|
38
|
+
Make sure your input data is in the correct format. See the file UA1_py.csv for reference. Namely:
|
39
|
+
- Your data must be in .csv format.
|
40
|
+
- Timestamps should ideally be in the format *dd-mm-yyyy hh:mm*, other formats may work, but their performance is not tried and tested.
|
41
|
+
- 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.
|
42
|
+
- 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.
|
43
|
+
- 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.
|
44
|
+
### Basic Workflow
|
45
|
+
1. **Import the library**\
|
46
|
+
Import the library into your script or active console.
|
47
|
+
```
|
48
|
+
from pycoustic import*
|
49
|
+
```
|
50
|
+
2. **Load Data**\
|
51
|
+
A single measurement position can be loaded into a Log object.
|
52
|
+
```
|
53
|
+
log1 = Log(path="path/to/data_for_pos1.csv")
|
54
|
+
log2 = Log(path="path/to/data_for_pos2.csv")
|
55
|
+
```
|
56
|
+
3. **Combine Data**\
|
57
|
+
The data from multiple measurement positions can be combined together within a Survey object.
|
58
|
+
First we need to create a Survey object, and then add each Log one at a time.
|
59
|
+
```
|
60
|
+
surv = Survey()
|
61
|
+
surv.add_log(data=log1, name="Position 1")
|
62
|
+
surv.add_log(data=log2, name="Position 2")
|
63
|
+
```
|
64
|
+
4. **Analyse the Survey Data**
|
65
|
+
The following are methods of the Survey() object representing the typical use cases for acoustic consultants in the UK.
|
66
|
+
### Survey.resi_summary()
|
67
|
+
This method provides a summary of the measurement data for residential projects, with a focus on typical assessment procedures in the UK.
|
68
|
+
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.
|
69
|
+
Optional arguments are:\
|
70
|
+
**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.\
|
71
|
+
**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.\
|
72
|
+
**lmax_n** *Int* *(default 10)* The nth-highest value to present.\
|
73
|
+
**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.
|
74
|
+
|
75
|
+
### Survey.modal_l90()
|
76
|
+
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.
|
77
|
+
|
78
|
+
### Survey.lmax_spectra()
|
79
|
+
Compute the Lmax Event spectra for the nth-highest Lmax during each night-time period.\
|
80
|
+
**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).
|
81
|
+
|
82
|
+
### Survey.typical_leq_spectra()
|
83
|
+
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.
|
84
|
+
|
85
|
+
|
86
|
+
### Other methods
|
87
|
+
### Known issues
|
88
|
+
- Lmax night-time timestamps can sometimes by out by a minute.
|
89
|
+
- [RESOLVED 07/02/2025] modal_L90 keyword 'cols' does not work due to headers not being properly allocated.
|
90
|
+
## Troubleshooting
|
91
|
+
### ValueError: NaTType does not support time
|
92
|
+
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.\
|
93
|
+
**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.
|
94
|
+
|
95
|
+
## Terms of use
|
96
|
+
The pycoustic toolkit was built by Tony Trup of [Timbral](https://www.timbral.co.uk).
|
97
|
+
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.
|
98
|
+
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.
|
99
|
+
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.
|
100
|
+
This project is being shared under a [Creative Commons CC BY-NC-SA 4.0 Licence](https://creativecommons.org/licenses/by-nc-sa/4.0/).
|
101
|
+
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.
|
102
|
+
NonCommercial — You may not use the material for commercial purposes.
|
103
|
+
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# pycoustic - Toolkit for Analysing Noise Survey Data
|
2
|
+
## Overview
|
3
|
+
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.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
This toolkit was written in Python 3.12. See the pyrpoject.toml for the latest dependencies.
|
7
|
+
|
8
|
+
## Features
|
9
|
+
- Import and process noise survey data from .csv files
|
10
|
+
- Analyse and recompute sound levels and statistical meausres (Leq, Lmax, L90 etc.)
|
11
|
+
- Handle large datasets from multiple measurement positions efficiently
|
12
|
+
- Visualise noise data through customisable plots (WIP)
|
13
|
+
- Generate reports with summary statistics (WIP)
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
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.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
**Before you start**
|
20
|
+
Make sure your input data is in the correct format. See the file UA1_py.csv for reference. Namely:
|
21
|
+
- Your data must be in .csv format.
|
22
|
+
- Timestamps should ideally be in the format *dd-mm-yyyy hh:mm*, other formats may work, but their performance is not tried and tested.
|
23
|
+
- 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.
|
24
|
+
- 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.
|
25
|
+
- 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.
|
26
|
+
### Basic Workflow
|
27
|
+
1. **Import the library**\
|
28
|
+
Import the library into your script or active console.
|
29
|
+
```
|
30
|
+
from pycoustic import*
|
31
|
+
```
|
32
|
+
2. **Load Data**\
|
33
|
+
A single measurement position can be loaded into a Log object.
|
34
|
+
```
|
35
|
+
log1 = Log(path="path/to/data_for_pos1.csv")
|
36
|
+
log2 = Log(path="path/to/data_for_pos2.csv")
|
37
|
+
```
|
38
|
+
3. **Combine Data**\
|
39
|
+
The data from multiple measurement positions can be combined together within a Survey object.
|
40
|
+
First we need to create a Survey object, and then add each Log one at a time.
|
41
|
+
```
|
42
|
+
surv = Survey()
|
43
|
+
surv.add_log(data=log1, name="Position 1")
|
44
|
+
surv.add_log(data=log2, name="Position 2")
|
45
|
+
```
|
46
|
+
4. **Analyse the Survey Data**
|
47
|
+
The following are methods of the Survey() object representing the typical use cases for acoustic consultants in the UK.
|
48
|
+
### Survey.resi_summary()
|
49
|
+
This method provides a summary of the measurement data for residential projects, with a focus on typical assessment procedures in the UK.
|
50
|
+
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.
|
51
|
+
Optional arguments are:\
|
52
|
+
**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.\
|
53
|
+
**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.\
|
54
|
+
**lmax_n** *Int* *(default 10)* The nth-highest value to present.\
|
55
|
+
**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.
|
56
|
+
|
57
|
+
### Survey.modal_l90()
|
58
|
+
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.
|
59
|
+
|
60
|
+
### Survey.lmax_spectra()
|
61
|
+
Compute the Lmax Event spectra for the nth-highest Lmax during each night-time period.\
|
62
|
+
**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).
|
63
|
+
|
64
|
+
### Survey.typical_leq_spectra()
|
65
|
+
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.
|
66
|
+
|
67
|
+
|
68
|
+
### Other methods
|
69
|
+
### Known issues
|
70
|
+
- Lmax night-time timestamps can sometimes by out by a minute.
|
71
|
+
- [RESOLVED 07/02/2025] modal_L90 keyword 'cols' does not work due to headers not being properly allocated.
|
72
|
+
## Troubleshooting
|
73
|
+
### ValueError: NaTType does not support time
|
74
|
+
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.\
|
75
|
+
**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.
|
76
|
+
|
77
|
+
## Terms of use
|
78
|
+
The pycoustic toolkit was built by Tony Trup of [Timbral](https://www.timbral.co.uk).
|
79
|
+
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.
|
80
|
+
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.
|
81
|
+
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.
|
82
|
+
This project is being shared under a [Creative Commons CC BY-NC-SA 4.0 Licence](https://creativecommons.org/licenses/by-nc-sa/4.0/).
|
83
|
+
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.
|
84
|
+
NonCommercial — You may not use the material for commercial purposes.
|
85
|
+
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
@@ -3,6 +3,11 @@ import numpy as np
|
|
3
3
|
from .weather import WeatherHistory
|
4
4
|
|
5
5
|
|
6
|
+
DECIMALS=0
|
7
|
+
|
8
|
+
# pd.set_option('display.max_columns', None)
|
9
|
+
# pd.set_option('display.max_rows', None)
|
10
|
+
|
6
11
|
class Survey:
|
7
12
|
"""
|
8
13
|
Survey Class is an overarching class which takes multiple Log objects and processes and summarises them together.
|
@@ -13,6 +18,7 @@ class Survey:
|
|
13
18
|
|
14
19
|
def __init__(self):
|
15
20
|
self._logs = {}
|
21
|
+
self._weather = WeatherHistory()
|
16
22
|
|
17
23
|
def _insert_multiindex(self, df=None, super=None, name1="Position", name2="Date"):
|
18
24
|
subs = df.index.to_list() # List of subheaders (dates)
|
@@ -287,6 +293,13 @@ class Survey:
|
|
287
293
|
ends = [self._logs[key].get_end() for key in self._logs.keys()]
|
288
294
|
return min(starts), max(ends)
|
289
295
|
|
296
|
+
def weather(self, interval=6, api_key="", country="GB", postcode="WC1", tz="",):
|
297
|
+
start, end = self.get_start_end()
|
298
|
+
self._weather.reinit(start=start, end=end, interval=interval, api_key=api_key, country=country,
|
299
|
+
postcode=postcode, tz=tz, units="metric")
|
300
|
+
self._weather.compute_weather_history()
|
301
|
+
return self._weather.get_weather_history()
|
302
|
+
|
290
303
|
# def typical_leq_spectra(self, leq_cols=None):
|
291
304
|
# """
|
292
305
|
# DEPRECATED 2025/06/05. Replaced by .leq_spectra() **TT**
|
@@ -2,6 +2,7 @@ import requests
|
|
2
2
|
import pandas as pd
|
3
3
|
import datetime as dt
|
4
4
|
|
5
|
+
test=0
|
5
6
|
|
6
7
|
appid = ""
|
7
8
|
with open("tests/openweather_app_id.txt") as f:
|
@@ -27,9 +28,13 @@ def test_weather_obj(weather_test_dict):
|
|
27
28
|
#TODO: Make this take the start and end times of a Survey object.
|
28
29
|
#TODO: Implement post codes instead of coordinates
|
29
30
|
class WeatherHistory:
|
30
|
-
def __init__(self
|
31
|
+
def __init__(self):
|
32
|
+
return
|
33
|
+
|
34
|
+
def reinit(self, start=None, end=None, interval=6, api_key="", country="GB", postcode="WC1", tz="",
|
31
35
|
units="metric"):
|
32
|
-
|
36
|
+
if api_key==None:
|
37
|
+
raise ValueError("API key is missing")
|
33
38
|
if type(start) == str:
|
34
39
|
self._start = dt.datetime.strptime(start, "%Y-%m-%d %H:%M:%S")
|
35
40
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "pycoustic"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.3"
|
4
4
|
description = ""
|
5
5
|
authors = ["thumpercastle <tony.ryb@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -10,7 +10,7 @@ python = "^3.10"
|
|
10
10
|
pandas = "2.2.3"
|
11
11
|
numpy = "2.2.6"
|
12
12
|
openpyxl = "3.1.5"
|
13
|
-
|
13
|
+
requests = "^2.32.4"
|
14
14
|
|
15
15
|
|
16
16
|
[build-system]
|
pycoustic-0.1.2/PKG-INFO
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: pycoustic
|
3
|
-
Version: 0.1.2
|
4
|
-
Summary:
|
5
|
-
Author: thumpercastle
|
6
|
-
Author-email: tony.ryb@gmail.com
|
7
|
-
Requires-Python: >=3.10,<4.0
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
11
|
-
Classifier: Programming Language :: Python :: 3.12
|
12
|
-
Classifier: Programming Language :: Python :: 3.13
|
13
|
-
Requires-Dist: numpy (==2.2.6)
|
14
|
-
Requires-Dist: openpyxl (==3.1.5)
|
15
|
-
Requires-Dist: pandas (==2.2.3)
|
16
|
-
Requires-Dist: streamlit (==1.46.0)
|
17
|
-
Description-Content-Type: text/markdown
|
18
|
-
|
19
|
-
|
pycoustic-0.1.2/README.md
DELETED
File without changes
|