diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f53dadbe1b0b5601d74c23781f61d87e72bd8c3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +contourpy==1.2.1 +cycler==0.12.1 +fonttools==4.51.0 +kiwisolver==1.4.5 +matplotlib==3.8.4 +numpy==1.26.4 +packaging==24.0 +pillow==10.3.0 +pyparsing==3.1.2 +python-dateutil==2.9.0.post0 +scipy==1.13.0 +six==1.16.0 diff --git a/src/PlotAllPlanes.py b/src/data-processing/PlotAllPlanes.py similarity index 100% rename from src/PlotAllPlanes.py rename to src/data-processing/PlotAllPlanes.py diff --git a/src/PlotVectorizedPlanes.py b/src/data-processing/PlotPeaks.py similarity index 62% rename from src/PlotVectorizedPlanes.py rename to src/data-processing/PlotPeaks.py index fe85a48ffa4b2ed75d5ea94a7a08bbaea5369343..d164eeb719b59561e80c653575b0ae2b3438e5d4 100644 --- a/src/PlotVectorizedPlanes.py +++ b/src/data-processing/PlotPeaks.py @@ -1,8 +1,8 @@ import numpy as np import matplotlib.pyplot as plt +from scipy.signal import find_peaks import csv -# Initialize list to store magnitudes magnitudes = [] with open('outputs/vectorized_data.csv', 'r') as file: @@ -17,12 +17,13 @@ with open('outputs/vectorized_data.csv', 'r') as file: # Convert magnitudes list to numpy array magnitudes = np.array(magnitudes) -# Plot magnitudes -plt.figure(figsize=(10, 6)) # Adjust the figure size as needed -plt.plot(magnitudes, label='Magnitude') +peaks, _ = find_peaks(magnitudes) + +plt.plot(magnitudes) +plt.plot(peaks, magnitudes[peaks], "x", color='red') plt.xlabel('Index') -plt.ylabel('Magnitude') -plt.title('Magnitude from vectorized_data.csv') -plt.legend() -plt.grid(True) -plt.show() \ No newline at end of file +plt.ylabel('Acceleration Magnitude') +plt.title('Acceleration Magnitude with Peaks') +plt.show() + +print("Indices of the peaks:", peaks) \ No newline at end of file diff --git a/src/data-processing/PlotVectorizedPlanes.py b/src/data-processing/PlotVectorizedPlanes.py new file mode 100644 index 0000000000000000000000000000000000000000..7a0cce2a800651567a068b47edb56c02e6ce8659 --- /dev/null +++ b/src/data-processing/PlotVectorizedPlanes.py @@ -0,0 +1,42 @@ +import numpy as np +import matplotlib.pyplot as plt +import csv + +# Initialize list to store magnitudes +magnitudes = [] + +with open('outputs/vectorized_data.csv', 'r') as file: + reader = csv.reader(file) + next(reader) # Skip the header row + for row in reader: + # Extract magnitude value from each row + mag = float(row[0]) + # Append magnitude to the list + magnitudes.append(mag) + +# Convert magnitudes list to numpy array +magnitudes = np.array(magnitudes) + +mean_value = np.mean(magnitudes) +std_dev = np.std(magnitudes) + +# Plot magnitudes +plt.figure(figsize=(10, 6)) # Adjust the figure size as needed +plt.plot(magnitudes, label='Magnitude') +plt.xlabel('Index') +plt.ylabel('Magnitude') +plt.title('Magnitude from vectorized_data.csv') + +# Plot mean and standard deviation lines +plt.axhline(mean_value, color='r', linestyle='--', label='Mean') +plt.axhline(mean_value + std_dev*1.5, color='g', linestyle='--', label='Mean + StdDev') +plt.axhline(mean_value - std_dev*1.5, color='g', linestyle='--', label='Mean - StdDev') + +# Annotate mean and standard deviation values +plt.text(0.5, mean_value, f'Mean: {mean_value:.2f}', color='r', fontsize=10, va='center', ha='left') +plt.text(0.5, mean_value + std_dev, f'Standard Deviation: {std_dev:.2f}', color='g', fontsize=10, va='center', ha='left') +plt.text(0.5, mean_value - std_dev, f'Standard Deviation: {std_dev:.2f}', color='g', fontsize=10, va='center', ha='left') + +plt.legend() +plt.grid(True) +plt.show() diff --git a/src/data-processing/Vectorize.py b/src/data-processing/Vectorize.py new file mode 100644 index 0000000000000000000000000000000000000000..a515c0258c28e636df4f577005375ca722b54e02 --- /dev/null +++ b/src/data-processing/Vectorize.py @@ -0,0 +1,27 @@ +import numpy as np +import matplotlib.pyplot as plt +import csv + +# Initialize list to store magnitudes +magnitudes = [] + +# Open and read the CSV file +with open('outputs/1714090197.csv', 'r') as file: + reader = csv.reader(file) + + for row in reader: + # Extract x, y, and z values from each row + x, y, z = float(row[0]), float(row[1]), float(row[2]) + + # Calculate magnitude using the provided algorithm + mag = np.sqrt(x**2 + y**2 + z**2) + + # Append magnitude to the list + magnitudes.append(mag) + +magnitudes = np.array(magnitudes) + +with open('outputs/vectorized_data.csv', 'w', newline='') as file: + writer = csv.writer(file) + for mag in magnitudes: + writer.writerow([mag]) \ No newline at end of file