added more raw files

This commit is contained in:
froejdh_e 2025-04-14 16:15:43 +02:00
parent a564862aa5
commit b7d5704f58
5 changed files with 126 additions and 0 deletions

Binary file not shown.

38
clust/make_hists.py Normal file
View File

@ -0,0 +1,38 @@
import numpy as np
import time
from pathlib import Path
import pickle
import boost_histogram as bh
n_bins = 100
xmin = -100
xmax = 1e4
#Python implementation to read a cluster file and save the
#histogram. Can be used to compare with the C++ implementation.
fname = Path('beam_En700eV_-40deg_300V_10us_d0_f0_100.clust')
hist_py = bh.Histogram(bh.axis.Regular(n_bins, xmin, xmax))
t0 = time.perf_counter()
N = 1500 #Maximum frames
with open(fname, 'rb') as f:
for i in range(N):
frame_number = np.fromfile(f, count=1, dtype = np.int32)
if frame_number.size == 0:
break
n_clusters = np.fromfile(f, count=1, dtype = np.uint32)[0]
for i in range(n_clusters):
xy = np.fromfile(f, count=2, dtype = np.uint16)
data = np.fromfile(f, count=9, dtype = np.int32)
hist_py.fill(data)
t = time.perf_counter()-t0
with open(fname.with_suffix('.pkl'), 'wb') as f:
pickle.dump(hist_py, f)
print(f'Reading {i} frames with python took: {t:.3f}s')

View File

@ -0,0 +1,40 @@
from pathlib import Path
header_size = 112
frame_size = 400**2*2
n_frames = 1000
# base = Path('/mnt/sls_det_storage/matterhorn_data/aare_test_data/')
# f = File(base/'Moench03new/cu_half_speed_master_4.json')
findex = 4
for base_name in ['cu_half_speed',]:
src = Path(f'/mnt/sls_det_storage/matterhorn_data/aare_test_data/Moench03new/{base_name}_d0_f0_{findex}.raw')
dst = Path('/home/l_msdetect/erik/data/aare-test-data/raw/moench03')/src.name
print(f'src: {src}')
print(f'dst: {dst}')
# Copy data
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
for i in range(n_frames):
data = fsrc.read(header_size+frame_size)
fdst.write(data)
# Copy master file and rewrite the number of frames in the file
msrc = src.parent/f'{base_name}_master_{findex}.json'
mdst = dst.parent/f'{base_name}_master_{findex}.json'
print(f'msrc: {msrc}')
print(f'mdst: {mdst}')
with open(msrc) as m_fsrc, open(mdst, 'w') as m_fdst:
for line in m_fsrc:
if "Total Frames" in line:
line = f'\t"Total Frames": {n_frames},\n'
if "Frames in File" in line:
line = f'\t"Frames in File": {n_frames},\n'
m_fdst.write(line)

Binary file not shown.

View File

@ -0,0 +1,48 @@
{
"Version": 7.1,
"Timestamp": "Fri Jul 14 15:29:01 2023",
"Detector Type": "Moench",
"Timing Mode": "auto",
"Geometry": {
"x": 1,
"y": 1
},
"Image Size in bytes": 320000,
"Pixels": {
"x": 400,
"y": 400
},
"Max Frames Per File": 10000,
"Frame Discard Policy": "discardpartial",
"Frame Padding": 1,
"Scan Parameters": "[disabled]",
"Total Frames": 1000,
"Receiver Roi": {
"xmin": 4294967295,
"xmax": 4294967295,
"ymin": 4294967295,
"ymax": 4294967295
},
"Exptime": "1ms",
"Period": "600us",
"Number of UDP Interfaces": 1,
"Number of rows": 400,
"Additional Json Header": "{detectorMode: counting, frameMode: frame}",
"Frames in File": 1000,
"Frame Header Format": {
"Frame Number": "8 bytes",
"SubFrame Number/ExpLength": "4 bytes",
"Packet Number": "4 bytes",
"Bunch ID": "8 bytes",
"Timestamp": "8 bytes",
"Module Id": "2 bytes",
"Row": "2 bytes",
"Column": "2 bytes",
"Reserved": "2 bytes",
"Debug": "4 bytes",
"Round Robin Number": "2 bytes",
"Detector Type": "1 byte",
"Header Version": "1 byte",
"Packets Caught Mask": "64 bytes"
}
}