apmtools 0.2.42__tar.gz → 0.2.44__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.5
2
2
  Name: apmtools
3
- Version: 0.2.42
3
+ Version: 0.2.44
4
4
  Summary: A collection of tools for processing air pollution monitoring data
5
5
  Project-URL: Homepage, https://github.com/federlorenz/apmtools
6
6
  Author-email: Federico Lorenzetti <lorenzetti.federico@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "apmtools"
7
- version = "0.2.42"
7
+ version = "0.2.44"
8
8
  authors = [
9
9
  { name="Federico Lorenzetti", email="lorenzetti.federico@gmail.com" },
10
10
  ]
@@ -257,6 +257,7 @@ class Dataset(DictionaryPlus):
257
257
  def __init__(self, *args, **kwargs):
258
258
  DictionaryPlus.__init__(self, *args, **kwargs)
259
259
  self.filter_key = None
260
+ self.description = ""
260
261
 
261
262
  @property
262
263
  def _constructor(self):
@@ -285,6 +286,7 @@ class Dataset(DictionaryPlus):
285
286
  if verbose:
286
287
  print(key)
287
288
  a.filter_key = self.filter_key
289
+ a.description = self.description + f"\n Applied function {func}"
288
290
  return a
289
291
 
290
292
  def subset(self, filter_dict={}, filter_style='all', condition=None):
@@ -435,6 +437,8 @@ class Dataset(DictionaryPlus):
435
437
  a[key] = value
436
438
  a = Dataset(a)
437
439
  a.filter_key = self.filter_key
440
+ a.description = self.description + \
441
+ f"\nSubset by {filter_dict} on style {filter_style} by condition {condition}"
438
442
  return a
439
443
  else:
440
444
  b = {}
@@ -443,10 +447,14 @@ class Dataset(DictionaryPlus):
443
447
  b[key] = value
444
448
  b = Dataset(b)
445
449
  b.filter_key = self.filter_key
450
+ b.description = self.description + \
451
+ f"\nSubset by {filter_dict} on style {filter_style} by condition {condition}"
446
452
  return b
447
453
  else:
448
454
  a = Dataset(a)
449
455
  a.filter_key = self.filter_key
456
+ a.description = self.description + \
457
+ f"\nSubset by {filter_dict} on style {filter_style} by condition {condition}"
450
458
  return a
451
459
 
452
460
  def scan_folder(self, directory="./", levels=[], level=0, monitor=None, levels_dict=None, utc_timezone_shift=0, interpolate=False, add_m={}):
@@ -1026,16 +1034,18 @@ class Summary(pd.DataFrame):
1026
1034
  def _constructor(self):
1027
1035
  return Summary
1028
1036
 
1029
- def __init__(self, *args, metadata=set(), variable=None, **kwargs):
1037
+ def __init__(self, *args, metadata=set(), variable=None, description="",**kwargs):
1030
1038
  pd.DataFrame.__init__(self, *args, **kwargs)
1031
1039
 
1032
1040
  self.metadata = metadata
1033
1041
  self.variable = variable
1042
+ self.description = description
1034
1043
 
1035
1044
  def __finalize__(self, other, method=None, **kwargs):
1036
1045
  if isinstance(other, Summary):
1037
1046
  self.variable = other.variable
1038
1047
  self.metadata = other.metadata.copy()
1048
+ self.description = other.description
1039
1049
 
1040
1050
  return self
1041
1051
 
@@ -1070,6 +1080,7 @@ class Summary(pd.DataFrame):
1070
1080
  if filter_style not in {'all', 'any', 'negative all', 'negative any'}:
1071
1081
  return return_dict
1072
1082
 
1083
+
1073
1084
  # Only conditions referring to existing columns can be evaluated.
1074
1085
  conditions = []
1075
1086
  for column, values in filter_dict.items():
@@ -1091,6 +1102,8 @@ class Summary(pd.DataFrame):
1091
1102
  mask = (~conditions).all(axis=0).to_numpy()
1092
1103
  else: # negative any
1093
1104
  mask = (~conditions).any(axis=0).to_numpy()
1105
+
1106
+ return_dict.description = self.description + f"\nSubset by {filter_dict} on style {filter_style}"
1094
1107
 
1095
1108
  return return_dict.loc[mask]
1096
1109
 
@@ -1152,6 +1165,9 @@ class Summary(pd.DataFrame):
1152
1165
  if day is not None:
1153
1166
  self = self.loc[[a in day for a in [self["datetime"].map(lambda x: x.date().isoweekday())
1154
1167
  for i in range(len(self["datetime"]))]]]
1168
+
1169
+ self.description = self.description + \
1170
+ f"\nFiltered by {time_start if time_start != None else ""} till {time_end if time_end != None else ""}, {date_start if date_start != None else ""} till {date_end if date_end != None else ""}, {day if day != None else ""}"
1155
1171
  return self.reset_index()
1156
1172
 
1157
1173
  def set_attrib(self, attribute):
File without changes
File without changes
File without changes