Official Python wrapper for the CAEN FELib.
Project description
caen_felib
The official Python wrapper for the CAEN FELib.
Install
You need to install both the latest version of CAEN FELib and an implementation like the CAEN Dig2 from the CAEN website.
Then, install this module and have fun.
Examples
Few examples may be found on the official documentation and in the function docstrings.
This example show the simplest way to perform a data acquisition with the scope firmware:
import numpy as np
from matplotlib import pyplot as plt
from caen_felib import device
with device.connect("dig2://<host>") as dig:
# Reset
dig.cmd.Reset()
# Configuration parameters
nch = int(dig.par.NumCh.value)
reclen = 4096
# Set some digitizer parameters
dig.par.AcqTriggerSource.value = 'SwTrg'
dig.par.RecordLengthS.value = f'{reclen}'
dig.par.PreTriggerS.value = f'{128}'
# Set some channel parameters
for ch in dig.ch:
ch.par.DCOffset.value = f'{50}'
# Set enabled endpoint to activate decode
dig.endpoint.par.ActiveEndpoint.value = 'scope'
# Configure endpoint
data_format = [
{
'name': 'TIMESTAMP',
'type': 'U64',
},
{
'name': 'WAVEFORM',
'type': 'U16',
'dim': 2,
'shape': [nch, reclen],
},
{
'name': 'WAVEFORM_SIZE',
'type': 'U64',
'dim': 1,
'shape': [nch],
},
]
# set_read_data_format returns allocated buffers
data = dig.endpoint.scope.set_read_data_format(data_format)
timestamp = data[0].value
waveform = data[1].value
waveform_size = data[2].value
# Start acquisition
dig.cmd.ArmAcquisition()
dig.cmd.SwStartAcquisition()
# Send trigger and wait for first event
dig.cmd.SendSwTrigger()
dig.endpoint.scope.read_data(-1, data)
# Stop acquisition
dig.cmd.DisarmAcquisition()
# Plot waveforms
for i in range(nch):
size = waveform_size[i]
plt.plot(np.arange(size), waveform[i][:size])
plt.title(f'Timestamp: {timestamp}')
plt.show()
Documentation
Python API is described on the CAEN FELib library documentation, starting from CAEN FELib v1.2.3.
References
Requirements and documentation can be found at https://www.caen.it/products/caen-felib-library/.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
caen_felib-1.0.4.tar.gz
(11.7 kB
view hashes)
Built Distribution
caen_felib-1.0.4-py3-none-any.whl
(13.0 kB
view hashes)
Close
Hashes for caen_felib-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ad2b94cb143d52063bf97b7bf24a28319c6ad2679c4bb9d227a2736fd1da194 |
|
MD5 | 191fa226c03d53b01ba4ec9aecbe4c65 |
|
BLAKE2b-256 | 7a9f5f6a3c52529028208ec13d360ddcacbe69fdd091e01978837e974fa13209 |