Restructures. adds TimeSlice, ClearDupes and more comments.

This commit is contained in:
Michael Beck
2023-06-21 19:07:07 +02:00
parent 2e70d960a5
commit ea7fcc732e
7 changed files with 539 additions and 325 deletions

25
funs/ClearDupes.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Created on Wed Jun 21 13:58:42 2023
@author: michael
'''
def deDupe(inFile, outFile):
from collections import Counter
with open(inFile) as f:
lines = f.readlines()
count = Counter(lines)
dupes = [ k for (k,v) in count.items() if v > 1]
# uncomment to get duplicates
''' for dup in dupes:
print(f'Duplicate: {dup}', end='') '''
skips = []
outFileName = outFile
with open(outFile, 'w') as outFile:
for line in lines:
if line not in skips:
outFile.write(line)
if line not in skips and line in dupes:
skips.append(line)
print(f'{len(dupes)} duplicate Keywords removed and saved into {outFileName}.')

24
funs/TimeSlice.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Created on Wed Jun 21 13:58:42 2023
@author: michael
'''
# create slices
def get_Tslices(ts_beg, ts_end, no_slices):
from datetime import datetime
from datetime import timedelta
ts_beg = datetime.strptime(ts_beg, '%Y-%m-%dT%H:%M:%SZ')
ts_end = datetime.strptime(ts_end, '%Y-%m-%dT%H:%M:%SZ')
ts_dif = (ts_end - ts_beg) / no_slices
time_slices = []
for i in range(no_slices):
time_slices.append(
{
'beg_time': (ts_beg + ts_dif * i).strftime('%Y-%m-%dT%H:%M:%SZ'),
'end_time': (ts_beg + ts_dif * i + ts_dif - timedelta(microseconds=1)).strftime('%Y-%m-%dT%H:%M:%SZ'),
'suffix': f'-slice{i+1}'
})
return time_slices