aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-03-13 10:43:42 +0100
committerThomas White <taw@physics.org>2013-04-17 17:33:48 +0200
commit2b115b938d8bfba13f4193e329728b09a750b79f (patch)
tree76a0fd434021d3c5b19eab23b544d88e1495e40a /libcrystfel
parent1acd2a02602a98a6286553868ed770427087c021 (diff)
Add Lorentz factor
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/geometry.c19
-rw-r--r--libcrystfel/src/reflist.c51
-rw-r--r--libcrystfel/src/reflist.h9
3 files changed, 69 insertions, 10 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c
index 450ebfaf..7a553f82 100644
--- a/libcrystfel/src/geometry.c
+++ b/libcrystfel/src/geometry.c
@@ -134,6 +134,10 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
Reflection *refl;
double cet, cez;
double pr;
+ double L;
+
+ /* Don't predict 000 */
+ if ( abs(h)+abs(k)+abs(l) == 0 ) return NULL;
pr = crystal_get_profile_radius(cryst);
@@ -160,6 +164,19 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
&& (fabs(rlow) > pr)
&& (fabs(rhigh) > pr) ) return NULL;
+ if ( rlow < rhigh ) {
+ ERROR("Reflection with rlow < rhigh!\n");
+ ERROR("%3i %3i %3i rlow = %e, rhigh = %e\n",
+ h, k, l, rlow, rhigh);
+ ERROR("div = %e\n", image->div);
+ return NULL;
+ }
+
+ /* Lorentz factor is determined direction from the r values, before
+ * clamping. The multiplication by the profile radius is to make the
+ * correction factor vaguely near 1. */
+ L = pr / (rlow - rhigh);
+
/* If the "lower" Ewald sphere is a long way away, use the
* position at which the Ewald sphere would just touch the
* reflection.
@@ -185,7 +202,6 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
rhigh = +pr;
clamp_high = +1;
}
- assert(clamp_low >= clamp_high);
/* Calculate partiality */
part = partiality(rlow, rhigh, pr);
@@ -198,6 +214,7 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
refl = reflection_new(h, k, l);
set_detector_pos(refl, 0.0, xda, yda);
set_partial(refl, rlow, rhigh, part, clamp_low, clamp_high);
+ set_lorentz(refl, L);
set_symmetric_indices(refl, h, k, l);
set_redundancy(refl, 1);
diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c
index 64154774..b3b9f85b 100644
--- a/libcrystfel/src/reflist.c
+++ b/libcrystfel/src/reflist.c
@@ -3,11 +3,11 @@
*
* Fast reflection/peak list
*
- * Copyright © 2012 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
+ * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
*
* Authors:
- * 2011-2012 Thomas White <taw@physics.org>
+ * 2011-2013 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -70,6 +70,7 @@ struct _refldata {
double r1; /* First excitation error */
double r2; /* Second excitation error */
double p; /* Partiality */
+ double L; /* Lorentz factor */
int clamp1; /* Clamp status for r1 */
int clamp2; /* Clamp status for r2 */
@@ -388,7 +389,7 @@ void get_symmetric_indices(const Reflection *refl,
* get_partiality:
* @refl: A %Reflection
*
- * Returns: The partiality of the reflection.
+ * Returns: The partiality of the reflection. See get_lorentz().
**/
double get_partiality(const Reflection *refl)
{
@@ -397,6 +398,19 @@ double get_partiality(const Reflection *refl)
/**
+ * get_lorentz:
+ * @refl: A %Reflection
+ *
+ * Returns: The Lorentz factor for the reflection. To "scale up" a partial
+ * reflection, divide by this multiplied by the partiality.
+ **/
+double get_lorentz(const Reflection *refl)
+{
+ return refl->data.L;
+}
+
+
+/**
* get_intensity:
* @refl: A %Reflection
*
@@ -602,10 +616,35 @@ void set_partial(Reflection *refl, double r1, double r2, double p,
/**
* set_intensity:
* @refl: A %Reflection
+ * @p: The partiality for the reflection.
+ *
+ * Set the partiality for the reflection. See set_lorentz().
+ **/
+void set_partiality(Reflection *refl, double p)
+{
+ refl->data.p = p;
+}
+
+/**
+ * set_lorentz:
+ * @refl: A %Reflection
+ * @L: The Lorentz factor for the reflection.
+ *
+ * Set the Lorentz factor for the reflection. To "scale up" a partial
+ * reflection, divide by this multiplied by the partiality.
+ **/
+void set_lorentz(Reflection *refl, double L)
+{
+ refl->data.L = L;
+}
+
+
+/**
+ * set_intensity:
+ * @refl: A %Reflection
* @intensity: The intensity for the reflection.
*
- * Set the intensity for the reflection. Note that retrieval is done with
- * get_intensity().
+ * Set the intensity for the reflection.
**/
void set_intensity(Reflection *refl, double intensity)
{
diff --git a/libcrystfel/src/reflist.h b/libcrystfel/src/reflist.h
index 246ef885..7969235c 100644
--- a/libcrystfel/src/reflist.h
+++ b/libcrystfel/src/reflist.h
@@ -3,11 +3,11 @@
*
* Fast reflection/peak list
*
- * Copyright © 2012 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
+ * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
*
* Authors:
- * 2011-2012 Thomas White <taw@physics.org>
+ * 2011-2013 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -78,6 +78,7 @@ extern Reflection *next_found_refl(Reflection *refl);
extern double get_excitation_error(const Reflection *refl);
extern void get_detector_pos(const Reflection *refl, double *fs, double *ss);
extern double get_partiality(const Reflection *refl);
+extern double get_lorentz(const Reflection *refl);
extern void get_indices(const Reflection *refl,
signed int *h, signed int *k, signed int *l);
extern void get_symmetric_indices(const Reflection *refl,
@@ -100,6 +101,8 @@ extern void set_detector_pos(Reflection *refl, double exerr,
double fs, double ss);
extern void set_partial(Reflection *refl, double r1, double r2, double p,
double clamp_low, double clamp_high);
+extern void set_partiality(Reflection *refl, double p);
+extern void set_lorentz(Reflection *refl, double L);
extern void set_intensity(Reflection *refl, double intensity);
extern void set_scalable(Reflection *refl, int scalable);
extern void set_refinable(Reflection *refl, int refinable);