forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Initial commit: PI_mikrokontroler changes
This commit is contained in:
30
firmware_adxl345_spi/Python3/test_adxl.py
Normal file
30
firmware_adxl345_spi/Python3/test_adxl.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
# Wczytanie danych z pominięciem komentarzy (pierwsze 4 linie)
|
||||
df = pd.read_csv('00000002.csv', comment='#')
|
||||
|
||||
# Obliczenie magnitudy
|
||||
df['magnitude'] = np.sqrt(df['x']**2 + df['y']**2 + df['z']**2)
|
||||
|
||||
# Przeliczenie czasu na względny (od 0)
|
||||
start_time = df['unix_ts'].min()
|
||||
df['relative_time'] = df['unix_ts'] - start_time
|
||||
|
||||
# Tworzenie wykresu
|
||||
fig, ax = plt.subplots(figsize=(12, 6))
|
||||
|
||||
for sensor_id in sorted(df['sensor_id'].unique()):
|
||||
sensor_data = df[df['sensor_id'] == sensor_id]
|
||||
ax.plot(sensor_data['relative_time'], sensor_data['magnitude'],
|
||||
label=f'Sensor {sensor_id}', linewidth=0.8, alpha=0.8)
|
||||
|
||||
ax.set_xlabel('Czas [s] (od startu)')
|
||||
ax.set_ylabel('Magnituda (jednostki surowe)')
|
||||
ax.set_title('Porównanie magnitudy przyspieszenia (Sensor 0 vs Sensor 1)')
|
||||
ax.legend()
|
||||
ax.grid(True, linestyle='--', alpha=0.7)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig('magnitude_comparison.png')
|
||||
Reference in New Issue
Block a user