aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-05-05 13:42:54 +0200
committerThomas White <taw@physics.org>2017-05-05 16:45:05 +0200
commit9104fb61c53f7d7d8fcb32627a7f87c2062ef496 (patch)
tree89dcb0b3892a78c8a09cbd33fdf2b97b7f3913ee /libcrystfel/src/image.c
parentbb552aba7ac926bfae331b5648abd8647ba1d9f5 (diff)
Fill in photon energy, clen and adu for CBFs
This needed a bit of reorganisation and clarification of who is repsonsible for loading what. The low-level file loaders, e.g. hdf5_read and hdf5_read2 in hdf5-file.c or cbf_read in image.c, are responsible. There is a helper function adjust_centering_for_rail in detector.h which they can use. It seems like this could be done more cleanly at the imagefile layer. However, we need to make sure that the "old" hdfile API still works on its own, even when not accessed via the new imagefile API.
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r--libcrystfel/src/image.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index a8c278fc..849d95bf 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -521,6 +521,48 @@ static int unpack_panels(struct image *image, signed int *data, int data_width)
}
+static void cbf_fill_in_beam_parameters(struct beam_params *beam,
+ struct imagefile *f,
+ struct image *image)
+{
+ double eV;
+
+ if ( beam->photon_energy_from == NULL ) {
+
+ /* Explicit value given */
+ eV = beam->photon_energy;
+
+ } else {
+
+ ERROR("Can't get photon energy from CBF yet.\n");
+ eV = 0.0;
+
+ }
+
+ image->lambda = ph_en_to_lambda(eV_to_J(eV))*beam->photon_energy_scale;
+}
+
+
+static void cbf_fill_in_clen(struct detector *det, struct imagefile *f)
+{
+ int i;
+
+ for ( i=0; i<det->n_panels; i++ ) {
+
+ struct panel *p = &det->panels[i];
+
+ if ( p->clen_from != NULL ) {
+
+ ERROR("Can't get clen from CBF yet.\n");
+
+ }
+
+ adjust_centering_for_rail(p);
+
+ }
+}
+
+
static int read_cbf(struct imagefile *f, struct image *image)
{
cbf_handle cbfh;
@@ -617,6 +659,17 @@ static int read_cbf(struct imagefile *f, struct image *image)
unpack_panels(image, data, dimfast);
free(data);
+ if ( image->beam != NULL ) {
+ cbf_fill_in_beam_parameters(image->beam, f, image);
+ if ( image->lambda > 1000 ) {
+ ERROR("WARNING: Missing or nonsensical wavelength "
+ "(%e m) for %s.\n",
+ image->lambda, image->filename);
+ }
+ }
+ cbf_fill_in_clen(image->det, f);
+ fill_in_adu(image);
+
cbf_free_handle(cbfh);
return 0;
}