diff options
author | Thomas White <taw@physics.org> | 2014-01-23 15:30:29 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-01-23 16:07:37 +0100 |
commit | 762ed2c39f48e226ddeab459e9b00dbc20b9eaef (patch) | |
tree | 5dcc70e7736610145b931e9f6fbce1d6f6dc708a /libcrystfel | |
parent | 3776f8cbfd41798a1591a1a5a337fffef3322bd5 (diff) |
pattern_sim: Add --background
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/detector.c | 13 | ||||
-rw-r--r-- | libcrystfel/src/detector.h | 9 |
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); |