fix(data): Fix pool mapping to include undamaged case and add csv header separator line for Excel compatibility
This commit is contained in:
@@ -25,9 +25,9 @@ def create_ready_data(
|
|||||||
"""
|
"""
|
||||||
ready_data = []
|
ready_data = []
|
||||||
for file in os.listdir(stft_data_path):
|
for file in os.listdir(stft_data_path):
|
||||||
ready_data.append(pd.read_csv(os.path.join(stft_data_path, file)))
|
ready_data.append(pd.read_csv(os.path.join(stft_data_path, file), skiprows=1))
|
||||||
|
|
||||||
y_data = [i for i in range(len(ready_data))]
|
y_data = [i for i in range(len(ready_data))] # TODO: Should be replaced with actual desired labels
|
||||||
|
|
||||||
# Combine all dataframes in ready_data into a single dataframe
|
# Combine all dataframes in ready_data into a single dataframe
|
||||||
if ready_data: # Check if the list is not empty
|
if ready_data: # Check if the list is not empty
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import glob
|
|||||||
import multiprocessing # Added import for multiprocessing
|
import multiprocessing # Added import for multiprocessing
|
||||||
|
|
||||||
# Define the base directory where DAMAGE_X folders are located
|
# Define the base directory where DAMAGE_X folders are located
|
||||||
damage_base_path = 'D:/thesis/data/converted/raw'
|
damage_base_path = 'D:/thesis/data/converted/raw_B'
|
||||||
|
|
||||||
# Define output directories for each sensor
|
# Define output directories for each sensor
|
||||||
output_dirs = {
|
output_dirs = {
|
||||||
@@ -105,6 +105,8 @@ def process_damage_case(damage_num):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Save the aggregated STFT to CSV
|
# Save the aggregated STFT to CSV
|
||||||
|
with open(output_file, 'w') as file:
|
||||||
|
file.write('sep=,\n')
|
||||||
df_aggregated.to_csv(output_file, index=False)
|
df_aggregated.to_csv(output_file, index=False)
|
||||||
print(f"Saved aggregated STFT for Sensor {sensor_num}, Damage {damage_num} to {output_file}")
|
print(f"Saved aggregated STFT for Sensor {sensor_num}, Damage {damage_num} to {output_file}")
|
||||||
else:
|
else:
|
||||||
@@ -112,4 +114,4 @@ def process_damage_case(damage_num):
|
|||||||
|
|
||||||
if __name__ == "__main__": # Added main guard for multiprocessing
|
if __name__ == "__main__": # Added main guard for multiprocessing
|
||||||
with multiprocessing.Pool() as pool:
|
with multiprocessing.Pool() as pool:
|
||||||
pool.map(process_damage_case, range(1, num_damage_cases + 1))
|
pool.map(process_damage_case, range(0, num_damage_cases + 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user