aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-11 17:15:39 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit7617a4adccf8f6cb3845c1ac018abae949dafef1 (patch)
treedeaaad55ba44eead36763c32ff3d5705a90c4354 /libcrystfel/src/image.c
parent46ac0a2dc406df8ceecad409ab30251d6e7c0680 (diff)
Set up adu_per_photon correctly
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r--libcrystfel/src/image.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index d8e97291..a7f15e0d 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -424,7 +424,25 @@ static void create_detgeom(struct image *image, DataTemplate *dtempl)
detgeom->panels[i].cnz /= detgeom->panels[i].pixel_pitch;
detgeom->panels[i].max_adu = dtempl->panels[i].max_adu;
- detgeom->panels[i].adu_per_photon = 1.0; /* FIXME ! */
+
+ switch ( dtempl->panels[i].adu_scale_unit ) {
+
+ case ADU_PER_PHOTON:
+ detgeom->panels[i].adu_per_photon = dtempl->panels[i].adu_scale;
+ break;
+
+ case ADU_PER_EV:
+ detgeom->panels[i].adu_per_photon = dtempl->panels[i].adu_scale
+ * ph_lambda_to_eV(image->lambda);
+ break;
+
+ default:
+ detgeom->panels[i].adu_per_photon = 1.0;
+ ERROR("Invalid ADU/ph scale unit (%i)\n",
+ dtempl->panels[i].adu_scale_unit);
+ break;
+
+ }
detgeom->panels[i].w = dtempl->panels[i].orig_max_fs
- dtempl->panels[i].orig_min_fs + 1;
@@ -440,7 +458,6 @@ static void create_detgeom(struct image *image, DataTemplate *dtempl)
}
- image->lambda = get_wavelength(image, dtempl->wavelength_from);
image->detgeom = detgeom;
/* FIXME: spectrum */
@@ -474,6 +491,9 @@ struct image *image_read(DataTemplate *dtempl, const char *filename,
if ( image == NULL ) return NULL;
+ /* Wavelength might be needed to create detgeom (adu_per_eV) */
+ image->lambda = get_wavelength(image, dtempl->wavelength_from);
+
create_detgeom(image, dtempl);
image->bad = malloc(dtempl->n_panels * sizeof(int *));