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, source: Optional[str] = None, description: Optional[str] = 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 |
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 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'
|
Returns:
| Type | Description |
|---|---|
WaveformData
|
WaveformData object with time and voltage arrays |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If channel number is invalid |
CommandError
|
If acquisition fails |
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) -> 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
|
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)