aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-02-12 17:24:56 +0100
committerThomas White <taw@physics.org>2015-02-12 18:08:34 +0100
commitafc554d3a541adb10e8bd534fd1fc430811abe57 (patch)
tree080d67d2621030e1aa6d510228ebb30c7871dd57
parentf8afaab03212e7ec2aec8957d6b4d0c1c42fc934 (diff)
Add panel name for bad regions
-rw-r--r--doc/man/crystfel_geometry.54
-rw-r--r--libcrystfel/src/detector.c73
-rw-r--r--libcrystfel/src/detector.h5
3 files changed, 44 insertions, 38 deletions
diff --git a/doc/man/crystfel_geometry.5 b/doc/man/crystfel_geometry.5
index 44fe4450..c02cb474 100644
--- a/doc/man/crystfel_geometry.5
+++ b/doc/man/crystfel_geometry.5
@@ -197,7 +197,9 @@ mask_bad = 0x00
.SH BAD REGIONS
-You can also specify bad regions. Peaks with centroid locations within such a region will not be integrated nor used for indexing. Bad regions are specified in pixel units, either in the lab coordinate system (see above) or in fast scan/slow scan coordinates (mixtures are not allowed). In the latter case, the range of pixels is specified \fIinclusively\fR. Bad regions are distinguished from normal panels by the fact that they begin with the three letters "bad".
+You can also specify bad regions. Bad regions will be completely ignored by CrystFEL. Bad regions are specified in pixel units, either in the lab coordinate system (see above) or in fast scan/slow scan coordinates (mixtures are not allowed). In the latter case, the range of pixels is specified \fIinclusively\fR. Bad regions are distinguished from normal panels by the fact that they begin with the three letters "bad".
+.PP
+You can specify a panel name for the bad region, in which case the pixels will only be considered bad if they are within the range you specify \fIand\fR in the panel you specify. This might be necessary if your HDF5 file layout has overlapping ranges of fs/ss coordinates for different panels (e.g. if the data blocks for the panels are in different HDF5 datasets).
Examples:
.br
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 78ada5c0..e7d53343 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -339,16 +339,23 @@ int in_bad_region(struct detector *det, double fs, double ss)
struct badregion *b = &det->bad[i];
+ if ( (b->panel != NULL)
+ && (strcmp(b->panel, p->name) != 0) ) continue;
+
if ( b->is_fsss ) {
+
if ( fs < b->min_fs ) continue;
if ( fs > b->max_fs ) continue;
if ( ss < b->min_ss ) continue;
if ( ss > b->max_ss ) continue;
+
} else {
+
if ( rx < b->min_x ) continue;
if ( rx > b->max_x ) continue;
if ( ry < b->min_y ) continue;
if ( ry > b->max_y ) continue;
+
}
return 1;
@@ -681,7 +688,8 @@ static struct badregion *new_bad_region(struct detector *det, const char *name)
new->max_fs = 0;
new->min_ss = 0;
new->max_ss = 0;
- new->is_fsss = 0;
+ new->is_fsss = 99; /* Slightly nasty: means "unassigned" */
+ new->panel = NULL;
strcpy(new->name, name);
return new;
@@ -952,6 +960,23 @@ static int parse_field_for_panel(struct panel *panel, const char *key,
}
+static int check_badr_fsss(struct badregion *badr, int is_fsss)
+{
+ /* First assignment? */
+ if ( badr->is_fsss == 99 ) {
+ badr->is_fsss = is_fsss;
+ return 0;
+ }
+
+ if ( is_fsss != badr->is_fsss ) {
+ ERROR("You can't mix x/y and fs/ss in a bad region.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+
static int parse_field_bad(struct badregion *badr, const char *key,
const char *val)
{
@@ -959,36 +984,30 @@ static int parse_field_bad(struct badregion *badr, const char *key,
if ( strcmp(key, "min_x") == 0 ) {
badr->min_x = atof(val);
- if ( badr->is_fsss ) {
- ERROR("You can't mix x/y and fs/ss in a bad region.\n");
- }
+ reject = check_badr_fsss(badr, 0);
} else if ( strcmp(key, "max_x") == 0 ) {
badr->max_x = atof(val);
- if ( badr->is_fsss ) {
- ERROR("You can't mix x/y and fs/ss in a bad region.\n");
- }
+ reject = check_badr_fsss(badr, 0);
} else if ( strcmp(key, "min_y") == 0 ) {
badr->min_y = atof(val);
- if ( badr->is_fsss ) {
- ERROR("You can't mix x/y and fs/ss in a bad region.\n");
- }
+ reject = check_badr_fsss(badr, 0);
} else if ( strcmp(key, "max_y") == 0 ) {
badr->max_y = atof(val);
- if ( badr->is_fsss ) {
- ERROR("You can't mix x/y and fs/ss in a bad region.\n");
- }
+ reject = check_badr_fsss(badr, 0);
} else if ( strcmp(key, "min_fs") == 0 ) {
badr->min_fs = atof(val);
- badr->is_fsss = 1;
+ reject = check_badr_fsss(badr, 1);
} else if ( strcmp(key, "max_fs") == 0 ) {
badr->max_fs = atof(val);
- badr->is_fsss = 1;
+ reject = check_badr_fsss(badr, 1);
} else if ( strcmp(key, "min_ss") == 0 ) {
badr->min_ss = atof(val);
- badr->is_fsss = 1;
+ reject = check_badr_fsss(badr, 1);
} else if ( strcmp(key, "max_ss") == 0 ) {
badr->max_ss = atof(val);
- badr->is_fsss = 1;
+ reject = check_badr_fsss(badr, 1);
+ } else if ( strcmp(key, "panel") == 0 ) {
+ badr->panel = strdup(val);
} else {
ERROR("Unrecognised field '%s'\n", key);
}
@@ -1511,24 +1530,8 @@ struct detector *get_detector_geometry(const char *filename,
}
for ( i=0; i<det->n_bad; i++ ) {
-
- if ( !det->bad[i].is_fsss && isnan(det->bad[i].min_x) ) {
- ERROR("Please specify the minimum x coordinate for"
- " bad region %s\n", det->bad[i].name);
- reject = 1;
- }
- if ( !det->bad[i].is_fsss && isnan(det->bad[i].min_y) ) {
- ERROR("Please specify the minimum y coordinate for"
- " bad region %s\n", det->bad[i].name);
- reject = 1;
- }
- if ( !det->bad[i].is_fsss && isnan(det->bad[i].max_x) ) {
- ERROR("Please specify the maximum x coordinate for"
- " bad region %s\n", det->bad[i].name);
- reject = 1;
- }
- if ( !det->bad[i].is_fsss && isnan(det->bad[i].max_y) ) {
- ERROR("Please specify the maximum y coordinate for"
+ if ( det->bad[i].is_fsss == 99 ) {
+ ERROR("Please specify the coordinate ranges for"
" bad region %s\n", det->bad[i].name);
reject = 1;
}
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index a82134bf..8f4d009c 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -3,12 +3,12 @@
*
* Detector properties
*
- * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
*
* Authors:
- * 2009-2014 Thomas White <taw@physics.org>
+ * 2009-2015 Thomas White <taw@physics.org>
* 2011-2012 Richard Kirian <rkirian@asu.edu>
* 2014 Valerio Mariani
* 2011 Andrew Aquila
@@ -131,6 +131,7 @@ struct badregion
{
char name[1024];
int is_fsss;
+ char *panel;
double min_x;
double max_x;