60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
import numpy as np
|
|
from pathlib import Path
|
|
|
|
from creader import cluster_dt
|
|
|
|
#[int32 frame_number][int32 n_clusters][clusters....]
|
|
# typedef struct {
|
|
# int16_t x;
|
|
# int16_t y;
|
|
# int32_t data[9];
|
|
# } Cluster ;
|
|
|
|
|
|
path = Path('/mnt/sls_det_storage/moench_data/cluster_reader_test/')
|
|
|
|
data = np.zeros(1, cluster_dt())
|
|
data['x'] = 1
|
|
data['y'] = 200
|
|
data['data'] = np.arange(9)
|
|
#Write 10 frames with increadsing number of clusters
|
|
header = np.array((135,97), dtype = np.int32)
|
|
with open(path/'single_frame_97_clustrers.clust', 'wb') as f:
|
|
header.tofile(f)
|
|
for i in range(97):
|
|
print(data)
|
|
data.tofile(f)
|
|
data['x'] += 1
|
|
data['y'] += 1
|
|
data['data'] = np.arange((i+1)*9,(i+2)*9)
|
|
|
|
|
|
header = np.array((135,5), dtype = np.int32)
|
|
with open(path/'37frames_with_5_clusters.clust', 'wb') as f:
|
|
for i in range(37):
|
|
header.tofile(f)
|
|
header[0] += 1
|
|
for j in range(5):
|
|
data['x'] = j+1
|
|
data['y'] = j+1
|
|
data['data'] = np.arange(j,j+9)
|
|
print(data)
|
|
data.tofile(f)
|
|
|
|
#Writing out data to test noise cuts
|
|
header[1] = 7
|
|
|
|
with open(path/'noise_test.clust', 'wb') as f:
|
|
for i in range(10):
|
|
data['x'] = 50
|
|
data['y'] = 133
|
|
data['data'][:] = 50
|
|
|
|
header.tofile(f)
|
|
print(header)
|
|
header[0] += 1
|
|
|
|
for j in range(7):
|
|
print(data)
|
|
data.tofile(f)
|
|
data['x'] += 10 |