pycoustic 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,2 +1,3 @@
1
1
  from .log import Log
2
- from .survey import Survey
2
+ from .survey import Survey
3
+ from .weather import WeatherHistory
pycoustic/log.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import pandas as pd
2
2
  import numpy as np
3
3
  import datetime as dt
4
- import warnings
4
+
5
5
 
6
6
 
7
7
  class Log:
pycoustic/survey.py CHANGED
@@ -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**
pycoustic/tkgui.py CHANGED
@@ -11,6 +11,7 @@ from tkinter import StringVar
11
11
  #from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
12
12
 
13
13
  #from src import log # Assuming log is an instance of a class with the required methods
14
+ test = 0
14
15
 
15
16
  class Application(tk.Tk):
16
17
 
pycoustic/weather.py CHANGED
@@ -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, start=None, end=None, interval=6, api_key="", country="GB", postcode="WC1", tz="",
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
- # self._history_df = pd.DataFrame()
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:
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.3
2
+ Name: pycoustic
3
+ Version: 0.1.4
4
+ Summary:
5
+ Author: thumpercastle
6
+ Author-email: tony.ryb@gmail.com
7
+ Requires-Python: >=3.12,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Requires-Dist: numpy (==2.2.6)
12
+ Requires-Dist: openpyxl (==3.1.5)
13
+ Requires-Dist: pandas (==2.2.3)
14
+ Requires-Dist: requests (>=2.32.4,<3.0.0)
15
+ Description-Content-Type: text/markdown
16
+
17
+ # pycoustic - Toolkit for Analysing Noise Survey Data
18
+ ## Overview
19
+ 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.
20
+
21
+ ## Requirements
22
+ This toolkit was written in Python 3.12. See the pyrpoject.toml for the latest dependencies.
23
+
24
+ ## Features
25
+ - Import and process noise survey data from .csv files
26
+ - Analyse and recompute sound levels and statistical meausres (Leq, Lmax, L90 etc.)
27
+ - Handle large datasets from multiple measurement positions efficiently
28
+ - Visualise noise data through customisable plots (WIP)
29
+ - Generate reports with summary statistics (WIP)
30
+
31
+ ## Installation
32
+ 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.
33
+
34
+ ## Usage
35
+ **Before you start**
36
+ Make sure your input data is in the correct format. See the file UA1_py.csv for reference. Namely:
37
+ - Your data must be in .csv format.
38
+ - Timestamps should ideally be in the format *dd-mm-yyyy hh:mm*, other formats may work, but their performance is not tried and tested.
39
+ - 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.
40
+ - 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.
41
+ - 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.
42
+ ### Basic Workflow
43
+ 1. **Import the library**\
44
+ Import the library into your script or active console.
45
+ ```
46
+ from pycoustic import*
47
+ ```
48
+ 2. **Load Data**\
49
+ A single measurement position can be loaded into a Log object.
50
+ ```
51
+ log1 = Log(path="path/to/data_for_pos1.csv")
52
+ log2 = Log(path="path/to/data_for_pos2.csv")
53
+ ```
54
+ 3. **Combine Data**\
55
+ The data from multiple measurement positions can be combined together within a Survey object.
56
+ First we need to create a Survey object, and then add each Log one at a time.
57
+ ```
58
+ surv = Survey()
59
+ surv.add_log(data=log1, name="Position 1")
60
+ surv.add_log(data=log2, name="Position 2")
61
+ ```
62
+ 4. **Analyse the Survey Data**
63
+ The following are methods of the Survey() object representing the typical use cases for acoustic consultants in the UK.
64
+ ### Survey.resi_summary()
65
+ This method provides a summary of the measurement data for residential projects, with a focus on typical assessment procedures in the UK.
66
+ 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.
67
+ Optional arguments are:\
68
+ **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.\
69
+ **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.\
70
+ **lmax_n** *Int* *(default 10)* The nth-highest value to present.\
71
+ **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.
72
+
73
+ ### Survey.modal_l90()
74
+ 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.
75
+
76
+ ### Survey.lmax_spectra()
77
+ Compute the Lmax Event spectra for the nth-highest Lmax during each night-time period.\
78
+ **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).
79
+
80
+ ### Survey.typical_leq_spectra()
81
+ 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.
82
+
83
+
84
+ ### Other methods
85
+ ### Known issues
86
+ - Lmax night-time timestamps can sometimes by out by a minute.
87
+ - [RESOLVED 07/02/2025] modal_L90 keyword 'cols' does not work due to headers not being properly allocated.
88
+ ## Troubleshooting
89
+ ### ValueError: NaTType does not support time
90
+ 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.\
91
+ **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.
92
+
93
+ ## Terms of use
94
+ The pycoustic toolkit was built by Tony Trup of [Timbral](https://www.timbral.co.uk).
95
+ 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.
96
+ 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.
97
+ 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.
98
+ 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/).
99
+ 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.
100
+ NonCommercial — You may not use the material for commercial purposes.
101
+ 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,8 @@
1
+ pycoustic/__init__.py,sha256=0UGHX-vdulM9x1j8g_DcR_BbtBk0gEFg9l4KjLl4Qrk,85
2
+ pycoustic/log.py,sha256=HNdS2hKKbUdqY7iAMj9QJqoI9r4ZtJ7GCXnIx8XpTH4,17145
3
+ pycoustic/survey.py,sha256=6bQW1UniUgUdj7jOpqTagdos6IRVPhURegmq9PgBYjQ,18453
4
+ pycoustic/tkgui.py,sha256=vvB0D29GER-i7lC_SUuzKrzbh1EFAAhpRaHi7kggtYk,13985
5
+ pycoustic/weather.py,sha256=xEp5-ZYlYJXB-G2QQuEETTfyMALAWJtSWtLn5XHDRFo,3822
6
+ pycoustic-0.1.4.dist-info/METADATA,sha256=oaKowQ5VWRGEAjzwklUpSJlyou5O6FIOcZMINOTN7NU,7374
7
+ pycoustic-0.1.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
8
+ pycoustic-0.1.4.dist-info/RECORD,,
@@ -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
-
@@ -1,8 +0,0 @@
1
- pycoustic/__init__.py,sha256=Midt6cul_fLEpsI002sx-Yi_-gZV2Hs36mxIlnDs82I,48
2
- pycoustic/log.py,sha256=pXSm01MHJ3gNGpJq14_lRV_NrF9S1ruHTK_77CDhsHs,17160
3
- pycoustic/survey.py,sha256=SqttTArZuldrafOf7fMNSQLEuHo8oqM89KYxqTAtQ88,17897
4
- pycoustic/tkgui.py,sha256=SGTAvJg1OzUcmfdi97TwThRvAPBJHPKKJi-jyrshors,13975
5
- pycoustic/weather.py,sha256=bKdCQrn_Dg6WHIXXKUOvgfVn7n6r6AoVBBMcdlu7ViM,3739
6
- pycoustic-0.1.2.dist-info/METADATA,sha256=t2f3wkScvHapwUHK5cElbmO4aR34oclGB2gEpNxvto8,574
7
- pycoustic-0.1.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
8
- pycoustic-0.1.2.dist-info/RECORD,,