|
|
@ -3,50 +3,25 @@ import datetime |
|
|
|
from services import io_services, log_services |
|
|
|
from services import io_services, log_services |
|
|
|
# import pdb |
|
|
|
# import pdb |
|
|
|
|
|
|
|
|
|
|
|
def tally_readings_per_second2(data): |
|
|
|
def tally_readings_per_second(data): |
|
|
|
time_tallies = dict() |
|
|
|
time_tallies = dict() |
|
|
|
for item in data: |
|
|
|
for item in data: |
|
|
|
# print(item[0]) |
|
|
|
|
|
|
|
key = item[0] |
|
|
|
key = item[0] |
|
|
|
if (key in time_tallies): |
|
|
|
if (key in time_tallies): |
|
|
|
time_tallies[key] = time_tallies[key] + 1 |
|
|
|
time_tallies[key] = time_tallies[key] + 1 |
|
|
|
# print(f"Updated {time_tallies[key]}") |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
time_tallies[key] = 1 |
|
|
|
time_tallies[key] = 1 |
|
|
|
#print(f"Added {time_tallies[key]}") |
|
|
|
|
|
|
|
return time_tallies |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tally_readings_per_second(): |
|
|
|
|
|
|
|
time_tallies = dict() |
|
|
|
|
|
|
|
with open("data/test-data-lite.csv") as csv_file: |
|
|
|
|
|
|
|
csv_reader = csv.reader(csv_file, delimiter=",") |
|
|
|
|
|
|
|
for r in csv_reader: |
|
|
|
|
|
|
|
if (r[1] != "Time Stamp"): |
|
|
|
|
|
|
|
time_str = r[1] |
|
|
|
|
|
|
|
if (time_str in time_tallies): |
|
|
|
|
|
|
|
time_tallies[time_str] = (time_tallies[time_str]) + 1 |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
time_tallies[time_str] = 1 |
|
|
|
|
|
|
|
return time_tallies |
|
|
|
return time_tallies |
|
|
|
|
|
|
|
|
|
|
|
def total_count_for_each_reading_per_second(time_tallies): |
|
|
|
def total_count_for_each_reading_per_second(time_tallies): |
|
|
|
tally_totals = dict() |
|
|
|
tally_totals = dict() |
|
|
|
# print(time_tallies) |
|
|
|
|
|
|
|
for val in time_tallies.values(): |
|
|
|
for val in time_tallies.values(): |
|
|
|
if (val in tally_totals): |
|
|
|
if (val in tally_totals): |
|
|
|
tally_totals[val] = (tally_totals[val]) + 1 |
|
|
|
tally_totals[val] = (tally_totals[val]) + 1 |
|
|
|
else: |
|
|
|
else: |
|
|
|
tally_totals[val] = 1 |
|
|
|
tally_totals[val] = 1 |
|
|
|
# print(tally_totals.items()) |
|
|
|
|
|
|
|
return tally_totals |
|
|
|
return tally_totals |
|
|
|
|
|
|
|
|
|
|
|
def save_rps_totals(totals): |
|
|
|
|
|
|
|
with open("data/results/readings-per-sec.csv", mode="w") as result: |
|
|
|
|
|
|
|
wtr = csv.writer(result) |
|
|
|
|
|
|
|
for k, v in totals.items(): |
|
|
|
|
|
|
|
# print(f"{k}: {v}") |
|
|
|
|
|
|
|
wtr.writerow([k,v]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_rps_above(threshold, readings): |
|
|
|
def get_rps_above(threshold, readings): |
|
|
|
times = list() |
|
|
|
times = list() |
|
|
|
# print(readings.values()) |
|
|
|
# print(readings.values()) |
|
|
@ -65,17 +40,17 @@ def tally_flickers(selected_readings, all_readings): |
|
|
|
return selected |
|
|
|
return selected |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
def main(): |
|
|
|
# raw_data = load_data() |
|
|
|
raw_data_path = "data/test-data-lite.csv" |
|
|
|
# time_tallies = tally_readings_per_second2(raw_data) |
|
|
|
rps_save_path ="data/results/readings-per-sec.csv" |
|
|
|
# # time_tallies = tally_readings_per_second() |
|
|
|
raw_data = io_services.load_raw_data(raw_data_path) |
|
|
|
# rps_totals = total_count_for_each_reading_per_second(time_tallies) |
|
|
|
# log_services.print_list(raw_data) |
|
|
|
# save_rps_totals(rps_totals) |
|
|
|
time_tallies = tally_readings_per_second(raw_data) |
|
|
|
|
|
|
|
# log_services.print_dictionary(time_tallies) |
|
|
|
|
|
|
|
rps_totals = total_count_for_each_reading_per_second(time_tallies) |
|
|
|
|
|
|
|
# log_services.print_dictionary(rps_totals) |
|
|
|
|
|
|
|
io_services.save_rps_totals(rps_totals, rps_save_path) |
|
|
|
# rsp_above_two = get_rps_above(2, time_tallies) |
|
|
|
# rsp_above_two = get_rps_above(2, time_tallies) |
|
|
|
# flicker_tallies = tally_flickers(rsp_above_two, time_tallies) |
|
|
|
# flicker_tallies = tally_flickers(rsp_above_two, time_tallies) |
|
|
|
raw_data = io_services.load_raw_data("data/test-data-lite.csv") |
|
|
|
|
|
|
|
# log_services.print_list(raw_data) |
|
|
|
|
|
|
|
time_tallies = tally_readings_per_second2(raw_data) |
|
|
|
|
|
|
|
log_services.print_dictionary(time_tallies) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
main() |
|
|
|
main() |
|
|
|