forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
30 lines
967 B
Python
30 lines
967 B
Python
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') |