fixing warnings
This commit is contained in:
parent
9eaa163e4e
commit
916ec20a1c
@ -6,7 +6,7 @@
|
|||||||
//clang-format off
|
//clang-format off
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD FILE *fp;
|
PyObject_HEAD FILE *fp;
|
||||||
int n_left;
|
size_t n_left;
|
||||||
Py_ssize_t chunk;
|
Py_ssize_t chunk;
|
||||||
} ClusterFileReader;
|
} ClusterFileReader;
|
||||||
//clang-format on
|
//clang-format on
|
||||||
@ -18,7 +18,7 @@ static int ClusterFileReader_init(ClusterFileReader *self, PyObject *args,
|
|||||||
PyObject *kwds) {
|
PyObject *kwds) {
|
||||||
|
|
||||||
// Parse file name, accepts string or pathlike objects
|
// Parse file name, accepts string or pathlike objects
|
||||||
const char *fname = NULL;
|
char *fname = NULL;
|
||||||
self->n_left = 0;
|
self->n_left = 0;
|
||||||
self->chunk = 0;
|
self->chunk = 0;
|
||||||
PyObject *fname_obj = NULL;
|
PyObject *fname_obj = NULL;
|
||||||
@ -27,9 +27,6 @@ static int ClusterFileReader_init(ClusterFileReader *self, PyObject *args,
|
|||||||
|
|
||||||
static char *kwlist[] = {"fname", "chunk", NULL};
|
static char *kwlist[] = {"fname", "chunk", NULL};
|
||||||
|
|
||||||
// if (!PyArg_ParseTuple(args, "O&", PyUnicode_FSConverter, &buf))
|
|
||||||
// return -1;
|
|
||||||
// PyBytes_AsStringAndSize(buf, &fname, &len);
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n", kwlist, &fname_obj,
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n", kwlist, &fname_obj,
|
||||||
&self->chunk)) {
|
&self->chunk)) {
|
||||||
@ -45,7 +42,7 @@ static int ClusterFileReader_init(ClusterFileReader *self, PyObject *args,
|
|||||||
printf("Opening: %s\n chunk: %lu\n", fname, self->chunk);
|
printf("Opening: %s\n chunk: %lu\n", fname, self->chunk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
self->fp = fopen(fname, "rb");
|
self->fp = fopen((const char*)fname, "rb");
|
||||||
|
|
||||||
|
|
||||||
// Keep the return code to not return before releasing buffer
|
// Keep the return code to not return before releasing buffer
|
||||||
|
@ -22,7 +22,7 @@ static int RawFileReader_init(RawFileReader *self, PyObject *args,
|
|||||||
PyObject *kwds) {
|
PyObject *kwds) {
|
||||||
|
|
||||||
// Parse file name, accepts string or pathlike objects
|
// Parse file name, accepts string or pathlike objects
|
||||||
const char *fname = NULL;
|
char *fname = NULL;
|
||||||
PyObject *fname_obj = NULL;
|
PyObject *fname_obj = NULL;
|
||||||
PyObject *fname_bytes = NULL;
|
PyObject *fname_bytes = NULL;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
@ -48,7 +48,7 @@ static int RawFileReader_init(RawFileReader *self, PyObject *args,
|
|||||||
printf("fname: %s\n read_header: %d detector type: %d\n", fname,
|
printf("fname: %s\n read_header: %d detector type: %d\n", fname,
|
||||||
self->read_header, self->detector);
|
self->read_header, self->detector);
|
||||||
#endif
|
#endif
|
||||||
self->fp = fopen(fname, "rb");
|
self->fp = fopen((const char*)fname, "rb");
|
||||||
|
|
||||||
// Keep the return code to not return before releasing buffer
|
// Keep the return code to not return before releasing buffer
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@ -110,12 +110,12 @@ static PyObject *RawFileReader_read(RawFileReader *self, PyObject *args) {
|
|||||||
|
|
||||||
switch (self->detector) {
|
switch (self->detector) {
|
||||||
case DT_MOENCH_03:
|
case DT_MOENCH_03:
|
||||||
n_read = read_raw_m03(self->fp, n_frames, out_buf, header_out);
|
n_read = read_raw_m03(self->fp, n_frames, out_buf, (Header*)header_out);
|
||||||
break;
|
break;
|
||||||
case DT_MOENCH_04_A:
|
case DT_MOENCH_04_A:
|
||||||
case DT_MOENCH_04_AD:
|
case DT_MOENCH_04_AD:
|
||||||
n_read =
|
n_read =
|
||||||
read_raw_m04(self->fp, n_frames, out_buf, digital_out, header_out);
|
read_raw_m04(self->fp, n_frames, out_buf, digital_out, (Header*)header_out);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "cluster_reader.h"
|
#include "cluster_reader.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int read_clusters(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left) {
|
size_t read_clusters(FILE *fp, size_t n_clusters, Cluster *buf, size_t *n_left) {
|
||||||
int iframe = 0;
|
int iframe = 0;
|
||||||
int nph = *n_left;
|
size_t nph = *n_left;
|
||||||
|
|
||||||
size_t nph_read = 0;
|
size_t nph_read = 0;
|
||||||
size_t nn = *n_left;
|
size_t nn = *n_left;
|
||||||
@ -44,23 +44,27 @@ int read_clusters(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_left) {
|
|||||||
return nph_read;
|
return nph_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf,
|
size_t read_clusters_with_cut(FILE *fp, size_t n_clusters, Cluster *buf,
|
||||||
int *n_left, double *noise_map, int nx, int ny) {
|
size_t *n_left, double *noise_map, int nx, int ny) {
|
||||||
int iframe = 0;
|
int iframe = 0;
|
||||||
int nph = *n_left;
|
size_t nph = *n_left;
|
||||||
|
|
||||||
size_t nph_read = 0;
|
size_t nph_read = 0;
|
||||||
|
|
||||||
int32_t tot2[4], t2max, tot1;
|
int32_t t2max, tot1;
|
||||||
int32_t val, tot3;
|
int32_t tot3;
|
||||||
Cluster *ptr = buf;
|
Cluster *ptr = buf;
|
||||||
int good = 1;
|
int good = 1;
|
||||||
double noise;
|
double noise;
|
||||||
// read photons left from previous frame
|
// read photons left from previous frame
|
||||||
if (nph) {
|
if (nph) {
|
||||||
for (int iph = 0; iph < nph; iph++) {
|
for (size_t iph = 0; iph < nph; iph++) {
|
||||||
// read photons 1 by 1
|
// read photons 1 by 1
|
||||||
fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
size_t n_read = fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
||||||
|
if (n_read != 1) {
|
||||||
|
return nph_read;
|
||||||
|
}
|
||||||
|
//TODO! error handling on read
|
||||||
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) {
|
||||||
@ -95,9 +99,12 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf,
|
|||||||
if (fread(&nph, sizeof(nph), 1, fp)) {
|
if (fread(&nph, sizeof(nph), 1, fp)) {
|
||||||
//printf("** %d\n",nph);
|
//printf("** %d\n",nph);
|
||||||
*n_left = nph;
|
*n_left = nph;
|
||||||
for (int iph=0; iph<nph; iph++) {
|
for (size_t iph=0; iph<nph; iph++) {
|
||||||
// read photons 1 by 1
|
// read photons 1 by 1
|
||||||
fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
size_t n_read = fread((void *)(ptr), sizeof(Cluster), 1, fp);
|
||||||
|
if (n_read != 1) {
|
||||||
|
return nph_read;
|
||||||
|
}
|
||||||
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) {
|
||||||
@ -140,10 +147,8 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf,
|
|||||||
|
|
||||||
|
|
||||||
int analyze_clusters(int64_t n_clusters, int32_t *cin, ClusterAnalysis *co, int csize) {
|
int analyze_clusters(int64_t n_clusters, int32_t *cin, ClusterAnalysis *co, int csize) {
|
||||||
|
|
||||||
int32_t tot2[4], t2max;
|
|
||||||
char quad;
|
char quad;
|
||||||
int32_t val, tot;
|
int32_t tot;
|
||||||
double etax, etay;
|
double etax, etay;
|
||||||
int nc=0;
|
int nc=0;
|
||||||
//printf("csize is %d\n",csize);
|
//printf("csize is %d\n",csize);
|
||||||
@ -186,16 +191,16 @@ int analyze_data(int32_t *data, int32_t *t2, int32_t *t3, char *quad, double *et
|
|||||||
|
|
||||||
int ok=1;
|
int ok=1;
|
||||||
|
|
||||||
int32_t tot2[4], t2max;
|
int32_t tot2[4];
|
||||||
|
int32_t t2max=0;
|
||||||
char c;
|
char c;
|
||||||
int32_t val, tot3;
|
int32_t val, tot3;
|
||||||
|
|
||||||
tot3 = 0;
|
tot3 = 0;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
tot2[i] = 0;
|
tot2[i] = 0;
|
||||||
// t2max=0;
|
|
||||||
for (int ix = 0; ix < 3; ix++) {
|
|
||||||
|
|
||||||
|
for (int ix = 0; ix < 3; ix++) {
|
||||||
for (int iy = 0; iy < 3; iy++) {
|
for (int iy = 0; iy < 3; iy++) {
|
||||||
val = data[iy * 3 + ix];
|
val = data[iy * 3 + ix];
|
||||||
// printf ("%d ",data[iy * 3 + ix]);
|
// printf ("%d ",data[iy * 3 + ix]);
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "data_types.h"
|
#include "data_types.h"
|
||||||
//Pure C implementation to read a cluster file
|
//Pure C implementation to read a cluster file
|
||||||
|
|
||||||
int read_clusters(FILE* fp, int64_t n_clusters, Cluster* buf, int *n_left);
|
size_t read_clusters(FILE* fp, size_t n_clusters, Cluster* buf, size_t *n_left);
|
||||||
|
|
||||||
int read_clusters_with_cut(FILE* fp, int64_t n_clusters, Cluster* buf, int *n_left, double *noise_map, int nx, int ny);
|
size_t read_clusters_with_cut(FILE* fp, size_t n_clusters, Cluster* buf, size_t *n_left, double *noise_map, int nx, int ny);
|
||||||
|
|
||||||
int analyze_clusters(int64_t n_clusters, int32_t* cin, ClusterAnalysis *cout, int csize);
|
int analyze_clusters(int64_t n_clusters, int32_t* cin, ClusterAnalysis *cout, int csize);
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ int64_t read_raw_m04(FILE *fp, int64_t n_frames, char *frame_out,
|
|||||||
|
|
||||||
const size_t frame_size = 400 * 400 * 2;
|
const size_t frame_size = 400 * 400 * 2;
|
||||||
const size_t digital_frame_size = 5000 * 8;
|
const size_t digital_frame_size = 5000 * 8;
|
||||||
char *tmp = malloc(frame_size);
|
void *tmp = malloc(frame_size);
|
||||||
char *digital_tmp = malloc(digital_frame_size);
|
void *digital_tmp = malloc(digital_frame_size);
|
||||||
Header h;
|
Header h;
|
||||||
|
|
||||||
int64_t frames_read = 0;
|
int64_t frames_read = 0;
|
||||||
@ -75,7 +75,7 @@ int64_t read_raw_m04(FILE *fp, int64_t n_frames, char *frame_out,
|
|||||||
|
|
||||||
// Decode frame and write to numpy output array
|
// Decode frame and write to numpy output array
|
||||||
// decode_moench03((uint16_t *)tmp, (uint16_t *)frame_out);
|
// decode_moench03((uint16_t *)tmp, (uint16_t *)frame_out);
|
||||||
decode_moench04(tmp, digital_tmp, frame_out, digital_out);
|
decode_moench04(tmp, digital_tmp, (uint16_t*)frame_out, (uint8_t*)digital_out);
|
||||||
|
|
||||||
frame_out += frame_size;
|
frame_out += frame_size;
|
||||||
if (digital_out)
|
if (digital_out)
|
||||||
|
Reference in New Issue
Block a user