From 934e9aeee2232692f289ef0faef2280017617d80 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 21 May 2012 15:52:06 +0200 Subject: ADU limit in peak integration --- libcrystfel/src/detector.c | 3 +++ libcrystfel/src/detector.h | 1 + libcrystfel/src/peaks.c | 6 ++++++ 3 files changed, 10 insertions(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 94af656f..06ef3a36 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -606,6 +606,8 @@ static int parse_field_for_panel(struct panel *panel, const char *key, panel->coffset = atof(val); } else if ( strcmp(key, "res") == 0 ) { panel->res = atof(val); + } else if ( strcmp(key, "max_adu") == 0 ) { + panel->max_adu = atof(val); } else if ( strcmp(key, "peak_sep") == 0 ) { panel->peak_sep = atof(val); } else if ( strcmp(key, "badrow_direction") == 0 ) { @@ -743,6 +745,7 @@ struct detector *get_detector_geometry(const char *filename) det->defaults.ssy = 1.0; det->defaults.rigid_group = NULL; det->defaults.adu_per_eV = NAN; + det->defaults.max_adu = +INFINITY; strncpy(det->defaults.name, "", 1023); do { diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index 02d66cd4..2b4ac5c6 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -65,6 +65,7 @@ struct panel double peak_sep; /* Characteristic peak separation */ char *rigid_group; /* Rigid group, or -1 for none */ double adu_per_eV; /* Number of ADU per eV */ + double max_adu; /* Treat pixel as unreliable if higher than this */ double fsx; double fsy; diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 78a68185..91a8c949 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -211,6 +211,9 @@ static int integrate_peak(struct image *image, int cfs, int css, val = image->data[idx]; + /* Veto peak if it contains saturation in bg region */ + if ( val > p->max_adu ) return 1; + bg_tot += val; bg_tot_sq += pow(val, 2.0); bg_counts++; @@ -259,6 +262,9 @@ static int integrate_peak(struct image *image, int cfs, int css, val = image->data[idx] - bg_mean; + /* Veto peak if it contains saturation */ + if ( val > p->max_adu ) return 1; + pk_counts++; pk_total += val; -- cgit v1.2.3 From 146e47c3180cca8f574a861d760e944261ad81ac Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 21 May 2012 16:03:56 +0200 Subject: Write max_adu out to saved geometry file --- libcrystfel/src/detector.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 06ef3a36..b7d809df 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1257,6 +1257,7 @@ int write_detector_geometry(const char *filename, struct detector *det) fprintf(fh, "%s/corner_x = %g\n", p->name, p->cnx); fprintf(fh, "%s/corner_y = %g\n", p->name, p->cny); fprintf(fh, "%s/adu_per_eV = %g\n", p->name, p->adu_per_eV); + fprintf(fh, "%s/max_adu = %g\n", p->name, p->max_adu); if ( p->no_index ) { fprintf(fh, "%s/no_index = 1\n", p->name); -- cgit v1.2.3 From 3bc13230355c2be24549e09663295f3cdaee74dc Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 21 May 2012 16:04:05 +0200 Subject: ADU threshold is on pixel value, not photon-bg subtracted version --- libcrystfel/src/peaks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 91a8c949..477d9345 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -263,7 +263,7 @@ static int integrate_peak(struct image *image, int cfs, int css, val = image->data[idx] - bg_mean; /* Veto peak if it contains saturation */ - if ( val > p->max_adu ) return 1; + if ( image->data[idx] > p->max_adu ) return 1; pk_counts++; pk_total += val; -- cgit v1.2.3