apmtools 0.2.35__tar.gz → 0.2.37__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.
- {apmtools-0.2.35 → apmtools-0.2.37}/PKG-INFO +1 -1
- {apmtools-0.2.35 → apmtools-0.2.37}/pyproject.toml +1 -1
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/classes.py +4 -4
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/data_processing.py +13 -4
- {apmtools-0.2.35 → apmtools-0.2.37}/.gitignore +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/LICENSE +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/README.md +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/__init__.py +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/functions.py +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/legacy.py +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/shiny/__init__.py +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/shiny/summary.py +0 -0
- {apmtools-0.2.35 → apmtools-0.2.37}/src/apmtools/units.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: apmtools
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.37
|
|
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>
|
|
@@ -449,7 +449,7 @@ class Dataset(DictionaryPlus):
|
|
|
449
449
|
a.filter_key = self.filter_key
|
|
450
450
|
return a
|
|
451
451
|
|
|
452
|
-
def scan_folder(self, directory="./", levels=[], level=0, monitor=None, levels_dict=None,
|
|
452
|
+
def scan_folder(self, directory="./", levels=[], level=0, monitor=None, levels_dict=None, utc_timezone_shift=0, interpolate=False, add_m={}):
|
|
453
453
|
|
|
454
454
|
from .data_processing import upas_processing, lascar_processing, purple_processing, lcm_processing
|
|
455
455
|
|
|
@@ -523,7 +523,7 @@ class Dataset(DictionaryPlus):
|
|
|
523
523
|
case "lcm":
|
|
524
524
|
try:
|
|
525
525
|
processed = lcm_processing(
|
|
526
|
-
directory, file=j, interpolate_data=interpolate)
|
|
526
|
+
directory, file=j, interpolate_data=interpolate, timezone_shift=timedelta(hours=utc_timezone_shift))
|
|
527
527
|
for k, v in levels_dict.items():
|
|
528
528
|
if (v not in ["None", "_", "-", None]) and (k not in ["monitor", "", None, "-", "_"]):
|
|
529
529
|
processed.m[k] = v
|
|
@@ -538,7 +538,7 @@ class Dataset(DictionaryPlus):
|
|
|
538
538
|
case "purple":
|
|
539
539
|
try:
|
|
540
540
|
processed = purple_processing(
|
|
541
|
-
f"{directory}/", timezone_shift=timedelta(hours=
|
|
541
|
+
f"{directory}/", timezone_shift=timedelta(hours=utc_timezone_shift), interpolate_data=interpolate)
|
|
542
542
|
for k, v in levels_dict.items():
|
|
543
543
|
if (v not in ["None", "_", "-", None]) and (k not in ["monitor", "", None, "-", "_"]):
|
|
544
544
|
processed.m[k] = v
|
|
@@ -564,7 +564,7 @@ class Dataset(DictionaryPlus):
|
|
|
564
564
|
if levels[r] not in levels[:level+1]:
|
|
565
565
|
levels_dict[levels[r]] = None
|
|
566
566
|
self.scan_folder(directory=f"{directory}{j}/", levels=levels,
|
|
567
|
-
level=level+1, monitor=monitor, levels_dict=levels_dict,
|
|
567
|
+
level=level+1, monitor=monitor, levels_dict=levels_dict, utc_timezone_shift=utc_timezone_shift, interpolate=interpolate, add_m=add_m)
|
|
568
568
|
|
|
569
569
|
def save_summary(self, save_csv=True, filename="./", columns={}, merged=True):
|
|
570
570
|
types_in = list(set(type(v) for v in self.values()))
|
|
@@ -308,6 +308,14 @@ def to_datetime(x):
|
|
|
308
308
|
':')[0]), int(x.split('T')[1].split(':')[1]), int(x.split('T')[1].split(':')[2][:-1])
|
|
309
309
|
return dt.datetime(year, month, day, hour, minute, second)
|
|
310
310
|
|
|
311
|
+
|
|
312
|
+
def to_datetime_lcm(x):
|
|
313
|
+
year, month, day = int(x.split('T')[0].split(
|
|
314
|
+
'-')[0]), int(x.split('T')[0].split('-')[1]), int(x.split('T')[0].split('-')[2])
|
|
315
|
+
hour, minute, second = int(x.split('T')[1].split(
|
|
316
|
+
':')[0]), int(x.split('T')[1].split(':')[1]), int(x.split('T')[1].split(':')[2].split(".")[0])
|
|
317
|
+
return dt.datetime(year, month, day, hour, minute, second)
|
|
318
|
+
|
|
311
319
|
def to_datetime_polar(x):
|
|
312
320
|
year, month, day = int(x.split('T')[0].split(
|
|
313
321
|
'-')[0]), int(x.split('T')[0].split('-')[1]), int(x.split('T')[0].split('-')[2])
|
|
@@ -842,15 +850,16 @@ def lascar_processing(directory, file, interpolation=1,interval="30 seconds", in
|
|
|
842
850
|
return out
|
|
843
851
|
|
|
844
852
|
|
|
845
|
-
def lcm_processing(directory, file, interpolation=1, interval="300 seconds", interpolate_data=True):
|
|
853
|
+
def lcm_processing(directory, file, interpolation=1, interval="300 seconds", interpolate_data=True, timezone_shift=dt.timedelta(hours=0)):
|
|
846
854
|
numeric = ["PM2.5", "PM10", "CO2", "NO2", "Temperature", "Humidity"]
|
|
847
|
-
|
|
848
|
-
df =
|
|
849
|
-
|
|
855
|
+
df = pd.read_csv(directory+file)
|
|
856
|
+
df['timestamp'] = df['timestamp'].map(to_datetime_lcm)
|
|
857
|
+
df.set_index('timestamp', inplace=True)
|
|
850
858
|
if interpolate_data:
|
|
851
859
|
df = interpolate(df, 300, interpolation, pd.Timedelta(
|
|
852
860
|
'00:06:00'), numeric_columns=numeric, add_binary_counter=False)
|
|
853
861
|
df = keep_interval(df, interval)
|
|
862
|
+
df.index = df.index + timezone_shift
|
|
854
863
|
out = Lcm(df)
|
|
855
864
|
return out
|
|
856
865
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|