Waveform¶
Waveform acquisition and data handling
Waveform acquisition and data processing for Siglent oscilloscopes.
WaveformData
dataclass
¶
WaveformData(time: ndarray, voltage: ndarray, channel: Union[int, str], sample_rate: Optional[float] = None, record_length: Optional[int] = None, timebase: Optional[float] = None, voltage_scale: Optional[float] = None, voltage_offset: float = 0.0, provenance: Optional[AcquisitionProvenance] = None)
Container for waveform data and metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
ndarray
|
Time values in seconds (numpy array) |
voltage |
ndarray
|
Voltage values in volts (numpy array) |
channel |
Union[int, str]
|
Source channel number |
sample_rate |
Optional[float]
|
Sampling rate in samples/second |
record_length |
Optional[int]
|
Number of samples |
timebase |
Optional[float]
|
Timebase setting (seconds/division) |
voltage_scale |
Optional[float]
|
Voltage scale (volts/division) |
voltage_offset |
float
|
Voltage offset in volts |
provenance |
Optional[AcquisitionProvenance]
|
Instrument settings snapshot at acquisition time (optional) |
Waveform
¶
Waveform acquisition and data processing.
Handles downloading waveform data from oscilloscope channels and converting to voltage/time arrays.
Initialize waveform acquisition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oscilloscope
|
Oscilloscope
|
Parent Oscilloscope instance |
required |
Source code in scpi_control/waveform.py
acquire
¶
acquire(channel: int, format: str = 'BYTE', provenance: bool = True, stride: Optional[int] = None) -> WaveformData
Acquire waveform data from a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
Channel number (1-4) |
required |
format
|
str
|
Data format - 'BYTE' or 'WORD' (default: 'BYTE') |
'BYTE'
|
provenance
|
bool
|
Snapshot instrument settings alongside the data (default True; pass False on high-rate paths) |
True
|
stride
|
Optional[int]
|
Forwarded to the transfer's acquire() -- see Oscilloscope.get_waveform for why None still writes 1 rather than skipping the write. |
None
|
Returns:
| Type | Description |
|---|---|
WaveformData
|
WaveformData object with time and voltage arrays |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If channel number is invalid |
CommandError
|
If acquisition fails |
FeatureNotSupportedError
|
If the active dialect's transfer doesn't support the requested format (e.g. 'WORD' on legacy Siglent or Tektronix) |
Source code in scpi_control/waveform.py
get_waveform_preamble
¶
Get waveform preamble information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
Channel number (1-4) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with waveform metadata |
Source code in scpi_control/waveform.py
save_waveform
¶
save_waveform(waveform: WaveformData, filename: str, format: Optional[str] = None, metadata: Optional[dict] = None, bare: bool = False) -> None
Save waveform data to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform
|
WaveformData
|
WaveformData object to save |
required |
filename
|
str
|
Output filename |
required |
format
|
Optional[str]
|
File format - 'CSV', 'CSV_ENHANCED', 'NPY', 'MAT', 'HDF5' If None, auto-detect from file extension |
None
|
metadata
|
Optional[dict]
|
Optional metadata dictionary to include in file |
None
|
bare
|
bool
|
CSV only: suppress the provenance comment header, reproducing the fully headerless legacy layout (default: False) |
False
|
Supported formats
- CSV: Simple CSV with time and voltage columns
- CSV_ENHANCED: CSV with metadata header
- NPY: NumPy compressed archive (.npz)
- MAT: MATLAB format (.mat) - requires scipy
- HDF5: HDF5 format (.h5, .hdf5) - requires h5py
Source code in scpi_control/waveform.py
See Also¶
- Oscilloscope - Main oscilloscope control class for SCPI communication
- Channel - Channel configuration and control
- Analysis - Signal analysis (FFT, THD, SNR)