56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
import matplotlib.pyplot as plt
|
|
from scope_parser import parse_owon_data, parse_gwinstek_data
|
|
|
|
# Parse OWON data
|
|
print("=== OWON Data ===")
|
|
owon_data = parse_owon_data("Example Wave OWON.CSV")
|
|
ch1 = owon_data["CH1"]
|
|
print(f"Samples: {len(ch1.voltage_values)}")
|
|
print(f"Sample interval: {ch1.time_interval} s")
|
|
print(f"Frequency (approx): {ch1.frequency} Hz")
|
|
|
|
print()
|
|
|
|
# Parse Gwinstek data
|
|
print("=== Gwinstek Data ===")
|
|
gwinstek_data = parse_gwinstek_data("Example Wave Gwinstek.CSV")
|
|
ch1_gw = gwinstek_data["CH1"]
|
|
print(f"Samples: {len(ch1_gw.voltage_values)}")
|
|
print(f"Average: {ch1_gw.average:.6f} V")
|
|
|
|
# Plot both waveforms
|
|
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 8))
|
|
|
|
# OWON plot
|
|
ax1.plot(ch1.time_values * 1000, ch1.voltage_values * 1000, "b-", linewidth=0.8)
|
|
ax1.set_title("OWON Oscilloscope Data")
|
|
ax1.set_xlabel("Time (ms)")
|
|
ax1.set_ylabel("Voltage (mV)")
|
|
ax1.grid(True, alpha=0.3)
|
|
ax1.text(
|
|
0.02,
|
|
0.95,
|
|
f"Frequency: {ch1.frequency} Hz\nPeak-to-peak: {ch1.vpp*1000:.1f} mV",
|
|
transform=ax1.transAxes,
|
|
verticalalignment="top",
|
|
bbox=dict(boxstyle="round", facecolor="wheat", alpha=0.8),
|
|
)
|
|
|
|
# Gwinstek plot
|
|
ax2.plot(ch1_gw.time_values * 1000, ch1_gw.voltage_values, "r-", linewidth=0.8)
|
|
ax2.set_title("Gwinstek Oscilloscope Data")
|
|
ax2.set_xlabel("Time (ms)")
|
|
ax2.set_ylabel("Voltage (V)")
|
|
ax2.grid(True, alpha=0.3)
|
|
ax2.text(
|
|
0.02,
|
|
0.95,
|
|
f"Average: {ch1_gw.average:.3f} V\nRange: {ch1_gw.voltage_values.min():.3f} to {ch1_gw.voltage_values.max():.3f} V",
|
|
transform=ax2.transAxes,
|
|
verticalalignment="top",
|
|
bbox=dict(boxstyle="round", facecolor="lightcoral", alpha=0.8),
|
|
)
|
|
|
|
plt.tight_layout()
|
|
plt.show()
|