format
This commit is contained in:
parent
6013f94d01
commit
b21ae3da2e
13
README.md
13
README.md
@ -33,3 +33,16 @@ conda develop install .
|
||||
#or with pip
|
||||
pip install --editable .
|
||||
```
|
||||
|
||||
## Cluster file specifications
|
||||
|
||||
```
|
||||
[int32 frame_number][int32 n_clusters][clusters....]
|
||||
|
||||
// Cluster data type
|
||||
typedef struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int32_t data[9];
|
||||
} Cluster ;
|
||||
```
|
@ -2,7 +2,8 @@
|
||||
|
||||
int read_clusters(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left) {
|
||||
#ifdef CR_VERBOSE
|
||||
printf("Item size: %lu n_clusters: %lld, n_left: %d\n", sizeof(Cluster), n_clusters,*n_left);
|
||||
printf("Item size: %lu n_clusters: %lld, n_left: %d\n", sizeof(Cluster),
|
||||
n_clusters, *n_left);
|
||||
#endif
|
||||
int iframe = 0, nph = *n_left;
|
||||
size_t n_read = 0, nph_read = 0, nn = *n_left, nr = 0;
|
||||
@ -61,10 +62,14 @@ int analyze_clusters(int64_t n_clusters, Cluster* cin, ClusterAnalysis *cout){
|
||||
for (int iy = 0; iy < 3; iy++) {
|
||||
val = (cin + ic)->data[iy * 3 + ix];
|
||||
tot3 += val;
|
||||
if (ix<=1 && iy<=1) tot2[0]+=val;
|
||||
if (ix>=1 && iy<=1) tot2[1]+=val;
|
||||
if (ix<=1 && iy>=1) tot2[2]+=val;
|
||||
if (ix>=1 && iy>=1) tot2[3]+=val;
|
||||
if (ix <= 1 && iy <= 1)
|
||||
tot2[0] += val;
|
||||
if (ix >= 1 && iy <= 1)
|
||||
tot2[1] += val;
|
||||
if (ix <= 1 && iy >= 1)
|
||||
tot2[2] += val;
|
||||
if (ix >= 1 && iy >= 1)
|
||||
tot2[3] += val;
|
||||
}
|
||||
}
|
||||
t2max = tot2[0];
|
||||
@ -78,10 +83,8 @@ int analyze_clusters(int64_t n_clusters, Cluster* cin, ClusterAnalysis *cout){
|
||||
(cout + ic)->c = c;
|
||||
(cout + ic)->tot2 = t2max;
|
||||
(cout + ic)->tot3 = tot3;
|
||||
//printf("%d %d %d %d %d %d\n",ic,(cin+ic)->x, (cin+ic)->y, (cout+ic)->c, (cout+ic)->tot2, (cout+ic)->tot3);
|
||||
|
||||
// printf("%d %d %d %d %d %d\n",ic,(cin+ic)->x, (cin+ic)->y,
|
||||
// (cout+ic)->c, (cout+ic)->tot2, (cout+ic)->tot3);
|
||||
}
|
||||
return n_clusters;
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,3 +9,20 @@ def test_references_on_read(data_path):
|
||||
clusters = r.read(10)
|
||||
assert sys.getrefcount(clusters) == 2 #Over counts by one due to call by reference
|
||||
|
||||
def test_size_on_read(data_path):
|
||||
fname= (data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust').as_posix()
|
||||
r = ClusterFileReader(fname)
|
||||
|
||||
for i in range(10):
|
||||
clusters = r.read(10)
|
||||
assert clusters.size == 10
|
||||
|
||||
def test_resize_on_read(data_path):
|
||||
# File contains 481603 clusters, output should be resized to the correct size
|
||||
fname= (data_path/'beam_En700eV_-40deg_300V_10us_d0_f0_100.clust').as_posix()
|
||||
r = ClusterFileReader(fname)
|
||||
|
||||
max_clusters = 10000000 #400MB initial allocation
|
||||
clusters = r.read(max_clusters)
|
||||
assert clusters.size == 481603
|
||||
assert sys.getrefcount(clusters) == 2
|
Reference in New Issue
Block a user