format
This commit is contained in:
parent
b8a8891c8d
commit
f28acaa3d5
@ -75,8 +75,6 @@ static PyObject *ClusterFileReader_read(ClusterFileReader *self,
|
|||||||
// if data type is different or we pass in a list. The
|
// if data type is different or we pass in a list. The
|
||||||
// NPY_ARRAY_C_CONTIGUOUS flag ensures that we have contiguous memory.
|
// NPY_ARRAY_C_CONTIGUOUS flag ensures that we have contiguous memory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CR_VERBOSE
|
#ifdef CR_VERBOSE
|
||||||
printf("Getting ready to read: %lu clusters. Noise map: %p\n", size,
|
printf("Getting ready to read: %lu clusters. Noise map: %p\n", size,
|
||||||
noise_obj);
|
noise_obj);
|
||||||
@ -134,8 +132,8 @@ static PyObject *ClusterFileReader_read(ClusterFileReader *self,
|
|||||||
// Here goes the looping, removing frame numbers etc.
|
// Here goes the looping, removing frame numbers etc.
|
||||||
int n_read = 0;
|
int n_read = 0;
|
||||||
if (noise_map)
|
if (noise_map)
|
||||||
n_read = read_clusters_with_cut(self->fp, size, buf, &self->n_left, noise_map,
|
n_read = read_clusters_with_cut(self->fp, size, buf, &self->n_left,
|
||||||
nx, ny);
|
noise_map, nx, ny);
|
||||||
else
|
else
|
||||||
n_read = read_clusters(self->fp, size, buf, &self->n_left);
|
n_read = read_clusters(self->fp, size, buf, &self->n_left);
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ int read_clusters(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left) {
|
|||||||
// keep on reading frames and photons until reaching n_clusters
|
// keep on reading frames and photons until reaching n_clusters
|
||||||
while (fread(&iframe, sizeof(iframe), 1, fp)) {
|
while (fread(&iframe, sizeof(iframe), 1, fp)) {
|
||||||
|
|
||||||
|
|
||||||
if (fread(&nph, sizeof(nph), 1, fp)) {
|
if (fread(&nph, sizeof(nph), 1, fp)) {
|
||||||
if (nph > n_clusters - nph_read)
|
if (nph > n_clusters - nph_read)
|
||||||
nn = n_clusters - nph_read;
|
nn = n_clusters - nph_read;
|
||||||
@ -39,18 +38,14 @@ int read_clusters(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left) {
|
|||||||
}
|
}
|
||||||
if (nph_read >= n_clusters)
|
if (nph_read >= n_clusters)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(nph_read <= n_clusters); // sanity check in debug mode
|
assert(nph_read <= n_clusters); // sanity check in debug mode
|
||||||
return nph_read;
|
return nph_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf,
|
||||||
|
int *n_left, double *noise_map, int nx, int ny) {
|
||||||
int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left, double *noise_map, int nx, int ny) {
|
|
||||||
int iframe = 0;
|
int iframe = 0;
|
||||||
int nph = *n_left;
|
int nph = *n_left;
|
||||||
|
|
||||||
@ -70,7 +65,8 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le
|
|||||||
if (noise_map) {
|
if (noise_map) {
|
||||||
if (ptr->x >= 0 && ptr->x < nx && ptr->y >= 0 && ptr->y < ny) {
|
if (ptr->x >= 0 && ptr->x < nx && ptr->y >= 0 && ptr->y < ny) {
|
||||||
tot1 = ptr->data[4];
|
tot1 = ptr->data[4];
|
||||||
analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
noise = noise_map[ptr->y * nx + ptr->x];
|
noise = noise_map[ptr->y * nx + ptr->x];
|
||||||
if (tot1 > noise && t2max > 2 * noise && tot3 > 3 * noise) {
|
if (tot1 > noise && t2max > 2 * noise && tot3 > 3 * noise) {
|
||||||
;
|
;
|
||||||
@ -104,11 +100,15 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le
|
|||||||
fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
||||||
good = 1;
|
good = 1;
|
||||||
if (noise_map) {
|
if (noise_map) {
|
||||||
if (ptr->x>=0 && ptr->x<nx && ptr->y>=0 && ptr->y<ny) {
|
if (ptr->x >= 0 && ptr->x < nx && ptr->y >= 0 &&
|
||||||
|
ptr->y < ny) {
|
||||||
tot1 = ptr->data[4];
|
tot1 = ptr->data[4];
|
||||||
analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
NULL);
|
||||||
noise = noise_map[ptr->y * nx + ptr->x];
|
noise = noise_map[ptr->y * nx + ptr->x];
|
||||||
if (tot1>noise && t2max>2*noise && tot3>3*noise) {
|
if (tot1 > noise && t2max > 2 * noise &&
|
||||||
|
tot3 > 3 * noise) {
|
||||||
;
|
;
|
||||||
} else
|
} else
|
||||||
good = 0;
|
good = 0;
|
||||||
@ -124,7 +124,6 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le
|
|||||||
}
|
}
|
||||||
if (nph_read >= n_clusters)
|
if (nph_read >= n_clusters)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,12 +136,6 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le
|
|||||||
return nph_read;
|
return nph_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) {
|
int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) {
|
||||||
|
|
||||||
int32_t tot2[4], t2max;
|
int32_t tot2[4], t2max;
|
||||||
@ -150,8 +143,8 @@ int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) {
|
|||||||
int32_t val, tot3;
|
int32_t val, tot3;
|
||||||
for (int ic = 0; ic < n_clusters; ic++) {
|
for (int ic = 0; ic < n_clusters; ic++) {
|
||||||
|
|
||||||
|
analyze_cluster(*(cin + ic), &t2max, &tot3, &quad, NULL, NULL, NULL,
|
||||||
analyze_cluster(*(cin+ic), &t2max, &tot3, &quad, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
(cout + ic)->c = quad;
|
(cout + ic)->c = quad;
|
||||||
(cout + ic)->tot2 = t2max;
|
(cout + ic)->tot2 = t2max;
|
||||||
@ -162,10 +155,10 @@ int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) {
|
|||||||
return n_clusters;
|
return n_clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad,
|
||||||
|
double *eta2x, double *eta2y, double *eta3x, double *eta3y,
|
||||||
int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, double *eta2x, double *eta2y, double *eta3x, double *eta3y, double *eta2Lx, double *eta2Ly, double *eta3Xx, double *eta3Xy) {
|
double *eta2Lx, double *eta2Ly, double *eta3Xx,
|
||||||
|
double *eta3Xy) {
|
||||||
|
|
||||||
int ok = 1;
|
int ok = 1;
|
||||||
|
|
||||||
@ -192,8 +185,6 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, double *e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (t2 || quad) {
|
if (t2 || quad) {
|
||||||
t2max = tot2[0];
|
t2max = tot2[0];
|
||||||
c = cBottomLeft;
|
c = cBottomLeft;
|
||||||
@ -211,11 +202,5 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, double *e
|
|||||||
if (t3)
|
if (t3)
|
||||||
*t3 = tot3;
|
*t3 = tot3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "RawFileReader.h"
|
#include "RawFileReader.h"
|
||||||
|
|
||||||
#include "arr_desc.h"
|
#include "arr_desc.h"
|
||||||
#include "data_types.h"
|
|
||||||
#include "cluster_reader.h"
|
#include "cluster_reader.h"
|
||||||
|
#include "data_types.h"
|
||||||
|
|
||||||
static PyObject *clusterize(PyObject *Py_UNUSED(self), PyObject *args) {
|
static PyObject *clusterize(PyObject *Py_UNUSED(self), PyObject *args) {
|
||||||
|
|
||||||
@ -59,7 +59,8 @@ static PyObject *get_cluster_dt(PyObject *Py_UNUSED(self), PyObject *args) {
|
|||||||
return (PyObject *)cluster_dt();
|
return (PyObject *)cluster_dt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *get_frame_header_dt(PyObject *Py_UNUSED(self), PyObject *args) {
|
static PyObject *get_frame_header_dt(PyObject *Py_UNUSED(self),
|
||||||
|
PyObject *args) {
|
||||||
if (!PyArg_ParseTuple(args, ""))
|
if (!PyArg_ParseTuple(args, ""))
|
||||||
return NULL;
|
return NULL;
|
||||||
return (PyObject *)frame_header_dt();
|
return (PyObject *)frame_header_dt();
|
||||||
|
Reference in New Issue
Block a user