nitypes.waveform.NumericWaveform
- class nitypes.waveform.NumericWaveform(sample_count: SupportsIndex | None = None, dtype: numpy.typing.DTypeLike = None, *, raw_data: numpy.typing.NDArray[_TRaw] | None = None, start_index: SupportsIndex | None = None, capacity: SupportsIndex | None = None, extended_properties: collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None = None, copy_extended_properties: bool = True, timing: nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None = None, scale_mode: nitypes.waveform.ScaleMode | None = None)
Bases:
abc.ABC,Generic[_TRaw,_TScaled]A numeric waveform, which encapsulates numeric data and timing information.
This is an abstract base class. To create a numeric waveform, use
AnalogWaveformorComplexWaveform.- Parameters:
sample_count (SupportsIndex | None)
dtype (numpy.typing.DTypeLike)
raw_data (numpy.typing.NDArray[_TRaw] | None)
start_index (SupportsIndex | None)
capacity (SupportsIndex | None)
extended_properties (collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None)
copy_extended_properties (bool)
timing (nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None)
scale_mode (nitypes.waveform.ScaleMode | None)
- classmethod from_array_1d(array: numpy.typing.NDArray[Any] | collections.abc.Sequence[Any], dtype: numpy.typing.DTypeLike = None, *, copy: bool = True, start_index: SupportsIndex | None = 0, sample_count: SupportsIndex | None = None, extended_properties: collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None = None, timing: nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None = None, scale_mode: nitypes.waveform.ScaleMode | None = None) typing_extensions.Self
Construct a waveform from a one-dimensional array or sequence.
- Parameters:
array (numpy.typing.NDArray[Any] | collections.abc.Sequence[Any]) – The waveform data as a one-dimensional array or a sequence.
dtype (numpy.typing.DTypeLike) – The NumPy data type for the waveform data. This argument is required when array is a sequence.
copy (bool) – Specifies whether to copy the array or save a reference to it.
start_index (SupportsIndex | None) – The sample index at which the waveform data begins.
sample_count (SupportsIndex | None) – The number of samples in the waveform.
extended_properties (collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None) – The extended properties of the waveform.
timing (nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None) – The timing information of the waveform.
scale_mode (nitypes.waveform.ScaleMode | None) – The scale mode of the waveform.
- Returns:
A waveform containing the specified data.
- Return type:
typing_extensions.Self
- classmethod from_array_2d(array: numpy.typing.NDArray[Any] | collections.abc.Sequence[collections.abc.Sequence[Any]], dtype: numpy.typing.DTypeLike = None, *, copy: bool = True, start_index: SupportsIndex | None = 0, sample_count: SupportsIndex | None = None, extended_properties: collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None = None, timing: nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None = None, scale_mode: nitypes.waveform.ScaleMode | None = None) collections.abc.Sequence[typing_extensions.Self]
Construct multiple waveforms from a two-dimensional array or nested sequence.
- Parameters:
array (numpy.typing.NDArray[Any] | collections.abc.Sequence[collections.abc.Sequence[Any]]) – The waveform data as a two-dimensional array or a nested sequence.
dtype (numpy.typing.DTypeLike) – The NumPy data type for the waveform data. This argument is required when array is a sequence.
copy (bool) – Specifies whether to copy the array or save a reference to it.
start_index (SupportsIndex | None) – The sample index at which the waveform data begins.
sample_count (SupportsIndex | None) – The number of samples in the waveform.
extended_properties (collections.abc.Mapping[str, nitypes.waveform.typing.ExtendedPropertyValue] | None) – The extended properties of the waveform.
timing (nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta] | None) – The timing information of the waveform.
scale_mode (nitypes.waveform.ScaleMode | None) – The scale mode of the waveform.
- Returns:
A sequence containing a waveform for each row of the specified data.
- Return type:
collections.abc.Sequence[typing_extensions.Self]
When constructing multiple waveforms, the same extended properties, timing information, and scale mode are applied to all waveforms. Consider assigning these properties after construction.
- __slots__ = ['_data', '_start_index', '_sample_count', '_extended_properties', '_timing', '_scale_mode',...
- property raw_data: numpy.typing.NDArray[_TRaw]
The raw waveform data.
- Return type:
numpy.typing.NDArray[_TRaw]
- get_raw_data(start_index: SupportsIndex | None = 0, sample_count: SupportsIndex | None = None) numpy.typing.NDArray[_TRaw]
Get a subset of the raw waveform data.
- Parameters:
start_index (SupportsIndex | None) – The sample index at which the data begins.
sample_count (SupportsIndex | None) – The number of samples to return.
- Returns:
A subset of the raw waveform data.
- Return type:
numpy.typing.NDArray[_TRaw]
- property scaled_data: numpy.typing.NDArray[_TScaled]
The scaled waveform data.
This property converts all of the waveform samples from the raw data type to the scaled data type and scales them using
scale_mode. To scale a subset of the waveform or scale to single-precision floating point, use theget_scaled_data()method instead.- Return type:
numpy.typing.NDArray[_TScaled]
- get_scaled_data(dtype: None = ..., *, start_index: SupportsIndex | None = ..., sample_count: SupportsIndex | None = ...) numpy.typing.NDArray[_TScaled]
- get_scaled_data(dtype: type[_TOtherScaled] | numpy.dtype[_TOtherScaled], *, start_index: SupportsIndex | None = ..., sample_count: SupportsIndex | None = ...) numpy.typing.NDArray[_TOtherScaled]
- get_scaled_data(dtype: numpy.typing.DTypeLike = ..., *, start_index: SupportsIndex | None = ..., sample_count: SupportsIndex | None = ...) numpy.typing.NDArray[Any]
Get a subset of the scaled waveform data with the specified dtype.
- Parameters:
dtype – The NumPy data type to use for scaled data.
start_index – The sample index at which to start scaling.
sample_count – The number of samples to scale.
- Returns:
A subset of the scaled waveform data.
- property start_index: int
The sample index of the underlying array at which the waveform data begins.
- Return type:
- property capacity: int
The total capacity available for waveform data.
Setting the capacity resizes the underlying NumPy array in-place.
Other Python objects with references to the array will see the array size change.
If the array has a reference to an external buffer (such as an array.array), attempting to resize it raises ValueError.
- Return type:
- property dtype: numpy.dtype[_TRaw]
The NumPy dtype for the waveform data.
- Return type:
numpy.dtype[_TRaw]
- property extended_properties: nitypes.waveform.ExtendedPropertyDictionary
The extended properties for the waveform.
Note
Data stored in the extended properties dictionary may not be encrypted when you send it over the network or write it to a TDMS file.
- Return type:
- property channel_name: str
The name of the device channel from which the waveform was acquired.
- Return type:
- property timing: nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta]
The timing information of the waveform.
The default value is Timing.empty.
- Return type:
nitypes.waveform.Timing[nitypes.time.typing.AnyDateTime, nitypes.time.typing.AnyTimeDelta, nitypes.time.typing.AnyTimeDelta]
- property scale_mode: nitypes.waveform.ScaleMode
The scale mode of the waveform.
- Return type:
- append(other: numpy.typing.NDArray[_TRaw] | NumericWaveform[_TRaw, _TScaled] | collections.abc.Sequence[NumericWaveform[_TRaw, _TScaled]], /, timestamps: collections.abc.Sequence[datetime.datetime] | collections.abc.Sequence[hightime.datetime] | None = None) None
Append data to the waveform.
- Parameters:
other (numpy.typing.NDArray[_TRaw] | NumericWaveform[_TRaw, _TScaled] | collections.abc.Sequence[NumericWaveform[_TRaw, _TScaled]]) – The array or waveform(s) to append.
timestamps (collections.abc.Sequence[datetime.datetime] | collections.abc.Sequence[hightime.datetime] | None) – A sequence of timestamps. When the current waveform has SampleIntervalMode.IRREGULAR, you must provide a sequence of timestamps with the same length as the array.
- Raises:
TimingMismatchError – The current and other waveforms have incompatible timing.
TimingMismatchWarning – The sample intervals of the waveform(s) do not match.
ScalingMismatchWarning – The scale modes of the waveform(s) do not match.
ValueError – The other array has the wrong number of dimensions or the length of the timestamps argument does not match the length of the other array.
TypeError – The data types of the current waveform and other array or waveform(s) do not match, or an argument has the wrong data type.
- Return type:
None
When appending waveforms:
Timing information is merged based on the sample interval mode of the current waveform:
SampleIntervalMode.NONE or SampleIntervalMode.REGULAR: The other waveform(s) must also have SampleIntervalMode.NONE or SampleIntervalMode.REGULAR. If the sample interval does not match, a TimingMismatchWarning is generated. Otherwise, the timing information of the other waveform(s) is discarded.
SampleIntervalMode.IRREGULAR: The other waveforms(s) must also have SampleIntervalMode.IRREGULAR. The timestamps of the other waveforms(s) are appended to the current waveform’s timing information.
Extended properties of the other waveform(s) are merged into the current waveform if they are not already set in the current waveform.
If the scale mode of other waveform(s) does not match the scale mode of the current waveform, a ScalingMismatchWarning is generated. Otherwise, the scaling information of the other waveform(s) is discarded.
- load_data(array: numpy.typing.NDArray[_TRaw], *, copy: bool = True, start_index: SupportsIndex | None = 0, sample_count: SupportsIndex | None = None) None
Load new data into an existing waveform.
- Parameters:
array (numpy.typing.NDArray[_TRaw]) – A NumPy array containing the data to load.
copy (bool) – Specifies whether to copy the array or save a reference to it.
start_index (SupportsIndex | None) – The sample index at which the waveform data begins.
sample_count (SupportsIndex | None) – The number of samples in the waveform.
- Return type:
None