aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-09 16:31:54 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit2c9de4119c0fe2338f5f6e54ee91294e3f0f6a74 (patch)
tree333f979756fc66ba594d2e718da6e6e99d0118a9 /libcrystfel
parent1cfbd01c2e0666fe7c888530e937ff4a310725f6 (diff)
Add detector_shift_{x,y} to geometry file
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/datatemplate.c7
-rw-r--r--libcrystfel/src/datatemplate_priv.h4
-rw-r--r--libcrystfel/src/image.c11
3 files changed, 19 insertions, 3 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 65da1a54..cc028025 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -756,6 +756,11 @@ static int parse_toplevel(DataTemplate *dt,
return 1;
}
+ } else if ( strcmp(key, "detector_shift_x") == 0 ) {
+ dt->shift_x_from = strdup(val);
+
+ } else if ( strcmp(key, "detector_shift_y") == 0 ) {
+ dt->shift_y_from = strdup(val);
} else if ( strcmp(key, "photon_energy") == 0 ) {
return parse_photon_energy(val,
@@ -872,6 +877,8 @@ DataTemplate *data_template_new_from_string(const char *string_in)
dt->rigid_group_collections = NULL;
dt->photon_energy_bandwidth = -1.0;
dt->peak_list = NULL;
+ dt->shift_x_from = NULL;
+ dt->shift_y_from = NULL;
/* The default defaults... */
defaults.orig_min_fs = -1;
diff --git a/libcrystfel/src/datatemplate_priv.h b/libcrystfel/src/datatemplate_priv.h
index 75492db5..e9ce3ccb 100644
--- a/libcrystfel/src/datatemplate_priv.h
+++ b/libcrystfel/src/datatemplate_priv.h
@@ -202,6 +202,10 @@ struct _datatemplate
int n_rg_collections;
char *peak_list;
+
+ /* Shift of whole detector, in m */
+ char * shift_x_from;
+ char * shift_y_from;
};
#endif /* DATATEMPLATE_PRIV_H */
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 47cbfea7..b70b920f 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -340,7 +340,8 @@ static char *get_value_and_units(struct image *image, const char *from,
}
-static double get_length(struct image *image, const char *from)
+static double get_length(struct image *image, const char *from,
+ double default_scale)
{
char *units;
double value;
@@ -348,7 +349,7 @@ static double get_length(struct image *image, const char *from)
units = get_value_and_units(image, from, &value);
if ( units == NULL ) {
- scale = 1.0e-3;
+ scale = default_scale;
} else {
if ( strcmp(units, "mm") == 0 ) {
scale = 1e-3;
@@ -421,13 +422,17 @@ void create_detgeom(struct image *image, const DataTemplate *dtempl)
/* NB cnx,cny are in pixels, cnz is in m */
detgeom->panels[i].cnx = dtempl->panels[i].cnx;
detgeom->panels[i].cny = dtempl->panels[i].cny;
- detgeom->panels[i].cnz = get_length(image, dtempl->panels[i].cnz_from);
+ detgeom->panels[i].cnz = get_length(image, dtempl->panels[i].cnz_from, 1e-3);
/* Apply offset (in m) and then convert cnz from
* m to pixels */
detgeom->panels[i].cnz += dtempl->panels[i].cnz_offset;
detgeom->panels[i].cnz /= detgeom->panels[i].pixel_pitch;
+ /* Apply overall shift (already in m) */
+ detgeom->panels[i].cnx += get_length(image, dtempl->shift_x_from, 1.0);
+ detgeom->panels[i].cny += get_length(image, dtempl->shift_y_from, 1.0);
+
detgeom->panels[i].max_adu = dtempl->panels[i].max_adu;
switch ( dtempl->panels[i].adu_scale_unit ) {