aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2016-10-07 15:46:29 +0200
committerThomas White <taw@physics.org>2016-10-10 15:21:56 +0200
commit4f17116d29759077a02d80fd410965f848ffc05f (patch)
treeba4243f7c2a8ec91cd0350841fc882accb61b4ef
parent34198e6f92f19dfeb0ee13c0fcc60c82b05f85e3 (diff)
Added detector shift to crystal structure, wrote get and get functions
-rw-r--r--libcrystfel/src/crystal.c22
-rw-r--r--libcrystfel/src/crystal.h5
-rw-r--r--libcrystfel/src/predict-refine.c5
-rw-r--r--libcrystfel/src/stream.c16
4 files changed, 42 insertions, 6 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
index dc2b28fb..116b6bce 100644
--- a/libcrystfel/src/crystal.c
+++ b/libcrystfel/src/crystal.c
@@ -72,6 +72,10 @@ struct _crystal
/* Text notes, which go in the stream */
char *notes;
+
+ /* Detector shift */
+ double det_shift_x;
+ double det_shift_y;
};
@@ -100,6 +104,8 @@ Crystal *crystal_new()
cryst->n_implausible = 0;
cryst->notes = NULL;
cryst->user_flag = 0;
+ cryst->det_shift_x = 0;
+ cryst->det_shift_y = 0;
return cryst;
}
@@ -219,6 +225,15 @@ const char *crystal_get_notes(Crystal *cryst)
}
+void crystal_get_det_shift(Crystal *cryst, double* shift_x,
+ double *shift_y)
+{
+ *shift_x = cryst->det_shift_x;
+ *shift_y = cryst->det_shift_y;
+}
+
+
+
/********************************** Setters ***********************************/
@@ -318,3 +333,10 @@ void crystal_add_notes(Crystal *cryst, const char *notes_add)
free(cryst->notes);
cryst->notes = nnotes;
}
+
+
+void crystal_set_det_shift(Crystal *cryst, double shift_x, double shift_y)
+{
+ cryst->det_shift_x = shift_x;
+ cryst->det_shift_y = shift_y;
+}
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
index f0d732ff..cf9582d7 100644
--- a/libcrystfel/src/crystal.h
+++ b/libcrystfel/src/crystal.h
@@ -66,6 +66,8 @@ extern double crystal_get_Bfac(Crystal *cryst);
extern struct image *crystal_get_image(Crystal *cryst);
extern double crystal_get_mosaicity(Crystal *cryst);
extern const char *crystal_get_notes(Crystal *cryst);
+extern void crystal_get_det_shift(Crystal *cryst, double *shift_x,
+ double* shift_y);
extern void crystal_set_cell(Crystal *cryst, UnitCell *cell);
extern void crystal_set_profile_radius(Crystal *cryst, double r);
@@ -81,7 +83,8 @@ extern void crystal_set_Bfac(Crystal *cryst, double B);
extern void crystal_set_image(Crystal *cryst, struct image *image);
extern void crystal_set_mosaicity(Crystal *cryst, double m);
extern void crystal_set_notes(Crystal *cryst, const char *notes);
-
+extern void crystal_set_det_shift(Crystal *cryst, double shift_x,
+ double shift_y);
extern void crystal_add_notes(Crystal *cryst, const char *notes_add);
#ifdef __cplusplus
diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c
index 743b4d04..dfc7242f 100644
--- a/libcrystfel/src/predict-refine.c
+++ b/libcrystfel/src/predict-refine.c
@@ -584,7 +584,6 @@ int refine_prediction(struct image *image, Crystal *cr)
double total_x = 0.0;
double total_y = 0.0;
double total_z = 0.0;
- char tmp[1024];
rps = malloc(image_feature_count(image->features)
* sizeof(struct reflpeak));
@@ -626,9 +625,7 @@ int refine_prediction(struct image *image, Crystal *cr)
}
//STATUS("Final residual = %e\n", residual(rps, n, image->det));
- snprintf(tmp, 1024, "predict_refine/det_shift x = %.3f y = %.3f mm",
- total_x*1e3, total_y*1e3);
- crystal_add_notes(cr, tmp);
+ crystal_set_det_shift(cr, total_x, total_y);
crystal_set_reflections(cr, NULL);
reflist_free(reflist);
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index d374a3d3..c8218790 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -702,6 +702,7 @@ static int write_crystal(Stream *st, Crystal *cr, int include_reflections)
double csx, csy, csz;
double a, b, c, al, be, ga;
double rad;
+ double det_shift_x, det_shift_y;
int ret = 0;
fprintf(st->fh, CRYSTAL_START_MARKER"\n");
@@ -737,6 +738,11 @@ static int write_crystal(Stream *st, Crystal *cr, int include_reflections)
fprintf(st->fh, "%s\n", crystal_get_notes(cr));
}
+ crystal_get_det_shift(cr, &det_shift_x, &det_shift_y);
+
+ fprintf(st->fh, "predict_refine/det_shift x = %.3f y = %.3f mm",
+ det_shift_x*1e3, det_shift_y*1e3);
+
reflist = crystal_get_reflections(cr);
if ( reflist != NULL ) {
@@ -918,6 +924,7 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf)
Crystal *cr;
int n;
Crystal **crystals_new;
+ double shift_x, shift_y;
as.u = 0.0; as.v = 0.0; as.w = 0.0;
bs.u = 0.0; bs.v = 0.0; bs.w = 0.0;
@@ -1008,6 +1015,12 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf)
crystal_set_profile_radius(cr, rad*1e9);
}
+ if ( sscanf(line, "predict_refine/det_shift x = %lf "
+ "y = %lf mm\n", &shift_x, &shift_y ) == 2 ) {
+ crystal_set_det_shift(cr, shift_x*1e-3, shift_y*1e-3);
+ }
+
+
if ( (strcmp(line, REFLECTION_START_MARKER) == 0)
&& (srf & STREAM_READ_REFLECTIONS) )
{
@@ -1029,7 +1042,8 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf)
if ( reflist == NULL ) {
ERROR("Failed while reading reflections\n");
ERROR("Filename = %s\n", image->filename);
- ERROR("Event = %s\n", get_event_string(image->event));
+ ERROR("Event = %s\n",
+ get_event_string(image->event));
break;
}