From ca8d43f3e39efa0375cc4d5e08cbac2a3ff7f888 Mon Sep 17 00:00:00 2001 From: mathiaszurbriggen Date: Fri, 10 Oct 2025 16:26:25 +0100 Subject: [PATCH 1/3] Create processing_utils_lecroy --- packs/proc/processing_utils_lecroy | 1 + 1 file changed, 1 insertion(+) create mode 100644 packs/proc/processing_utils_lecroy diff --git a/packs/proc/processing_utils_lecroy b/packs/proc/processing_utils_lecroy new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/packs/proc/processing_utils_lecroy @@ -0,0 +1 @@ + From c248de6daea6adaec47b0a0d18f1efaa5153e743 Mon Sep 17 00:00:00 2001 From: mattzur Date: Fri, 10 Oct 2025 16:30:29 +0100 Subject: [PATCH 2/3] add parser for typical lecroy .csv files for sipm signal --- packs/proc/processing_utils_lecroy | 1 - packs/proc/processing_utils_lecroy.py | 43 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) delete mode 100644 packs/proc/processing_utils_lecroy create mode 100644 packs/proc/processing_utils_lecroy.py diff --git a/packs/proc/processing_utils_lecroy b/packs/proc/processing_utils_lecroy deleted file mode 100644 index 8b13789..0000000 --- a/packs/proc/processing_utils_lecroy +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packs/proc/processing_utils_lecroy.py b/packs/proc/processing_utils_lecroy.py new file mode 100644 index 0000000..82faf88 --- /dev/null +++ b/packs/proc/processing_utils_lecroy.py @@ -0,0 +1,43 @@ +def parse_lecroy_segmented(lines): + # Line 1 has to have: Segments,1000,SegmentSize,5002 + segments = int(lines[1][1]) + seg_size = int(lines[1][3]) + + # Line 2, header is: Segment,TrigTime,TimeSinceSegment1 + # Lines 3 to 3 + segments - 1 are header lines + header_start = 3 + header_end = header_start + segments + header_lines = lines[header_start:header_end] + + header_df = pd.DataFrame(header_lines, columns=["Segment", "TrigTime", "TimeSinceSegment1"]) + + # Find the "Time,Ampl" line + for i, line in enumerate(lines): + if line[0].strip() == "Time": + data_start = i + 1 + break + else: + raise ValueError("Time,Ampl line not found") + + # Read the data block (segments × segment size) + raw_data = lines[data_start:] + if len(raw_data) < segments * seg_size: + print(f"Warning: expected {segments * seg_size} rows, got {len(raw_data)}") + + value_list = [] + for j in range(segments): + segment_data = [] + for k in range(seg_size): + x = j * seg_size + k + if x >= len(raw_data): # x = line in the file + segment_data.append(None) + else: + try: + value = float(raw_data[x][1]) # column 1 = Amplitude of signal + segment_data.append(value) + except (ValueError, IndexError): + segment_data.append(None) + value_list.append(segment_data) + + value_df = pd.DataFrame(value_list) + return value_df, header_df From f134d788d51ecd4411afd79e66600d72fec3d447 Mon Sep 17 00:00:00 2001 From: mattzur Date: Mon, 13 Oct 2025 11:50:02 +0100 Subject: [PATCH 3/3] add notes and imports --- packs/proc/processing_utils_lecroy.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packs/proc/processing_utils_lecroy.py b/packs/proc/processing_utils_lecroy.py index 82faf88..c5764ca 100644 --- a/packs/proc/processing_utils_lecroy.py +++ b/packs/proc/processing_utils_lecroy.py @@ -1,3 +1,16 @@ +import numpy as np +import pandas as pd +import os +from tqdm import tqdm +import csv +import re + +""" +Processing utilities for the Lecroy oscilloscope + +This file holds all the relevant functions for the processing of data from csv files to h5. +""" + def parse_lecroy_segmented(lines): # Line 1 has to have: Segments,1000,SegmentSize,5002 segments = int(lines[1][1])