Inital version
This commit is contained in:
4016
examples/Example Wave Gwinstek.CSV
Normal file
4016
examples/Example Wave Gwinstek.CSV
Normal file
File diff suppressed because it is too large
Load Diff
4011
examples/Example Wave OWON.CSV
Normal file
4011
examples/Example Wave OWON.CSV
Normal file
File diff suppressed because it is too large
Load Diff
55
examples/example_usage.py
Normal file
55
examples/example_usage.py
Normal file
@@ -0,0 +1,55 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user