Skip to content

Commit f67d6e7

Browse files
author
Jakub Sliacan
committed
Mostly refactor to read FIT file (not radar)
1 parent 8e551bb commit f67d6e7

File tree

4 files changed

+482
-324
lines changed

4 files changed

+482
-324
lines changed

__main__.py

+34-7
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
from src import box, constants, util
1717
from src import modularity as mod
1818

19-
dflist = util.get_box_files(constants.DATA_HOME)
19+
dflist = util.get_box_files(constants.DATA_HOME, "txt")
2020
util.ensure_date_in_filenames(dflist)
21-
dflist = util.get_box_files(constants.DATA_HOME)
21+
dflist = util.get_box_files(constants.DATA_HOME, "txt")
2222

2323
ot_events = []
2424
lds = []
25+
total_num_OC = 0
2526

2627
for csv_file in dflist:
2728
print(csv_file, flush=True)
@@ -32,7 +33,11 @@
3233
ldata = box.make_ldata(csvr) # CSV data as a list
3334
# presses
3435
press_starts, press_lengths = box.get_press_lengths_and_starts(ldata)
35-
36+
37+
for pl in press_lengths:
38+
if pl < 10:
39+
total_num_OC += 1
40+
3641
b_partitions, a_partitions, b_modularities, a_modularities = mod.get_partitions(ldata, press_starts, press_lengths)
3742

3843
for j, b_parts in enumerate(b_partitions):
@@ -107,7 +112,7 @@
107112
plt.clf()
108113

109114
print("Number of OT events:", len(ot_events))
110-
115+
print("Number of Oncoming:", total_num_OC)
111116
lds_trimmed_means = [stats.trim_mean(ld, 0.1)-20 for ld in lds]
112117
lds_trimmed_mins = []
113118
for ld in lds:
@@ -358,18 +363,40 @@
358363
# plt.legend(loc='upper right')
359364
# plt.savefig("figures/OT-vs-OC_events-hist.png")
360365
"""
366+
367+
"""
368+
# -------------------------- TEST fit.py ----------------------------
369+
import datetime
370+
from src import fit, util, constants
371+
filenames_list = util.get_box_files(constants.DATA_HOME, "fit")
372+
373+
ride_durations_wahoo = []
374+
ride_distances_wahoo = []
375+
376+
for filename in filenames_list:
377+
print(filename)
378+
msgs = fit.fit_file_messages(filename)
379+
session = fit.fit_get_session(msgs)
380+
if "Wahoo" in filename:
381+
ride_durations_wahoo.append(session[0]["total_elapsed_time"])
382+
ride_distances_wahoo.append(session[0]["total_distance"])
383+
384+
385+
print("total durations (wahoo):", str(datetime.timedelta(seconds = sum(ride_durations_wahoo))))
386+
print("total distances (wahoo):", sum(ride_distances_wahoo))
387+
"""
361388
"""
362389
# -------------------------- TEST radar.py ----------------------------
363390
from src import radar
364391
#radar.radar_decode()
365392
all_events = radar.radar_unload()
366-
# radar.radar_events_to_csv("radar_out.csv", all_events)
367-
radar.plot_radar_data()
393+
radar.radar_events_to_csv("radar_out.csv", all_events)
394+
#radar.plot_radar_data()
368395
"""
369396
"""
370397
# -------------------------- TEST util.py ----------------------------
371398
372-
for f in util.get_box_files(constants.DATA_HOME):
399+
for f in util.get_box_files(constants.DATA_HOME, "TXT"):
373400
print(f)
374401
375402
print()

0 commit comments

Comments
 (0)