Skip to content

Commit

Permalink
feat: PicoHarp support added
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Barrow committed Aug 21, 2024
1 parent d3d94d2 commit 16dbd7d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tangy"
version = "0.7.0"
version = "0.8.0"
description = "Timetag analysing library"
authors = [
{name = "Peter Thomas Barrow", email = "[email protected]"}
Expand Down
17 changes: 3 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
from setuptools import setup, Extension


def building_on_github_actions():
if "CI" not in os.environ \
or not os.environ["CI"] \
or "GITHUB_RUN_ID" not in os.environ:
return False
return True

# local = True
# if "CIBUILDWHEEL" in os.environ or os.environ["CIBUILDWHEEL"]:
# local = False

# if building_on_github_actions():
# local = False
local = False
local = True
if os.environ.get("CIBUILDWHEEL", '0') == 1:
local = False

cython_dir = os.path.join("tangy_src")

Expand Down
16 changes: 14 additions & 2 deletions tangy_src/_tangy.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,30 @@ cdef extern from './src/picoquant_reader.h':

void delete_reader_status(const READER_STATUS* const reader_stat)

u64 srb_read_next_HH2_T2(shared_ring_buffer* buf,
u64 srb_read_next_PH_T2(shared_ring_buffer* buf,
std_slice* data,
FILE* filehandle,
READER_STATUS* status,
u64 count_tags)

u64 srb_read_next_HH2_T3(shared_ring_buffer* buf,
u64 srb_read_next_PH_T3(shared_ring_buffer* buf,
clk_slice* data,
FILE* filehandle,
READER_STATUS* status,
u64 count_tags)

u64 srb_read_next_HH2_T2(shared_ring_buffer* buf,
std_slice* data,
FILE* filehandle,
READER_STATUS* status,
u64 count_tags)

u64 srb_read_next_HH2_T3(shared_ring_buffer* buf,
clk_slice* data,
FILE* filehandle,
READER_STATUS* status,
u64 count_tags)


cdef extern from "./src/shared_ring_buffer_context.h":

Expand Down
55 changes: 41 additions & 14 deletions tangy_src/_tangy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1586,23 +1586,50 @@ def read(self, n: u64n):
:param n: [TODO:description]
"""

res: u64n = 0
record_type = self._header["TTResultFormat_TTTRRecType"]["value"]

if self._buffer._format == TangyBufferType.Standard:
res = _tangy.srb_read_next_HH2_T2(self._buffer._ptr_rb,
cython.address(
self._buffer._buf.slice.standard),
self._c_file_handle,
self._status,
n)
return res

slice_standard: cython.pointer(_tangy.std_slice) = \
cython.address(self._buffer._buf.slice.standard)

if record_type == _ptu_record_types["PicoHarpT2"]:
res = _tangy.srb_read_next_PH_T2(self._buffer._ptr_rb,
slice_standard,
self._c_file_handle,
self._status,
n)
return res

if record_type == _ptu_record_types["HydraHarp2T2"]:
res = _tangy.srb_read_next_HH2_T2(self._buffer._ptr_rb,
slice_standard,
self._c_file_handle,
self._status,
n)
return res

if self._buffer._format == TangyBufferType.Clocked:
res = _tangy.srb_read_next_HH2_T3(self._buffer._ptr_rb,
cython.address(
self._buffer._buf.slice.clocked),
self._c_file_handle,
self._status,
n)
return res
slice_clocked: cython.pointer(_tangy.clk_slice) = \
cython.address(self._buffer._buf.slice.clocked)

if record_type == _ptu_record_types["PicoHarpT3"]:
res = _tangy.srb_read_next_PH_T3(self._buffer._ptr_rb,
slice_clocked,
self._c_file_handle,
self._status,
n)
return res

if record_type == _ptu_record_types["HydraHarp2T3"]:
res = _tangy.srb_read_next_HH2_T3(self._buffer._ptr_rb,
slice_clocked,
self._c_file_handle,
self._status,
n)
return res
return res

# def read_seconds(self, t: f64n):
Expand Down
6 changes: 4 additions & 2 deletions tangy_src/src/picoquant_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ Parse_PH_T2(u32 record, Record_PH_T2* Rec_struct, res* out) {
u64 marker = tt & 0xf;
if (marker == 0) {
out->overflow += T2WRAPAROUND;
// ch -= 1;
} else {
tt += out->overflow;
++photon;
// ++photon;
// ch -= 2;
}
} else {
tt += out->overflow;
Expand Down Expand Up @@ -121,7 +123,7 @@ Parse_PH_T3(u32 record, Record_PH_T3* Rec_struct, res* out) {
out->overflow += T3WRAPAROUND;
} else {
ns += out->overflow;
++photon;
// ++photon;
}
} else {
ns += out->overflow;
Expand Down

0 comments on commit 16dbd7d

Please sign in to comment.