pycoustic 0.1.13__py3-none-any.whl → 0.1.15__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/survey.py
CHANGED
@@ -35,10 +35,31 @@ class Survey:
|
|
35
35
|
return df.set_index(idx, inplace=False)
|
36
36
|
|
37
37
|
def _insert_header(self, df=None, new_head_list=None, header_idx=None):
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
if df is None or new_head_list is None:
|
39
|
+
return df
|
40
|
+
|
41
|
+
ncols = df.shape[1]
|
42
|
+
|
43
|
+
# Allow scalar broadcast for convenience
|
44
|
+
if isinstance(new_head_list, (str, int, float)):
|
45
|
+
new_head_list = [new_head_list] * ncols
|
46
|
+
|
47
|
+
if len(new_head_list) != ncols:
|
48
|
+
raise ValueError(
|
49
|
+
f"new_head_list length ({len(new_head_list)}) must equal number of columns ({ncols})."
|
50
|
+
)
|
51
|
+
|
52
|
+
cols = list(df.columns)
|
53
|
+
# Normalize columns into list of tuples
|
54
|
+
if isinstance(df.columns, pd.MultiIndex):
|
55
|
+
tuples = cols # already list of tuples
|
56
|
+
else:
|
57
|
+
tuples = [(c,) for c in cols]
|
58
|
+
|
59
|
+
# Build arrays per level and insert new header list
|
60
|
+
arrays = [list(x) for x in zip(*tuples)]
|
61
|
+
arrays.insert(header_idx, list(new_head_list))
|
62
|
+
df.columns = pd.MultiIndex.from_arrays(arrays)
|
42
63
|
return df
|
43
64
|
|
44
65
|
# def _leq_by_date(self, data, cols=None):
|
@@ -113,34 +134,33 @@ class Survey:
|
|
113
134
|
:return: A dataframe presenting a summary of the Leq and Lmax values requested.
|
114
135
|
"""
|
115
136
|
combi = pd.DataFrame()
|
116
|
-
period_headers = []
|
117
137
|
if leq_cols is None:
|
118
138
|
leq_cols = [("Leq", "A")]
|
119
139
|
if max_cols is None:
|
120
140
|
max_cols = [("Lmax", "A")]
|
121
141
|
|
122
|
-
for key, lg in self._logs.items():
|
123
|
-
|
124
|
-
|
142
|
+
for key, lg in self._logs.items():
|
143
|
+
period_blocks = []
|
144
|
+
period_names = []
|
125
145
|
|
126
146
|
# Day
|
127
147
|
days = lg.leq_by_date(lg.get_period(data=lg.get_antilogs(), period="days"), cols=leq_cols)
|
128
148
|
days.sort_index(inplace=True)
|
129
|
-
|
130
|
-
|
149
|
+
period_blocks.append(days)
|
150
|
+
period_names.append("Daytime")
|
131
151
|
|
132
|
-
# Evening
|
152
|
+
# Evening (optional)
|
133
153
|
if lg.is_evening():
|
134
154
|
evenings = lg.leq_by_date(lg.get_period(data=lg.get_antilogs(), period="evenings"), cols=leq_cols)
|
135
155
|
evenings.sort_index(inplace=True)
|
136
|
-
|
137
|
-
|
156
|
+
period_blocks.append(evenings)
|
157
|
+
period_names.append("Evening")
|
138
158
|
|
139
159
|
# Night Leq
|
140
160
|
nights = lg.leq_by_date(lg.get_period(data=lg.get_antilogs(), period="nights"), cols=leq_cols)
|
141
161
|
nights.sort_index(inplace=True)
|
142
|
-
|
143
|
-
|
162
|
+
period_blocks.append(nights)
|
163
|
+
period_names.append("Night-time")
|
144
164
|
|
145
165
|
# Night max
|
146
166
|
maxes = lg.as_interval(t=lmax_t)
|
@@ -153,20 +173,23 @@ class Survey:
|
|
153
173
|
except Exception as e:
|
154
174
|
print(f"Error converting index to date: {e}")
|
155
175
|
maxes.index.name = None
|
156
|
-
|
157
|
-
|
176
|
+
period_blocks.append(maxes)
|
177
|
+
period_names.append("Night-time")
|
158
178
|
|
159
|
-
|
179
|
+
# Build Period as a proper column level to avoid manual header length mismatches
|
180
|
+
summary = pd.concat(objs=period_blocks, axis=1, keys=period_names, names=["Period"])
|
181
|
+
|
182
|
+
# Add the per-log super level (kept as before)
|
160
183
|
summary = self._insert_multiindex(df=summary, super=key)
|
161
|
-
combi = pd.concat(objs=[combi, summary], axis=0)
|
162
184
|
|
163
|
-
#
|
164
|
-
|
185
|
+
# Stack logs by rows; columns remain aligned across logs
|
186
|
+
combi = pd.concat(objs=[combi, summary], axis=0)
|
165
187
|
|
166
|
-
|
188
|
+
# No manual header insertion needed anymore; Period is already a column level
|
167
189
|
return combi
|
168
190
|
#test
|
169
191
|
def modal(self, cols=None, by_date=False, day_t="60min", evening_t="60min", night_t="15min"):
|
192
|
+
#TODO rename second level index so it is not 'date'
|
170
193
|
"""
|
171
194
|
Get a dataframe summarising Modal L90 values for each time period, as suggested by BS 4142:2014.
|
172
195
|
Currently, this method rounds the values to 0 decimal places by default and there is no alternative
|
@@ -493,43 +516,4 @@ class WeatherHistory:
|
|
493
516
|
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pycoustic\survey.py", line 328, in weather_summary
|
494
517
|
# return pd.DataFrame([self._weatherhist.min(), self._weatherhist.max(), self._weatherhist.mean()],
|
495
518
|
# ^^^^^^^^^^^^^^^^^^^^^^^
|
496
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\
|
497
|
-
# result = super().min(axis, skipna, numeric_only, **kwargs)
|
498
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
499
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\generic.py", line 12388, in min
|
500
|
-
# return self._stat_function(
|
501
|
-
# ^^^^^^^^^^^^^^^^^^^^
|
502
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\generic.py", line 12377, in _stat_function
|
503
|
-
# return self._reduce(
|
504
|
-
# ^^^^^^^^^^^^^
|
505
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\frame.py", line 11562, in _reduce
|
506
|
-
# res = df._mgr.reduce(blk_func)
|
507
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^
|
508
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\internals\managers.py", line 1500, in reduce
|
509
|
-
# nbs = blk.reduce(func)
|
510
|
-
# ^^^^^^^^^^^^^^^^
|
511
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\internals\blocks.py", line 404, in reduce
|
512
|
-
# result = func(self.values)
|
513
|
-
# ^^^^^^^^^^^^^^^^^
|
514
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\frame.py", line 11481, in blk_func
|
515
|
-
# return op(values, axis=axis, skipna=skipna, **kwds)
|
516
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
517
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\nanops.py", line 147, in f
|
518
|
-
# result = alt(values, axis=axis, skipna=skipna, **kwds)
|
519
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
520
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\nanops.py", line 404, in new_func
|
521
|
-
# result = func(values, axis=axis, skipna=skipna, mask=mask, **kwargs)
|
522
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
523
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\pandas\core\nanops.py", line 1098, in reduction
|
524
|
-
# result = getattr(values, meth)(axis)
|
525
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
526
|
-
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\numpy\_core\_methods.py", line 48, in _amin
|
527
|
-
# return umr_minimum(a, axis, None, out, keepdims, initial, where)
|
528
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
529
|
-
# TypeError: '<=' not supported between instances of 'dict' and 'dict'
|
530
|
-
|
531
|
-
|
532
|
-
#TODO: Fix this error:
|
533
|
-
#
|
534
|
-
# C:\Users\tonyr\PycharmProjects\pycoustic\pycoustic\survey.py:316: FutureWarning:
|
535
|
-
# The behavior of pd.concat with len(keys) != len(objs) is deprecated. In a future version this will raise instead of truncating to the smaller of the two sequences
|
519
|
+
# File "C:\Users\tonyr\PycharmProjects\pycoustic\.venv2\Lib\site-packages\
|
@@ -1,19 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: pycoustic
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.15
|
4
4
|
Summary:
|
5
5
|
Author: thumpercastle
|
6
6
|
Author-email: tony.ryb@gmail.com
|
7
|
-
Requires-Python: >=3.
|
7
|
+
Requires-Python: >=3.11,<=3.13
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
10
9
|
Classifier: Programming Language :: Python :: 3.11
|
11
10
|
Classifier: Programming Language :: Python :: 3.12
|
12
11
|
Classifier: Programming Language :: Python :: 3.13
|
13
12
|
Requires-Dist: numpy (==2.3.3)
|
14
13
|
Requires-Dist: openpyxl (==3.1.5)
|
15
14
|
Requires-Dist: pandas (==2.3.3)
|
16
|
-
Requires-Dist: plotly (
|
15
|
+
Requires-Dist: plotly (>=6.3.1,<7.0.0)
|
17
16
|
Requires-Dist: requests (>=2.32.4,<3.0.0)
|
18
17
|
Requires-Dist: streamlit (>=1.46.1,<2.0.0)
|
19
18
|
Description-Content-Type: text/markdown
|
@@ -1,9 +1,9 @@
|
|
1
1
|
pycoustic/__init__.py,sha256=jq9Tzc5nEgXh8eNf0AkAypmw3Dda9A-iSy-tyFaTksA,89
|
2
2
|
pycoustic/log.py,sha256=e8rAy9hIYP2H-3vTDVe0-6swe_n_gXjuFCu6Q-xNiYQ,17827
|
3
3
|
pycoustic/pycoustic_gui_app.py,sha256=Hs61Y8fAp7uoRONa4RLSVl0UvGXZZ96n5eJGilErlAU,11143
|
4
|
-
pycoustic/survey.py,sha256=
|
4
|
+
pycoustic/survey.py,sha256=yPOCNLaNJ85MhNN5ehWPWM5EQ_ixsE9Y3ikk84yIfTY,26154
|
5
5
|
pycoustic/tkgui.py,sha256=YAy5f_qkXZ3yU8BvB-nIVQX1fYwPs_IkwmDEXHPMAa4,13997
|
6
6
|
pycoustic/weather.py,sha256=q9FbDKjY0WaNvaYMHeDk7Bhbq0_Q7ehsTM_vUaCjeAk,3753
|
7
|
-
pycoustic-0.1.
|
8
|
-
pycoustic-0.1.
|
9
|
-
pycoustic-0.1.
|
7
|
+
pycoustic-0.1.15.dist-info/METADATA,sha256=T3GDJd8La3Bp2HJtl5qsM_eMc98EwNoru34KqZOJBAY,8472
|
8
|
+
pycoustic-0.1.15.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
9
|
+
pycoustic-0.1.15.dist-info/RECORD,,
|
File without changes
|