aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/detector.c13
-rw-r--r--libcrystfel/src/detector.h9
2 files changed, 15 insertions, 7 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 99205e67..257d1daa 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -312,7 +312,8 @@ double get_tt(struct image *image, double fs, double ss, int *err)
}
-void record_image(struct image *image, int do_poisson, gsl_rng *rng)
+void record_image(struct image *image, int do_poisson, int background,
+ gsl_rng *rng)
{
int x, y;
double total_energy, energy_density;
@@ -345,6 +346,7 @@ void record_image(struct image *image, int do_poisson, gsl_rng *rng)
double pix_area, Lsq;
double xs, ys, rx, ry;
double dsq, proj_area;
+ float dval;
struct panel *p;
intensity = (double)image->data[x + image->width*y];
@@ -378,8 +380,13 @@ void record_image(struct image *image, int do_poisson, gsl_rng *rng)
counts = cf;
}
- image->data[x + image->width*y] = counts * p->adu_per_eV
- * ph_lambda_to_eV(image->lambda);
+ /* Number of photons in pixel */
+ dval = counts + poisson_noise(rng, background);
+
+ /* Convert to ADU */
+ dval *= p->adu_per_eV * ph_lambda_to_eV(image->lambda);
+
+ image->data[x + image->width*y] = dval;
/* Sanity checks */
if ( isinf(image->data[x+image->width*y]) ) n_inf2++;
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index eaa5618e..e44147eb 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -3,12 +3,12 @@
*
* Detector properties
*
- * Copyright © 2012 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
*
* Authors:
- * 2009-2012 Thomas White <taw@physics.org>
+ * 2009-2014 Thomas White <taw@physics.org>
* 2011-2012 Richard Kirian <rkirian@asu.edu>
* 2011 Andrew Aquila
*
@@ -153,7 +153,8 @@ extern double get_tt(struct image *image, double xs, double ys, int *err);
extern int in_bad_region(struct detector *det, double fs, double ss);
-extern void record_image(struct image *image, int do_poisson, gsl_rng *rng);
+extern void record_image(struct image *image, int do_poisson, int background,
+ gsl_rng *rng);
extern struct panel *find_panel(struct detector *det, double fs, double ss);