Skip to content

Commit 6e78002

Browse files
committed
Refactorign method position.
1 parent d41600c commit 6e78002

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

PostProcessing/PostProcessVideos.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,9 @@
88

99
from pathlib import Path
1010

11+
from dataframes import compute_time_range, trim_into_interval
1112

12-
THRESHOLD_NS = 10 * 1000
13-
14-
15-
def compute_time_range(dfs):
16-
# Find the lowest and highest numbers in all the data frames
17-
min_common = max(df.iloc[:,0].min() for df in dfs)
18-
max_common = min(df.iloc[:,0].max() for df in dfs)
19-
20-
# Print the results
21-
print(f"The lowest common number is {min_common}")
22-
print(f"The highest common number is {max_common}")
23-
24-
return (min_common, max_common)
25-
26-
27-
def trim_into_interval(csv_path, dfs, min_common, max_common):
28-
# Trim each data frame to the min_common and max_common interval and save to a new file
29-
for i, df in enumerate(dfs):
30-
df_trimmed = df[(df.iloc[:,0] >= min_common) & (df.iloc[:,0] <= max_common)]
31-
df_trimmed.to_csv(f"{csv_path}trimmed_df_{i+1}.csv", header=False, index=False)
32-
33-
# Print the results
34-
print(f"{len(dfs)} data frames trimmed and saved to {csv_path}")
13+
THRESHOLD_NS = 10 * 1000 * 1000
3514

3615

3716
def extract(input_dir, output_dir):

PostProcessing/dataframes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,24 @@
44
def repair_dropped_frames(df: pd.DataFrame) -> pd.DataFrame:
55
pass
66

7+
8+
def compute_time_range(dfs):
9+
# Find the lowest and highest numbers in all the data frames
10+
min_common = max(df.iloc[:,0].min() for df in dfs)
11+
max_common = min(df.iloc[:,0].max() for df in dfs)
12+
13+
# Print the results
14+
print(f"The lowest common number is {min_common}")
15+
print(f"The highest common number is {max_common}")
16+
17+
return (min_common, max_common)
18+
19+
20+
def trim_into_interval(csv_path, dfs, min_common, max_common):
21+
# Trim each data frame to the min_common and max_common interval and save to a new file
22+
for i, df in enumerate(dfs):
23+
df_trimmed = df[(df.iloc[:,0] >= min_common) & (df.iloc[:,0] <= max_common)]
24+
df_trimmed.to_csv(f"{csv_path}trimmed_df_{i+1}.csv", header=False, index=False)
25+
26+
# Print the results
27+
print(f"{len(dfs)} data frames trimmed and saved to {csv_path}")

0 commit comments

Comments
 (0)