diff options
author | Thomas White <taw@physics.org> | 2012-03-09 15:58:15 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-03-09 15:58:15 +0100 |
commit | e38375cb0af448c3a7f3667594cf06d1117132c7 (patch) | |
tree | f23e49509f032a84d3f774846106755beea64160 /libcrystfel | |
parent | be33bf078a8ed1ec4c5439095285add97b823fd1 (diff) |
Use ADU per eV in geometry file, rather than ADU per photon in beam file
Conflicts:
src/get_hkl.c
tests/morphology_check.c
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/beam-parameters.c | 15 | ||||
-rw-r--r-- | libcrystfel/src/beam-parameters.h | 3 | ||||
-rw-r--r-- | libcrystfel/src/detector.c | 18 | ||||
-rw-r--r-- | libcrystfel/src/detector.h | 1 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 6 |
5 files changed, 20 insertions, 23 deletions
diff --git a/libcrystfel/src/beam-parameters.c b/libcrystfel/src/beam-parameters.c index 082e9651..654d7550 100644 --- a/libcrystfel/src/beam-parameters.c +++ b/libcrystfel/src/beam-parameters.c @@ -51,8 +51,6 @@ struct beam_params *get_beam_parameters(const char *filename) b->photon_energy = -1.0; b->bandwidth = -1.0; b->divergence = -1.0; - b->dqe = -1.0; - b->adu_per_photon = -1.0; do { @@ -88,10 +86,6 @@ struct beam_params *get_beam_parameters(const char *filename) b->bandwidth = atof(bits[2]); } else if ( strcmp(bits[0], "beam/divergence") == 0 ) { b->divergence = atof(bits[2]); - } else if ( strcmp(bits[0], "detector/dqe") == 0 ) { - b->dqe = atof(bits[2]); - } else if ( strcmp(bits[0], "detector/adu_per_photon") == 0 ) { - b->adu_per_photon = atof(bits[2]); } else { ERROR("Unrecognised field '%s'\n", bits[0]); } @@ -125,15 +119,6 @@ struct beam_params *get_beam_parameters(const char *filename) ERROR("Invalid or unspecified value for 'beam/divergence'.\n"); reject = 1; } - if ( b->dqe < 0.0 ) { - ERROR("Invalid or unspecified value for 'detector/dqe'.\n"); - reject = 1; - } - if ( b->adu_per_photon < 0.0 ) { - ERROR("Invalid or unspecified value for" - " 'detector/adu_per_photon'.\n"); - reject = 1; - } if ( reject ) { ERROR("Please fix the above problems with the beam" diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h index 6f5d8a75..2cf1bf39 100644 --- a/libcrystfel/src/beam-parameters.h +++ b/libcrystfel/src/beam-parameters.h @@ -40,9 +40,6 @@ struct beam_params * a rectangular distribution with this as * its (full) width. */ double divergence; /* divergence (radians) */ - - double dqe; /* Detector DQE (fraction) */ - double adu_per_photon; /* Detector "gain" */ }; diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index ee09eb73..6c4dcbb6 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -365,15 +365,14 @@ void record_image(struct image *image, int do_poisson) sa = proj_area / (dsq + Lsq); if ( do_poisson ) { - counts = poisson_noise(intensity * ph_per_e - * sa * image->beam->dqe ); + counts = poisson_noise(intensity * ph_per_e * sa); } else { - cf = intensity * ph_per_e * sa * image->beam->dqe; + cf = intensity * ph_per_e * sa; counts = cf; } - image->data[x + image->width*y] = counts - * image->beam->adu_per_photon; + image->data[x + image->width*y] = counts * p->adu_per_eV + * ph_lambda_to_eV(image->lambda); /* Sanity checks */ if ( isinf(image->data[x+image->width*y]) ) n_inf2++; @@ -577,6 +576,8 @@ static int parse_field_for_panel(struct panel *panel, const char *key, panel->cnx = atof(val); } else if ( strcmp(key, "corner_y") == 0 ) { panel->cny = atof(val); + } else if ( strcmp(key, "adu_per_eV") == 0 ) { + panel->adu_per_eV = atof(val); } else if ( strcmp(key, "rigid_group") == 0 ) { panel->rigid_group = find_or_add_rg(det, val); } else if ( strcmp(key, "clen") == 0 ) { @@ -737,6 +738,7 @@ struct detector *get_detector_geometry(const char *filename) det->defaults.ssx = 0.0; det->defaults.ssy = 1.0; det->defaults.rigid_group = NULL; + det->defaults.adu_per_eV = NAN; strncpy(det->defaults.name, "", 1023); do { @@ -871,6 +873,11 @@ struct detector *get_detector_geometry(const char *filename) " panel %s\n", det->panels[i].name); reject = 1; } + if ( isnan(det->panels[i].adu_per_eV) ) { + ERROR("Please specify the number of ADU per eV for" + " panel %s\n", det->panels[i].name); + reject = 1; + } /* It's OK if the badrow direction is '0' */ /* It's not a problem if "no_index" is still zero */ /* The default peak_sep is OK (maybe) */ @@ -1242,6 +1249,7 @@ int write_detector_geometry(const char *filename, struct detector *det) fprintf(fh, "%s/ss = %+fx %+fy\n", p->name, p->ssx, p->ssy); 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); if ( p->no_index ) { fprintf(fh, "%s/no_index = 1\n", p->name); diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index 53aca93d..b3743935 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -59,6 +59,7 @@ struct panel double peak_sep; /* Characteristic peak separation */ double integr_radius; /* Peak integration radius */ char *rigid_group; /* Rigid group, or -1 for none */ + double adu_per_eV; /* Number of ADU per eV */ double fsx; double fsy; diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index 8d5ee479..8c11abd6 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -186,6 +186,12 @@ static inline int within_tolerance(double a, double b, double percent) /* Joules to eV */ #define J_to_eV(a) ((a)/ELECTRON_CHARGE) +/* Photon wavelength (m) to energy (eV) */ +#define ph_lambda_to_eV(a) J_to_eV(ph_lambda_to_en(a)) + +/* Photon energy (eV) to wavelength (m) */ +#define ph_eV_to_lambda(a) ph_en_to_lambda(eV_to_J(a)) + #define UNUSED __attribute__((unused)) |