aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/datatemplate.c8
-rw-r--r--libcrystfel/src/datatemplate_priv.h6
-rw-r--r--libcrystfel/src/image.c24
3 files changed, 27 insertions, 11 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index cfba15ea..b9a30e0e 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -476,9 +476,11 @@ static int parse_field_for_panel(struct panel_template *panel, const char *key,
} else if ( strcmp(key, "clen_for_centering") == 0 ) {
panel->clen_for_centering = atof(val);
} else if ( strcmp(key, "adu_per_eV") == 0 ) {
- panel->adu_per_eV = atof(val);
+ panel->adu_scale = atof(val);
+ panel->adu_scale_unit = ADU_PER_EV;
} else if ( strcmp(key, "adu_per_photon") == 0 ) {
- panel->adu_per_photon = atof(val);
+ panel->adu_scale = atof(val);
+ panel->adu_scale_unit = ADU_PER_PHOTON;
} else if ( strcmp(key, "rigid_group") == 0 ) {
add_to_rigid_group(find_or_add_rg(det, val), panel);
} else if ( strcmp(key, "clen") == 0 ) {
@@ -1075,7 +1077,7 @@ DataTemplate *data_template_new_from_string(const char *string_in)
p->name);
reject = 1;
}
- if ( isnan(p->adu_per_eV) && isnan(p->adu_per_photon) ) {
+ if ( isnan(p->adu_scale) ) {
ERROR("Please specify either adu_per_eV or "
"adu_per_photon for panel %s\n",
dt->panels[i].name);
diff --git a/libcrystfel/src/datatemplate_priv.h b/libcrystfel/src/datatemplate_priv.h
index 574df8b3..64d060b1 100644
--- a/libcrystfel/src/datatemplate_priv.h
+++ b/libcrystfel/src/datatemplate_priv.h
@@ -133,12 +133,6 @@ struct panel_template
int orig_min_ss;
int orig_max_ss;
/*@}*/
-
-
- /* FIXME: Should only be one */
- double adu_per_eV;
- double adu_per_photon;
-
};
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 *));