Giter VIP home page Giter VIP logo

tangy's Introduction

Welcome to tangy ๐ŸŠ

tangy is a high performance library to buffer timetags from timetaggers and files and provides soft-realtime analysis.

About

It stores your timetag data in a circular buffer backed by shared memory allowing you to have multiple client connect to the same buffer. When streaming data from a device into a tangy buffer this allows you to have multiple connections to the same device facilitating either mulitple lab users or multiple concurrent experiments. Alternatively, if you have a large file of containing timetags you can read a section into a tangy buffer in one python interpreter and perform analysis on that section in another speeding up exploratory analysis.

Features

  • Support for different timetag formats
  • A client-server model for buffering and analysis
  • Analysis for:
    • Singles counting
    • Coincidence counting
    • Delay finding
    • Joint delay histograms

Installation

python3 -m pip install tangy
python3 -m pip install tangy[gui] # if you intend on using the guis

Advanced

Install from git to get the latest version

python3 -m pip install git+https://gitlab.com/PeterBarrow/tangy.git

Quick Examples

Open a file and read some data

import tangy

target_file = 'tttr_data.ptu'

n = int(1e7)
name = "tagbuffer"
# Open the file
ptu = tangy.PTUFile(target_file, name, n)

# Read some data from the file
for i in range(11):
    start_time = perf_counter()
    a = ptu.read(1e6)
    stop_time = perf_counter()
    run_time += (stop_time - start_time)
    print([ptu.record_count, ptu.count])

# Acquire the buffer
buffer = ptu.buffer()

Count coincidences in the last second for channels [0, 1] with a 1ns window

integration_time = 1
coincidence_window = 1e-9
channels = [0, 1]
count = buffer.coincidence_count(integration_time, coincidence_window, channels)

Collect coincident timetags

records = buffer.coincidence_collect(integration_time, coincidence_window, channels)

Find the delays between pairs of channels

channel_a = 0
channel_b = 1
integration_time = 10
measurement_resolution = 6.25e-9
result_delay = buffer.relative_delay(channel_a, channel_b,
                                     integration_time,
                                     resolution=6.25e-9,
                                     window=250e-7)
delays = [0, result_delay.t0]

Count (or collect) coincidences with delays

count = buffer.coincidence_count(integration_time,
                                 coincidence_window,
                                 channels,
                                 delays=delays)

records = buffer.coincidence_collect(integration_time,
                                     coincidence_window,
                                     channels,
                                     delays=delays)

tangy's People

Contributors

peter-barrow avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tangy's Issues

Tangy is incompatible with Numpy 2.0

Describe the bug
When installing tangy, the latest version of numpy is installed, which is currently version 2.0.0, but this version is incompatible with tangy since there are breaking changes compared to version 1.26.4. Reverting back to numpy 1.26.4 solves this.

To Reproduce
Install tangy with pip without specifying numpy version

System (please complete the following information):

  • OS: Ubuntu
  • Version 22.04

tangy-gui-uqdlogic16, cannot import name 'UQDLogic16' from 'tangy'

Describe the bug
ImportError from running tangy-gui-uqdlogic16

To Reproduce
Running tangy-gui-uqdlogic16 results in

Traceback (most recent call last):
  File "/home/faris/Projects/tangy-test/.venv/bin/tangy-gui-uqdlogic16", line 5, in <module>
    from tangy.apps.gui_uqd import run
  File "/home/faris/Projects/tangy-test/.venv/lib/python3.10/site-packages/tangy/apps/gui_uqd.py", line 10, in <module>
    from tangy import tangy_config_location, UQDLogic16
ImportError: cannot import name 'UQDLogic16' from 'tangy' (/home/faris/Projects/tangy-test/.venv/lib/python3.10/site-packages/tangy/__init__.py)

System (please complete the following information):

  • Ubuntu
  • 22.04

Additional context
The __init__.py file shown in the error has the lines

# uqd_lib = None
# 
# if platform.startswith("linux"):
#     uqd_lib = find_library("timetag64")
# 
# if platform.startswith("win32"):
#     uqd_lib = find_library("CTimeTagLib")
#     from ._uqd import UQDLogic16
# 
# if uqd_lib is not None:
#     from ._uqd import UQDLogic16

commented out, uncommenting these lines fixes the issue and tangy-gui-uqdlogic16 seems to work normally

tangy-gui-coincidence-counter, cannot import name 'find_delay' from 'tangy'

Describe the bug
Import error from running tangy-gui-coincidence-counter

To Reproduce
Running tangy-gui-coincidence-counter results in

Traceback (most recent call last):
  File "/home/jh115/python-venvs/pythona/bin/tangy-gui-coincidence-counter", line 5, in <module>
    from tangy.apps.gui_coincidence_counter import run
  File "/home/jh115/python-venvs/pythona/lib/python3.10/site-packages/tangy/apps/gui_coincidence_counter.py", line 12, in <module>
    from tangy import find_delay
ImportError: cannot import name 'find_delay' from 'tangy' (/home/jh115/python-venvs/pythona/lib/python3.10/site-packages/tangy/__init__.py)

System (please complete the following information):

  • Ubuntu
  • 22.04

Additional context
Commenting out the import of find_delay in gui_coincidence_counter.py seems to fix this and the window shows up, has find_delay been deprecated?

tangy-gui-uqdlogic16, 'tangy._tangy.TangyBuffer' object has no attribute 'clear'

Describe the bug
When pressing start on tangy-gui-uqdlogic16, an attribute error is thrown and it does not start counting

To Reproduce
Steps to reproduce the behavior:
Apply a config and press start results in

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/usr/lib/python3.10/tkinter/__init__.py", line 839, in callit
    func(*args)
  File "/home/jh115/Projects/waveguide/.venv/lib/python3.10/site-packages/tangy/apps/gui_uqd.py", line 368, in sync
    self.device.start_timetags()
  File "tangy_src/_uqd.py", line 370, in tangy._uqd.UQDLogic16.start_timetags
AttributeError: 'tangy._tangy.TangyBuffer' object has no attribute 'clear'

System (please complete the following information):

  • OS: Ubuntu
  • Version 22.04

Additional context
The file tangy_src/_uqd.py had the lines

  def start_timetags(self):
      """
      Start transmitting timetags from the device to the host computer
      """

      if self._have_buffer is True:
          self._buffer.clear()

in v0.4.1, where _buffer.clear() appears to have since been deprecated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.