aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/hdf5-file.c16
-rw-r--r--libcrystfel/src/image.c2
2 files changed, 14 insertions, 4 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 9c8038ea..7a8f359e 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -1149,7 +1149,8 @@ static void debodge_saturation(struct hdfile *f, struct image *image)
}
-static int *make_badmask(int *flags, struct panel *p, struct detector *det)
+static int *make_badmask(int *flags, struct detector *det, float *data,
+ struct panel *p)
{
int *badmap;
int fs, ss;
@@ -1184,6 +1185,7 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
int f = flags[fs+p->w*ss];
int bad = badmap[fs+p->w*ss];
+ float val = data[fs+p->w*ss];
/* Bad if it's missing any of the "good" bits */
if ( (f & det->mask_good) != det->mask_good ) bad = 1;
@@ -1191,6 +1193,9 @@ static int *make_badmask(int *flags, struct panel *p, struct detector *det)
/* Bad if it has any of the "bad" bits. */
if ( f & det->mask_bad ) bad = 1;
+ /* Bad if pixel value is NaN or inf */
+ if ( isnan(val) || isinf(val) ) bad = 1;
+
badmap[fs+p->w*ss] = bad;
}
@@ -1902,13 +1907,16 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev,
if ( p->mask != NULL ) {
int *flags = malloc(p->w*p->h*sizeof(int));
if ( !load_mask(f, ev, p, flags, f_offset, f_count, hsd) ) {
- image->bad[pi] = make_badmask(flags, p, image->det);
+ image->bad[pi] = make_badmask(flags, image->det,
+ image->dp[pi], p);
} else {
- image->bad[pi] = make_badmask(NULL, p, image->det);
+ image->bad[pi] = make_badmask(NULL, image->det,
+ image->dp[pi], p);
}
free(flags);
} else {
- image->bad[pi] = make_badmask(NULL, p, image->det);
+ image->bad[pi] = make_badmask(NULL, image->det,
+ image->dp[pi], p);
}
if ( p->satmap != NULL ) {
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 63fd54f9..8c47d3cf 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -521,6 +521,8 @@ static int unpack_panels(struct image *image, float *data, int data_width,
bad = 1;
}
+ if ( isnan(data[idx]) || isinf(data[idx]) ) bad = 1;
+
if ( flags != NULL ) {
int f;