aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/hdf5-file.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-04-02 15:55:51 +0200
committerThomas White <taw@physics.org>2019-04-03 15:53:07 +0200
commit0a1a129583fdd191045df501d22a0342f612e548 (patch)
tree30ae20f574ca091c14baa8d45e3b51ddfdf36152 /libcrystfel/src/hdf5-file.c
parente64e2ec6879410dc90c5d87f58268dd3eb2ec521 (diff)
Consider pixel as bad if its value is NaN or infinity
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r--libcrystfel/src/hdf5-file.c16
1 files changed, 12 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 ) {