pycoustic 0.1.15__tar.gz → 0.1.16__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pycoustic
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary:
5
5
  Author: thumpercastle
6
6
  Author-email: tony.ryb@gmail.com
@@ -18,8 +18,8 @@ class Log:
18
18
  path,
19
19
  index_col="Time",
20
20
  parse_dates=["Time"],
21
- date_format="%Y/%m/%d %H:%M", # Explicit format to avoid the dayfirst warning
22
- # dayfirst=False, # Optional: include for clarity; default is False
21
+ date_format="%d/%m/%Y %H:%M", # Explicit format to avoid the dayfirst warning
22
+ dayfirst=True, # Optional: include for clarity; default is False
23
23
  )
24
24
  self._master.index = pd.to_datetime(self._master.index)
25
25
  self._master = self._master.sort_index(axis=1)
@@ -317,30 +317,71 @@ class Survey:
317
317
  For all Leq columns, use ["Leq"]. For specific columns, use list of tuples [("Leq", "A"), ("Leq", 125)]
318
318
  :return: A dataframe with a continuous Leq computation across dates, for each time period.
319
319
  """
320
- #TODO: C:\Users\tonyr\PycharmProjects\pycoustic\tests.py:674: FutureWarning: 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 combi = pd.concat(all_pos, axis=1, keys=["UA1", "UA2"])
321
320
  all_pos = []
321
+ labels = []
322
+
322
323
  if leq_cols is None:
323
324
  leq_cols = ["Leq"]
324
- for key in self._logs.keys():
325
- log = self._logs[key]
325
+
326
+ for label, log in self._logs.items():
326
327
  # Day
327
328
  days = log.get_period(data=log.get_antilogs(), period="days")
328
- days = days[leq_cols].apply(lambda x: np.round(10*np.log10(np.mean(x)), DECIMALS))
329
+ days = days[leq_cols].apply(lambda x: np.round(10 * np.log10(np.mean(x)), DECIMALS))
330
+
329
331
  # Night-time
330
332
  nights = log.get_period(data=log.get_antilogs(), period="nights")
331
- nights = nights[leq_cols].apply(lambda x: np.round(10*np.log10(np.mean(x)), DECIMALS))
332
- df = pd.DataFrame
333
- # Evening
333
+ nights = nights[leq_cols].apply(lambda x: np.round(10 * np.log10(np.mean(x)), DECIMALS))
334
+
335
+ # Evening (if applicable)
334
336
  if log.is_evening():
335
337
  evenings = log.get_period(data=log.get_antilogs(), period="evenings")
336
338
  evenings = evenings[leq_cols].apply(lambda x: np.round(10 * np.log10(np.mean(x)), DECIMALS))
337
339
  df = pd.concat([days, evenings, nights], axis=1, keys=["Daytime", "Evening", "Night-time"])
338
340
  else:
339
341
  df = pd.concat([days, nights], axis=1, keys=["Daytime", "Night-time"])
342
+
340
343
  all_pos.append(df)
341
- combi = pd.concat(all_pos, axis=1, keys=["UA1", "UA2"])
342
- combi = combi.transpose()
343
- return combi
344
+ labels.append(label)
345
+
346
+ if not all_pos:
347
+ return pd.DataFrame()
348
+
349
+ # Concatenate across logs; keys match number of objects (no FutureWarning)
350
+ combi = pd.concat(all_pos, axis=1, keys=labels)
351
+ return combi.transpose()
352
+ #
353
+ # def leq_spectra(self, leq_cols=None):
354
+ # """
355
+ # Compute Leqs over daytime, evening and night-time periods.
356
+ # This is an overall Leq, and does not group Leqs by date.
357
+ # :param leq_cols: List of strings or List of Tuples.
358
+ # For all Leq columns, use ["Leq"]. For specific columns, use list of tuples [("Leq", "A"), ("Leq", 125)]
359
+ # :return: A dataframe with a continuous Leq computation across dates, for each time period.
360
+ # """
361
+ # #TODO: C:\Users\tonyr\PycharmProjects\pycoustic\tests.py:674: FutureWarning: 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 combi = pd.concat(all_pos, axis=1, keys=["UA1", "UA2"])
362
+ # all_pos = []
363
+ # if leq_cols is None:
364
+ # leq_cols = ["Leq"]
365
+ # for key in self._logs.keys():
366
+ # log = self._logs[key]
367
+ # # Day
368
+ # days = log.get_period(data=log.get_antilogs(), period="days")
369
+ # days = days[leq_cols].apply(lambda x: np.round(10*np.log10(np.mean(x)), DECIMALS))
370
+ # # Night-time
371
+ # nights = log.get_period(data=log.get_antilogs(), period="nights")
372
+ # nights = nights[leq_cols].apply(lambda x: np.round(10*np.log10(np.mean(x)), DECIMALS))
373
+ # df = pd.DataFrame
374
+ # # Evening
375
+ # if log.is_evening():
376
+ # evenings = log.get_period(data=log.get_antilogs(), period="evenings")
377
+ # evenings = evenings[leq_cols].apply(lambda x: np.round(10 * np.log10(np.mean(x)), DECIMALS))
378
+ # df = pd.concat([days, evenings, nights], axis=1, keys=["Daytime", "Evening", "Night-time"])
379
+ # else:
380
+ # df = pd.concat([days, nights], axis=1, keys=["Daytime", "Night-time"])
381
+ # all_pos.append(df)
382
+ # combi = pd.concat(all_pos, axis=1, keys=["UA1", "UA2"])
383
+ # combi = combi.transpose()
384
+ # return combi
344
385
 
345
386
  def get_start_end(self):
346
387
  starts = [self._logs[key].get_start() for key in self._logs.keys()]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pycoustic"
3
- version = "0.1.15"
3
+ version = "0.1.16"
4
4
  description = ""
5
5
  authors = ["thumpercastle <tony.ryb@gmail.com>"]
6
6
  readme = "README.md"
File without changes