Package: picodaqa
# picoDAQpythonData AcQuisition and analysis with PicoScope usb-oscilloscopesTheusb-oscilloscope series PicoSpope by Pico Technology (see <https://www.picotech.com>)
offers universal instruments that come with great software support, not only a graphical
interface offering the functionality known from oscilloscopes, but - most importantly for
this project - also with a software development kit (SDK) which makes it possible to use
the devices with a wide range of high-level languages.Provided here is a data acquisition system as is needed to record,  analyze, classify and
count the occurrence of wave forms such as provided for example by single-photon counters
or typical detectors common in quantum mechanical measurements or in nuclear, particle
physics and astro particle physics, e.g. photo tubes, Geiger counters, avalanche
photo-diodes or modern SiPMs.The random nature of such processes and the need to keep read-out dead times low requires
an input buffer and a buffer manager running as a background process. Data are provided
via the buffer manager interface to several consumer processes to analyze, check or
visualize data and analysis results. Such consumers may be obligatory ones, i.e. data
acquisition pauses if all input buffers are full and an obligatory consumer is still busy
processing. A second type of random consumers receives an event copy from the buffer manager
upon request, without pausing the data acquisition process. Typical examples of
random consumers are displays of a subset of the wave forms or of intermediate
analysis results. Examples for such consumers are provided as part of this package,
running either as a ‘thread’ within the python interpreter or as sub-processes using
the ‘multiprocessing’ package.This project originated as a demonstration to analyze pulses from a photomultiplier (PM)
or a Silicon Photo Multiplier (SiPM) registering optical signals from  a detector, in the
simplest case a coffeepot filled with water and equipped with a PM to count muons from
cosmic rays.## List of implementedFunctions:classpicoConfig:
- set up PicoScope time base, channel ranges and trigger
- set up the internal signal generator
- PicoScope configuration read fromjsonoryamlfile
- data acquisition of raw data from deviceclassBufferMan:
- acquire data (implemented as background thread)
- manage event data buffer and distribute to consumers
- configuration read fromjsonoryamlfile
- supportsobligatoryconsumers: data acquisition pauses until consumer doneandrandomconsumers: receive a copy of one event, data acquisition continuesmoduleAnimatedInstruments(deprecated, to be removed soon)
- examples of animated graphical devices: a Buffer Manager display (using
classplotBufManInfo), a VoltMeter (class *VoltMeter), an Oscilloscope
(classOcscilloscopeand a ratemeter (classRMeter). The module must run as
apythonthreadin the samepythoninterpreter asBufferManmodulempBufManCntrl- this sub-process receives status and logging information from the Buffer Manager
via a multiprocessing Queue and displays input rate history, filling level of the
buffers and the data-acquisition lifetime. Buttons at the bottom of the window allow
status changes (from RUNNING to PAUSED or vice versa) or to exit. A log-file at the
end contains a summary and, optionally, logging information.modulempOsciruns an instance ofOscilloscpeas a sub-process, and receives data fromBufferManvia a multiprocessing Queue.modulempRMeterruns an instance of theRMeterclass as a sub-process, receiving via a multiprocessing Queue.modulempVMeterruns an instance of theVoltMeterclass as a sub-process, receiving data via a multiprocessing Queue.modulempHistsruns an instance of theanimHistsclass as a sub-process; receives input data via a
multiprocessing Queue. Data are formatted as lists of values. A normalized frequency distribution is
then updated and displayed.modulempBDisplay- runs an instance of class BarDisplay and shows one (signed or unsigned) value per Channel
(e.g. peak Voltage, effective Voltage etc.). Values are passed to the sub-process via a
multiprocessing Queue.modulempDataLoggerruns an instance of theDataLoggerclass as a sub-process, displaying  values passed via a
multiprocessing Queue as a history plot. This module   is not implemented as aBufferMan*client (see examplerunDataLogger).modulempDataGraphsruns an instance of theDataGraphsclass as a sub-process, displaying values passed via a
multiprocessing Queue as a bar graph, a history plot or optionally - if two channels are
enabled - as xy-display. This module ist not implemented as aBufferManclient (see examplerunDataGraphs)The scriptrunDAQ.pygives an example of how to use all of the above. For a full demo,
connect the output of a PicoScope’s signal generator to channelB, and eventually an
open cable to ChannelAto see random noise. Use the configuration fileDAQconfig.yaml,
which specifies the configuration files`BMconfig.yaml` for the Buffer Manager andPSConfig.yamlfor the PicoScope. As a hook for own extensions, user code may be included. An example for this
is shown in the configuration fileDAQ_Cosmo.json, which points to a code snippetanaDAQ.pyto start some example consumers (code in`exampleConsumers.py`).## ExamplesThe directoryexamples/contains configuration files and some special applications.The scriptrunDataLogger.pyimplements a data logger for rates below 20 Hz. Signals are
sampled with a PicoSocpe at a rate of 10 kHz over 20 ms and then averaged. 50 Hz noise is
thus eliminated, and a clean voltage signal is obtained. The history of the recorded voltages
is displayed using the modulempDataLogger.
Similarly,runDataGraphsuses the same sampling mechanism to display the effective voltage
as bar graph, a history plot, and, optionally,   channel B vs. Channel A as an xy-graph if two
channels are enabled.
These examples directly read from the hardware device and therefore do not rely on theBufferManclass.
As a third simple example the scriptrunOsci.pyprovides a simple oscilloscpe independent of BufferMan.The scriptrunCosmo.pyis a modified version ofrunDAQ.pyand depends on the code inpulseFilter.py, which implements a convolution filter to search for characteristic signal
shapes in an input waveform. The example is tailored to identify short pulses from muon
detectors (e. g. the scintillator panels of theCosMO-experiment by “Netzwerk Teilchenwelt”,
<http://www.teilchenwelt.de>,
or the Kamiokanne-Experiment with photomultiplier readout and pulses shaped to a length of
approx. 150ns). A more complete and updated version has been moved to the projectpicoCosmo,
see <https://github.com/GuenterQuast/picoCosmo>.## Installation of the packageThis python code is compatible withpythonversions and >=3.5. It was tested with PicoScope
device classes PS2000, PS2000a, PS3000a and PS4000 under Ubuntu, openSUSE Leap and on RaspberryPi.
Graphical displays are implemented withmatplotlib.Requirements:The low-level drivers and C-libraries contained in the Pico Technology
Software Development Kit are required,SDKby Pico Technology,
seehttps://www.picotech.com/downloadspythonbindings of thepico-pythonproject by Colin O’Flynn
and Mark Harfouche,https://github.com/colinoflynn/pico-pythonpicoDAQpresently consists of the modules in the direcoctrypicodaqa, mentioned above,
and an examplepythonscript (runDAQ.py) with configuration examples (.yamlfiles) for
the data acquisition (DAQconfig.yaml), for the PicoScope Device (PSconfig.yaml) and for
the Buffer Mananger (BMconfig.yaml).After downloading all files from the git repository, connect your PicoScope and start from
the command line, e. g.python runDAQ.py.You may run the scriptmake_dist.shto generate a.whlfile in the subdirectorydist, which can be installed viapip install picodaqa_<vers>_<type>.whl. Once
this is done, the provided examples can be copied to any directory.