.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\General\recording.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_General_recording.py: Recording and Analyzing Data Using Skutils and a FemtoDAQ Vireo 2-Channel Digitizer =================================================================================== Skutils is not just designed to help one with analyzing data from your FemtoDAQ Digitizer, but it is also designed to be a fully-controllable system for managing your FemtoDAQ digitizer. .. GENERATED FROM PYTHON SOURCE LINES 11-12 Imports .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import skutils import numpy as np import matplotlib.pyplot as plt import tempfile import os .. GENERATED FROM PYTHON SOURCE LINES 18-19 Variables to modify to run a similar experiment on your own system. .. GENERATED FROM PYTHON SOURCE LINES 19-24 .. code-block:: Python # Fill in this spot with your own FemtoDAQ device location DIGITIZER_URL = "http://vireo-000019.tek" NUMBER_OF_EVENTS = 1000 .. GENERATED FROM PYTHON SOURCE LINES 25-26 Configuring the vireo .. GENERATED FROM PYTHON SOURCE LINES 26-63 .. code-block:: Python digitizer = skutils.FemtoDAQController(DIGITIZER_URL, skip_version_check=True) # Configure the vireo to record both channels, with 4096 samples in the waveform # Use eventcsv as it's easier to demo recording_channels = [0, 1] digitizer.configureRecording( recording_channels, number_of_samples_to_capture=4096, file_recording_format="eventcsv", file_recording_data_output="waveforms", ) # enable triggers digitizer.setEnableTrigger(0, True) digitizer.setEnableTrigger(1, True) # Default offset digitizer.setDigitalOffset(0, 0) digitizer.setDigitalOffset(1, 0) digitizer.setAnalogOffsetPercent(0, 0) digitizer.setAnalogOffsetPercent(1, 0) # Allow us to see the beginning of the pulse, if we wish. digitizer.setTriggerXPosition(100) # This is the only digitizer we're using here, set the global id to 0 digitizer.setGlobalId(0) # We want to capture the rising edge, and we want a "fairly" sensitive trigger digitizer.setTriggerEdge(0, "rising") digitizer.setTriggerEdge(1, "rising") digitizer.setTriggerSensitivity(0, 1) digitizer.setTriggerSensitivity(1, 1) # Trigger windows # The trigger active window can also be called the "Coincidence window" digitizer.setTriggerActiveWindow(4096) digitizer.setTriggerAveragingWindow(0, 1) digitizer.setTriggerAveragingWindow(1, 1) # Coincidence settings, I want both channels to have triggered in order to be a true "trigger" and recording the data point digitizer.configureCoincidence("multiplicity", trigger_multiplicity=1) .. rst-class:: sphx-glr-script-out .. code-block:: pytb Traceback (most recent call last): File "C:\Users\Jeff\Documents\projects\skutils\examples\General\recording.py", line 30, in digitizer.configureRecording( File "C:\Users\Jeff\Documents\projects\skutils\src\skutils\FemtoDAQController.py", line 1041, in configureRecording self.__post(self.__config_url("global", "RecordingSettings"), t) File "C:\Users\Jeff\Documents\projects\skutils\src\skutils\FemtoDAQController.py", line 197, in __post raise BusyError(f"FemtoDAQ device responded busy! {resp_json['message']}") skutils.FemtoDAQController.BusyError: FemtoDAQ device responded busy! Capture is currently running and force option was not requested .. GENERATED FROM PYTHON SOURCE LINES 64-65 Collect data .. GENERATED FROM PYTHON SOURCE LINES 65-77 .. code-block:: Python digitizer.start(NUMBER_OF_EVENTS) # wait until we're done collecting data or 5 minutes has passed timed_out = digitizer.waitUntil(timeout_time=360) # Technically not needed, just for posterity digitizer.stop() # We're already in a stopped state at this point, no need to calls stop # Because this is actually being executed, # in this case I am storing them in a temporary directory to not fill directories on my system file_list = digitizer.downloadLastRunDataFiles(tempfile.gettempdir()) .. GENERATED FROM PYTHON SOURCE LINES 78-79 Histogram of the noise triggers .. GENERATED FROM PYTHON SOURCE LINES 79-109 .. code-block:: Python # Individual pulse_heights = [[] for _ in digitizer.channels] for file in file_list: loader = skutils.EventCSVLoader(file) event_count = 0 for event in loader: for channel in event.channel_data: assert channel.has_wave height = np.max(channel.wave) pulse_heights[channel.channel].append(height) total_range = digitizer.adc_max_val - digitizer.adc_min_val total_bins = total_range // 4 hist_builder = [] for height_list in pulse_heights: hist_builder.append(np.histogram(height_list, bins=total_bins)) fig, axes = plt.subplots(2, 1) for i in range(len(hist_builder)): hist, edges = hist_builder[i] axes[i].bar(edges[1:], hist, width=3.5, label=f"channel {i}") axes[i].legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.087 seconds) .. _sphx_glr_download_auto_examples_General_recording.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: recording.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: recording.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: recording.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_