niscope module
Installation
As a prerequisite to using the niscope module, you must install the NI-SCOPE runtime on your system. Visit ni.com/downloads to download the driver runtime for your devices.
The nimi-python modules (i.e. for NI-SCOPE) can be installed with pip:
$ python -m pip install niscope~=1.4.5
Usage
The following is a basic example of using the niscope module to open a session to a High Speed Digitizer and capture a single record of 1000 points.
import niscope
with niscope.Session("Dev1") as session:
session.channels[0].configure_vertical(range=1.0, coupling=niscope.VerticalCoupling.AC)
session.channels[1].configure_vertical(range=10.0, coupling=niscope.VerticalCoupling.DC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=1000, ref_position=50.0, num_records=5, enforce_realtime=True)
with session.initiate():
waveforms = session.channels[0,1].fetch(num_records=5)
for wfm in waveforms:
print('Channel {0}, record {1} samples acquired: {2:,}\n'.format(wfm.channel, wfm.record, len(wfm.samples)))
# Find all channel 1 records (Note channel name is always a string even if integers used in channel[])
chan1 = [wfm for wfm in waveforms if wfm.channel == '0']
# Find all record number 3
rec3 = [wfm for wfm in waveforms if wfm.record == 3]
The waveform returned from fetch is a flat list of Python objects
Attributes:
relative_initial_x (float) the time (in seconds) from the trigger to the first sample in the fetched waveform
absolute_initial_x (float) timestamp (in seconds) of the first fetched sample. This timestamp is comparable between records and acquisitions; devices that do not support this parameter use 0 for this output.
x_increment (float) the time between points in the acquired waveform in seconds
channel (str) channel name this waveform was acquired from
record (int) record number of this waveform
gain (float) the gain factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
offset (float) the offset factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
samples (array of float) floating point array of samples. Length will be of the actual samples acquired
Such that all record 0 waveforms are first. For example, with a channel list of 0,1, you would have the following index values:
index 0 = record 0, channel 0
index 1 = record 0, channel 1
index 2 = record 1, channel 0
index 3 = record 1, channel 1
etc.
If you need more performance or need to work with SciPy, you can use the fetch_into() method instead of fetch(). This method takes an already allocated numpy array and puts the acquired samples in it. Data types supported:
numpy.float64
numpy.int8
numpy.in16
numpy.int32
voltage_range = 1.0
record_length = 2000
channels = [0, 1]
num_channels = len(channels)
num_records = 5
wfm = numpy.ndarray(num_channels * record_length, dtype=numpy.int8)
session.configure_vertical(voltage_range, niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(50000000, record_length, 50.0, num_records, True)
with session.initiate():
waveform_infos = session.channels[channels].fetch_into(wfm=wfm, num_records=num_records)
The waveform_infos returned from fetch_into is a 1D list of Python objects
Attributes:
relative_initial_x (float) the time (in seconds) from the trigger to the first sample in the fetched waveform
absolute_initial_x (float) timestamp (in seconds) of the first fetched sample. This timestamp is comparable between records and acquisitions; devices that do not support this parameter use 0 for this output.
x_increment (float) the time between points in the acquired waveform in seconds
channel (str) channel name this waveform was asquire from
record (int) record number of this waveform
gain (float) the gain factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
offset (float) the offset factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
samples (numpy array of datatype used) floating point array of samples. Length will be of the actual samples acquired
Such that all record 0 waveforms are first. For example, with a channel list of 0,1, you would have the following index values:
index 0 = record 0, channel 0
index 1 = record 0, channel 1
index 2 = record 1, channel 0
index 3 = record 1, channel 1
etc.
API Reference
- Session
- Methods
- abort
- acquisition_status
- add_waveform_processing
- auto_setup
- clear_waveform_measurement_stats
- clear_waveform_processing
- close
- commit
- configure_chan_characteristics
- configure_equalization_filter_coefficients
- configure_horizontal_timing
- configure_trigger_digital
- configure_trigger_edge
- configure_trigger_hysteresis
- configure_trigger_immediate
- configure_trigger_software
- configure_trigger_video
- configure_trigger_window
- configure_vertical
- disable
- export_attribute_configuration_buffer
- export_attribute_configuration_file
- fetch
- fetch_array_measurement
- fetch_into
- fetch_measurement_stats
- get_channel_names
- get_equalization_filter_coefficients
- get_ext_cal_last_date_and_time
- get_ext_cal_last_temp
- get_self_cal_last_date_and_time
- get_self_cal_last_temp
- import_attribute_configuration_buffer
- import_attribute_configuration_file
- initiate
- lock
- probe_compensation_signal_start
- probe_compensation_signal_stop
- read
- reset
- reset_device
- reset_with_defaults
- self_cal
- self_test
- send_software_trigger_edge
- unlock
- Properties
- absolute_sample_clock_offset
- acquisition_start_time
- acquisition_type
- acq_arm_source
- advance_trigger_terminal_name
- adv_trig_src
- allow_more_records_than_memory
- arm_ref_trig_src
- backlog
- bandpass_filter_enabled
- binary_sample_width
- cable_sense_mode
- cable_sense_signal_enable
- cable_sense_voltage
- channel_count
- channel_enabled
- channel_terminal_configuration
- data_transfer_block_size
- data_transfer_maximum_bandwidth
- data_transfer_preferred_packet_size
- device_temperature
- enabled_channels
- enable_dc_restore
- enable_time_interleaved_sampling
- end_of_acquisition_event_output_terminal
- end_of_acquisition_event_terminal_name
- end_of_record_event_output_terminal
- end_of_record_event_terminal_name
- end_of_record_to_advance_trigger_holdoff
- equalization_filter_enabled
- equalization_num_coefficients
- exported_advance_trigger_output_terminal
- exported_ref_trigger_output_terminal
- exported_start_trigger_output_terminal
- flex_fir_antialias_filter_type
- fpga_bitfile_path
- glitch_condition
- glitch_polarity
- glitch_width
- high_pass_filter_frequency
- horz_enforce_realtime
- horz_min_num_pts
- horz_num_records
- horz_record_length
- horz_record_ref_position
- horz_sample_rate
- horz_time_per_record
- input_clock_source
- input_impedance
- instrument_firmware_revision
- instrument_manufacturer
- instrument_model
- interleaving_offset_correction_enabled
- io_resource_descriptor
- is_probe_comp_on
- logical_name
- master_enable
- max_input_frequency
- max_real_time_sampling_rate
- max_ris_rate
- meas_array_gain
- meas_array_offset
- meas_chan_high_ref_level
- meas_chan_low_ref_level
- meas_chan_mid_ref_level
- meas_filter_center_freq
- meas_filter_cutoff_freq
- meas_filter_order
- meas_filter_ripple
- meas_filter_taps
- meas_filter_transient_waveform_percent
- meas_filter_type
- meas_filter_width
- meas_fir_filter_window
- meas_high_ref
- meas_hysteresis_percent
- meas_interpolation_sampling_factor
- meas_last_acq_histogram_size
- meas_low_ref
- meas_mid_ref
- meas_other_channel
- meas_percentage_method
- meas_polynomial_interpolation_order
- meas_ref_level_units
- meas_time_histogram_high_time
- meas_time_histogram_high_volts
- meas_time_histogram_low_time
- meas_time_histogram_low_volts
- meas_time_histogram_size
- meas_voltage_histogram_high_volts
- meas_voltage_histogram_low_volts
- meas_voltage_histogram_size
- min_sample_rate
- onboard_memory_size
- output_clock_source
- pll_lock_status
- points_done
- poll_interval
- probe_attenuation
- ready_for_advance_event_output_terminal
- ready_for_advance_event_terminal_name
- ready_for_ref_event_output_terminal
- ready_for_ref_event_terminal_name
- ready_for_start_event_output_terminal
- ready_for_start_event_terminal_name
- records_done
- record_arm_source
- ref_clk_rate
- ref_trigger_detector_location
- ref_trigger_minimum_quiet_time
- ref_trigger_terminal_name
- ref_trig_tdc_enable
- resolution
- ris_in_auto_setup_enable
- ris_method
- ris_num_averages
- runt_high_threshold
- runt_low_threshold
- runt_polarity
- runt_time_condition
- runt_time_high_limit
- runt_time_low_limit
- sample_mode
- samp_clk_timebase_div
- sample_clock_timebase_multiplier
- samp_clk_timebase_rate
- samp_clk_timebase_src
- serial_number
- accessory_gain
- accessory_offset
- simulate
- specific_driver_description
- specific_driver_revision
- specific_driver_vendor
- start_to_ref_trigger_holdoff
- start_trigger_terminal_name
- supported_instrument_models
- trigger_auto_triggered
- trigger_coupling
- trigger_delay_time
- trigger_holdoff
- trigger_hysteresis
- trigger_impedance
- trigger_level
- trigger_modifier
- trigger_slope
- trigger_source
- trigger_type
- trigger_window_high_level
- trigger_window_low_level
- trigger_window_mode
- tv_trigger_event
- tv_trigger_line_number
- tv_trigger_polarity
- tv_trigger_signal_format
- use_spec_initial_x
- vertical_coupling
- vertical_offset
- vertical_range
- width_condition
- width_high_threshold
- width_low_threshold
- width_polarity
- NI-TClk Support
- Repeated Capabilities
- Enums
- AcquisitionStatus
- AcquisitionType
- ArrayMeasurement
ArrayMeasurement
ArrayMeasurement.NO_MEASUREMENT
ArrayMeasurement.LAST_ACQ_HISTOGRAM
ArrayMeasurement.FFT_PHASE_SPECTRUM
ArrayMeasurement.FFT_AMP_SPECTRUM_VOLTS_RMS
ArrayMeasurement.MULTI_ACQ_VOLTAGE_HISTOGRAM
ArrayMeasurement.MULTI_ACQ_TIME_HISTOGRAM
ArrayMeasurement.ARRAY_INTEGRAL
ArrayMeasurement.DERIVATIVE
ArrayMeasurement.INVERSE
ArrayMeasurement.HANNING_WINDOW
ArrayMeasurement.FLAT_TOP_WINDOW
ArrayMeasurement.POLYNOMIAL_INTERPOLATION
ArrayMeasurement.MULTIPLY_CHANNELS
ArrayMeasurement.ADD_CHANNELS
ArrayMeasurement.SUBTRACT_CHANNELS
ArrayMeasurement.DIVIDE_CHANNELS
ArrayMeasurement.MULTI_ACQ_AVERAGE
ArrayMeasurement.BUTTERWORTH_FILTER
ArrayMeasurement.CHEBYSHEV_FILTER
ArrayMeasurement.FFT_AMP_SPECTRUM_DB
ArrayMeasurement.HAMMING_WINDOW
ArrayMeasurement.WINDOWED_FIR_FILTER
ArrayMeasurement.BESSEL_FILTER
ArrayMeasurement.TRIANGLE_WINDOW
ArrayMeasurement.BLACKMAN_WINDOW
ArrayMeasurement.ARRAY_OFFSET
ArrayMeasurement.ARRAY_GAIN
- CableSenseMode
- ClearableMeasurement
ClearableMeasurement
ClearableMeasurement.ALL_MEASUREMENTS
ClearableMeasurement.MULTI_ACQ_VOLTAGE_HISTOGRAM
ClearableMeasurement.MULTI_ACQ_TIME_HISTOGRAM
ClearableMeasurement.MULTI_ACQ_AVERAGE
ClearableMeasurement.FREQUENCY
ClearableMeasurement.AVERAGE_FREQUENCY
ClearableMeasurement.FFT_FREQUENCY
ClearableMeasurement.PERIOD
ClearableMeasurement.AVERAGE_PERIOD
ClearableMeasurement.RISE_TIME
ClearableMeasurement.FALL_TIME
ClearableMeasurement.RISE_SLEW_RATE
ClearableMeasurement.FALL_SLEW_RATE
ClearableMeasurement.OVERSHOOT
ClearableMeasurement.PRESHOOT
ClearableMeasurement.VOLTAGE_RMS
ClearableMeasurement.VOLTAGE_CYCLE_RMS
ClearableMeasurement.AC_ESTIMATE
ClearableMeasurement.FFT_AMPLITUDE
ClearableMeasurement.VOLTAGE_AVERAGE
ClearableMeasurement.VOLTAGE_CYCLE_AVERAGE
ClearableMeasurement.DC_ESTIMATE
ClearableMeasurement.VOLTAGE_MAX
ClearableMeasurement.VOLTAGE_MIN
ClearableMeasurement.VOLTAGE_PEAK_TO_PEAK
ClearableMeasurement.VOLTAGE_HIGH
ClearableMeasurement.VOLTAGE_LOW
ClearableMeasurement.AMPLITUDE
ClearableMeasurement.VOLTAGE_TOP
ClearableMeasurement.VOLTAGE_BASE
ClearableMeasurement.VOLTAGE_BASE_TO_TOP
ClearableMeasurement.WIDTH_NEG
ClearableMeasurement.WIDTH_POS
ClearableMeasurement.DUTY_CYCLE_NEG
ClearableMeasurement.DUTY_CYCLE_POS
ClearableMeasurement.INTEGRAL
ClearableMeasurement.AREA
ClearableMeasurement.CYCLE_AREA
ClearableMeasurement.TIME_DELAY
ClearableMeasurement.PHASE_DELAY
ClearableMeasurement.LOW_REF_VOLTS
ClearableMeasurement.MID_REF_VOLTS
ClearableMeasurement.HIGH_REF_VOLTS
ClearableMeasurement.VOLTAGE_HISTOGRAM_MEAN
ClearableMeasurement.VOLTAGE_HISTOGRAM_STDEV
ClearableMeasurement.VOLTAGE_HISTOGRAM_MEDIAN
ClearableMeasurement.VOLTAGE_HISTOGRAM_MODE
ClearableMeasurement.VOLTAGE_HISTOGRAM_MAX
ClearableMeasurement.VOLTAGE_HISTOGRAM_MIN
ClearableMeasurement.VOLTAGE_HISTOGRAM_PEAK_TO_PEAK
ClearableMeasurement.VOLTAGE_HISTOGRAM_MEAN_PLUS_STDEV
ClearableMeasurement.VOLTAGE_HISTOGRAM_MEAN_PLUS_2_STDEV
ClearableMeasurement.VOLTAGE_HISTOGRAM_MEAN_PLUS_3_STDEV
ClearableMeasurement.VOLTAGE_HISTOGRAM_HITS
ClearableMeasurement.VOLTAGE_HISTOGRAM_NEW_HITS
ClearableMeasurement.TIME_HISTOGRAM_MEAN
ClearableMeasurement.TIME_HISTOGRAM_STDEV
ClearableMeasurement.TIME_HISTOGRAM_MEDIAN
ClearableMeasurement.TIME_HISTOGRAM_MODE
ClearableMeasurement.TIME_HISTOGRAM_MAX
ClearableMeasurement.TIME_HISTOGRAM_MIN
ClearableMeasurement.TIME_HISTOGRAM_PEAK_TO_PEAK
ClearableMeasurement.TIME_HISTOGRAM_MEAN_PLUS_STDEV
ClearableMeasurement.TIME_HISTOGRAM_MEAN_PLUS_2_STDEV
ClearableMeasurement.TIME_HISTOGRAM_MEAN_PLUS_3_STDEV
ClearableMeasurement.TIME_HISTOGRAM_HITS
ClearableMeasurement.TIME_HISTOGRAM_NEW_HITS
- FIRFilterWindow
- FetchRelativeTo
- FilterType
- FlexFIRAntialiasFilterType
- GlitchCondition
- GlitchPolarity
- Option
- PercentageMethod
- RISMethod
- RefLevelUnits
- RefTriggerDetectorLocation
- RuntPolarity
- RuntTimeCondition
- ScalarMeasurement
ScalarMeasurement
ScalarMeasurement.NO_MEASUREMENT
ScalarMeasurement.RISE_TIME
ScalarMeasurement.FALL_TIME
ScalarMeasurement.FREQUENCY
ScalarMeasurement.PERIOD
ScalarMeasurement.VOLTAGE_RMS
ScalarMeasurement.VOLTAGE_PEAK_TO_PEAK
ScalarMeasurement.VOLTAGE_MAX
ScalarMeasurement.VOLTAGE_MIN
ScalarMeasurement.VOLTAGE_HIGH
ScalarMeasurement.VOLTAGE_LOW
ScalarMeasurement.VOLTAGE_AVERAGE
ScalarMeasurement.WIDTH_NEG
ScalarMeasurement.WIDTH_POS
ScalarMeasurement.DUTY_CYCLE_NEG
ScalarMeasurement.DUTY_CYCLE_POS
ScalarMeasurement.AMPLITUDE
ScalarMeasurement.VOLTAGE_CYCLE_RMS
ScalarMeasurement.VOLTAGE_CYCLE_AVERAGE
ScalarMeasurement.OVERSHOOT
ScalarMeasurement.PRESHOOT
ScalarMeasurement.LOW_REF_VOLTS
ScalarMeasurement.MID_REF_VOLTS
ScalarMeasurement.HIGH_REF_VOLTS
ScalarMeasurement.AREA
ScalarMeasurement.CYCLE_AREA
ScalarMeasurement.INTEGRAL
ScalarMeasurement.VOLTAGE_BASE
ScalarMeasurement.VOLTAGE_TOP
ScalarMeasurement.FFT_FREQUENCY
ScalarMeasurement.FFT_AMPLITUDE
ScalarMeasurement.RISE_SLEW_RATE
ScalarMeasurement.FALL_SLEW_RATE
ScalarMeasurement.AC_ESTIMATE
ScalarMeasurement.DC_ESTIMATE
ScalarMeasurement.TIME_DELAY
ScalarMeasurement.AVERAGE_PERIOD
ScalarMeasurement.AVERAGE_FREQUENCY
ScalarMeasurement.VOLTAGE_BASE_TO_TOP
ScalarMeasurement.PHASE_DELAY
- TerminalConfiguration
- TriggerCoupling
- TriggerModifier
- TriggerSlope
- TriggerType
- TriggerWindowMode
- VerticalCoupling
- VideoPolarity
- VideoSignalFormat
VideoSignalFormat
VideoSignalFormat.NTSC
VideoSignalFormat.PAL
VideoSignalFormat.SECAM
VideoSignalFormat.M_PAL
VideoSignalFormat.VIDEO_480I_59_94_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_480I_60_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_480P_59_94_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_480P_60_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_576I_50_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_576P_50_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_720P_50_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_720P_59_94_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_720P_60_FRAMES_PER_SECOND
VideoSignalFormat.VIDEO_1080I_50_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_1080I_59_94_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_1080I_60_FIELDS_PER_SECOND
VideoSignalFormat.VIDEO_1080P_24_FRAMES_PER_SECOND
- VideoTriggerEvent
- WhichTrigger
- WidthCondition
- WidthPolarity
- Exceptions and Warnings
- Examples
- gRPC Support