Skip to content
Snippets Groups Projects
Commit ea2150a4 authored by wmalisch's avatar wmalisch
Browse files

Plotting scripts

parent 06b1162c
No related branches found
No related tags found
1 merge request!5Plotting scripts
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
File moved
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
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()
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment