caen-felib


Namecaen-felib JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummaryOfficial Python wrapper for the CAEN FELib.
upload_time2024-06-14 10:35:31
maintainerNone
docs_urlNone
authorGiovanni Cerretani, Daniele Ninci
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://www.caen.it/products/caen-felib-library/).

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:

```python
import numpy as np
from matplotlib import pyplot as plt

from caen_felib import device, error

with device.connect('dig2://<host>') as dig:
    # Reset
    dig.cmd.Reset()

    # Read-only parameters
    nch = int(dig.par.NumCh.value)
    adc_nbit = int(dig.par.ADC_NBit.value)

    # Configuration parameters
    reclen = 4096
    dc_offset = 50
    pre_trigger = 128

    # Set some digitizer parameters
    dig.par.AcqTriggerSource.value = 'SwTrg'
    dig.par.RecordLengthS.value = f'{reclen}'
    dig.par.PreTriggerS.value = f'{pre_trigger}'

    # Set some channel parameters
    for ch in dig.ch:
        ch.par.DCOffset.value = f'{dc_offset}'

    # 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],
        },
    ]

    # Store endpoint node
    ep_scope = dig.endpoint.scope

    # set_read_data_format returns allocated buffers
    data = ep_scope.set_read_data_format(data_format)
    timestamp = data[0].value
    waveform = data[1].value
    waveform_size = data[2].value

    # Configure plot
    plt.ion()
    figure, ax = plt.subplots(figsize=(10, 8))
    lines = []
    for i in range(nch):
        line, = ax.plot([], [])
        lines.append(line)
    ax.set_xlim(0, reclen - 1)
    ax.set_ylim(0, 2 ** adc_nbit - 1)

    # Start acquisition
    dig.cmd.ArmAcquisition()
    dig.cmd.SwStartAcquisition()

    # Acquisition loop
    while True:

        # Send trigger
        dig.cmd.SendSwTrigger()

        # Wait for event
        try:
            dig.endpoint.scope.read_data(100, data)
        except error.Error as ex:
            if ex.code == error.ErrorCode.TIMEOUT:
                # Timeout expired, waiting againg
                continue
            elif ex.code == error.ErrorCode.STOP:
                # End of run, exit the loop
                print('End of run.')
                break
            else:
                # Other critical error, propagate it
                raise ex

        for i in range(nch):
            lines[i].set_data(np.arange(0, waveform_size[i]), waveform[i])

        ax.title.set_text(f'Timestamp: {timestamp}')

        figure.canvas.draw()
        figure.canvas.flush_events()

    # Stop acquisition
    dig.cmd.DisarmAcquisition()
```

## 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/.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "caen-felib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Giovanni Cerretani, Daniele Ninci",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/50/d1/14a04755e8a7b324b0a1ed485c3f948a65eeac4e404d0b3c1fb77749d325/caen_felib-1.2.2.tar.gz",
    "platform": null,
    "description": "# caen_felib\nThe official Python wrapper for the CAEN FELib.\n\n## Install\nYou need to install both the latest version of CAEN FELib and an implementation like the CAEN Dig2 from [the CAEN website](https://www.caen.it/products/caen-felib-library/).\n\nThen, install this module and have fun.\n\n## Examples\nFew examples may be found on the official documentation and in the function docstrings.\n\nThis example show the simplest way to perform a data acquisition with the scope firmware:\n\n```python\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\nfrom caen_felib import device, error\n\nwith device.connect('dig2://<host>') as dig:\n    # Reset\n    dig.cmd.Reset()\n\n    # Read-only parameters\n    nch = int(dig.par.NumCh.value)\n    adc_nbit = int(dig.par.ADC_NBit.value)\n\n    # Configuration parameters\n    reclen = 4096\n    dc_offset = 50\n    pre_trigger = 128\n\n    # Set some digitizer parameters\n    dig.par.AcqTriggerSource.value = 'SwTrg'\n    dig.par.RecordLengthS.value = f'{reclen}'\n    dig.par.PreTriggerS.value = f'{pre_trigger}'\n\n    # Set some channel parameters\n    for ch in dig.ch:\n        ch.par.DCOffset.value = f'{dc_offset}'\n\n    # Set enabled endpoint to activate decode\n    dig.endpoint.par.ActiveEndpoint.value = 'scope'\n\n    # Configure endpoint\n    data_format = [\n        {\n            'name': 'TIMESTAMP',\n            'type': 'U64',\n        },\n        {\n            'name': 'WAVEFORM',\n            'type': 'U16',\n            'dim': 2,\n            'shape': [nch, reclen],\n        },\n        {\n            'name': 'WAVEFORM_SIZE',\n            'type': 'U64',\n            'dim': 1,\n            'shape': [nch],\n        },\n    ]\n\n    # Store endpoint node\n    ep_scope = dig.endpoint.scope\n\n    # set_read_data_format returns allocated buffers\n    data = ep_scope.set_read_data_format(data_format)\n    timestamp = data[0].value\n    waveform = data[1].value\n    waveform_size = data[2].value\n\n    # Configure plot\n    plt.ion()\n    figure, ax = plt.subplots(figsize=(10, 8))\n    lines = []\n    for i in range(nch):\n        line, = ax.plot([], [])\n        lines.append(line)\n    ax.set_xlim(0, reclen - 1)\n    ax.set_ylim(0, 2 ** adc_nbit - 1)\n\n    # Start acquisition\n    dig.cmd.ArmAcquisition()\n    dig.cmd.SwStartAcquisition()\n\n    # Acquisition loop\n    while True:\n\n        # Send trigger\n        dig.cmd.SendSwTrigger()\n\n        # Wait for event\n        try:\n            dig.endpoint.scope.read_data(100, data)\n        except error.Error as ex:\n            if ex.code == error.ErrorCode.TIMEOUT:\n                # Timeout expired, waiting againg\n                continue\n            elif ex.code == error.ErrorCode.STOP:\n                # End of run, exit the loop\n                print('End of run.')\n                break\n            else:\n                # Other critical error, propagate it\n                raise ex\n\n        for i in range(nch):\n            lines[i].set_data(np.arange(0, waveform_size[i]), waveform[i])\n\n        ax.title.set_text(f'Timestamp: {timestamp}')\n\n        figure.canvas.draw()\n        figure.canvas.flush_events()\n\n    # Stop acquisition\n    dig.cmd.DisarmAcquisition()\n```\n\n## Documentation\nPython API is described on the CAEN FELib library documentation, starting from CAEN FELib v1.2.3.\n\n## References\nRequirements and documentation can be found at \nhttps://www.caen.it/products/caen-felib-library/.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Official Python wrapper for the CAEN FELib.",
    "version": "1.2.2",
    "project_urls": {
        "Documentation": "https://www.caen.it/products/caen-felib-library/",
        "Homepage": "https://www.caen.it",
        "Support": "https://www.caen.it/mycaen/support/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d35a26aae0a777db6827542ffa8061ed08cbd5da5bfa7760d0b120696cde4247",
                "md5": "9da242c202ec1536cba27ae84b1a61bb",
                "sha256": "fda295e89a2fe8e71d64699dde1c53a224d71e761d86f352ca4db7a4bb63da07"
            },
            "downloads": -1,
            "filename": "caen_felib-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9da242c202ec1536cba27ae84b1a61bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 29101,
            "upload_time": "2024-06-14T10:35:15",
            "upload_time_iso_8601": "2024-06-14T10:35:15.500676Z",
            "url": "https://files.pythonhosted.org/packages/d3/5a/26aae0a777db6827542ffa8061ed08cbd5da5bfa7760d0b120696cde4247/caen_felib-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50d114a04755e8a7b324b0a1ed485c3f948a65eeac4e404d0b3c1fb77749d325",
                "md5": "20f252293a3f58e284e13e4eb033454b",
                "sha256": "7278565091f751e9a659c185fcc6041a0340e28f36a1390cdbe1bd28420313d6"
            },
            "downloads": -1,
            "filename": "caen_felib-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "20f252293a3f58e284e13e4eb033454b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27154,
            "upload_time": "2024-06-14T10:35:31",
            "upload_time_iso_8601": "2024-06-14T10:35:31.954761Z",
            "url": "https://files.pythonhosted.org/packages/50/d1/14a04755e8a7b324b0a1ed485c3f948a65eeac4e404d0b3c1fb77749d325/caen_felib-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-14 10:35:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "caen-felib"
}
        
Elapsed time: 0.26769s