You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
3 years ago
|
def tally_readings_per_second(data):
|
||
|
time_tallies = dict()
|
||
|
for item in data:
|
||
|
key = item[0]
|
||
|
if (key in time_tallies):
|
||
|
time_tallies[key] = time_tallies[key] + 1
|
||
|
else:
|
||
|
time_tallies[key] = 1
|
||
|
return time_tallies
|
||
|
|
||
|
def total_count_for_each_reading_per_second(time_tallies):
|
||
|
tally_totals = dict()
|
||
|
for val in time_tallies.values():
|
||
|
if (val in tally_totals):
|
||
|
tally_totals[val] = (tally_totals[val]) + 1
|
||
|
else:
|
||
|
tally_totals[val] = 1
|
||
|
return tally_totals
|
||
|
|
||
|
def get_rps_above(threshold, readings):
|
||
|
times = list()
|
||
|
for k, v in readings.items():
|
||
|
if (v >= threshold):
|
||
|
times.append(k)
|
||
|
return times
|
||
|
|
||
|
def find_flickers(selected_readings, all_readings):
|
||
|
selected = dict()
|
||
|
for current_selected_reading in selected_readings:
|
||
|
readings = list()
|
||
|
for current_reading in all_readings:
|
||
|
if (current_selected_reading == current_reading[0]):
|
||
|
readings.append(current_reading[1])
|
||
|
selected[current_selected_reading] = readings
|
||
|
return selected
|
||
|
|
||
|
def find_readings_with_lights_on(flicker_entries):
|
||
|
filtered_readings = list()
|
||
|
add_to_list = False
|
||
|
for time, reading in flicker_entries.items():
|
||
|
for item in reading:
|
||
|
val = int(item)
|
||
|
if (val > 39):
|
||
|
add_to_list = True
|
||
|
break
|
||
|
else:
|
||
|
add_to_list = False
|
||
|
if (add_to_list == True):
|
||
|
filtered_readings.append( (time, reading) )
|
||
|
return filtered_readings
|