This commit is contained in:
froejdh_e
2024-12-10 17:21:05 +01:00
parent b43003966f
commit 6a150e8d98
7 changed files with 268 additions and 98 deletions

View File

@ -1,15 +1,53 @@
import sys
sys.path.append('/home/l_msdetect/erik/aare/build')
#Our normal python imports
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
from pathlib import Path
from aare import ClusterFile
import boost_histogram as bh
import time
base = Path('~/data/aare_test_data/clusters').expanduser()
from aare import File, ClusterFinder, VarClusterFinder
f = ClusterFile(base / 'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust')
# f = ClusterFile(base / 'single_frame_97_clustrers.clust')
base = Path('/mnt/sls_det_storage/matterhorn_data/aare_test_data/')
f = File(base/'Moench03new/cu_half_speed_master_4.json')
cf = ClusterFinder((400,400), (3,3))
for i in range(1000):
cf.push_pedestal_frame(f.read_frame())
fig, ax = plt.subplots()
im = ax.imshow(cf.pedestal())
cf.pedestal()
cf.noise()
N = 200
t0 = time.perf_counter()
hist1 = bh.Histogram(bh.axis.Regular(40, -2, 4000))
f.seek(0)
t0 = time.perf_counter()
data = f.read_n(N)
t_elapsed = time.perf_counter()-t0
print(f'Reading {N} frames took {t_elapsed:.3f}s {N/t_elapsed:.0f} FPS')
clusters = []
for frame in data:
clusters += [cf.find_clusters_without_threshold(frame)]
for i in range(10):
fn, cl = f.read_frame()
print(fn, cl.size)
t_elapsed = time.perf_counter()-t0
print(f'Clustering {N} frames took {t_elapsed:.2f}s {N/t_elapsed:.0f} FPS')
t0 = time.perf_counter()
total_clusters = 0
for cl in clusters:
arr = np.array(cl, copy = False)
hist1.fill(arr['data'].sum(axis = 1).sum(axis = 1))
total_clusters += cl.size
# t_elapsed = time.perf_counter()-t0
print(f'Filling histogram with {total_clusters} clusters took: {t_elapsed:.3f}s')
print(f'Cluster per frame {total_clusters/N:.3f}')