aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/geometry.c5
-rw-r--r--libcrystfel/src/geometry.h5
-rw-r--r--src/predict-refine.c33
3 files changed, 34 insertions, 9 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c
index 92284c3d..ca91082b 100644
--- a/libcrystfel/src/geometry.c
+++ b/libcrystfel/src/geometry.c
@@ -370,6 +370,11 @@ double r_gradient(UnitCell *cell, int k, Reflection *refl, struct image *image)
case GPARAM_CSZ :
return - ls * cos(phi);
+ case GPARAM_DETX :
+ case GPARAM_DETY :
+ case GPARAM_CLEN :
+ return 0.0;
+
}
ERROR("No r gradient defined for parameter %i\n", k);
diff --git a/libcrystfel/src/geometry.h b/libcrystfel/src/geometry.h
index e0d21dda..cecdc4f1 100644
--- a/libcrystfel/src/geometry.h
+++ b/libcrystfel/src/geometry.h
@@ -63,7 +63,7 @@ typedef enum {
/* Enumeration of parameters which may want to be refined */
-enum {
+enum gparam {
GPARAM_ASX,
GPARAM_ASY,
GPARAM_ASZ,
@@ -75,6 +75,9 @@ enum {
GPARAM_CSZ,
GPARAM_R,
GPARAM_DIV,
+ GPARAM_DETX,
+ GPARAM_DETY,
+ GPARAM_CLEN
};
diff --git a/src/predict-refine.c b/src/predict-refine.c
index ff5fa862..28c9fdc7 100644
--- a/src/predict-refine.c
+++ b/src/predict-refine.c
@@ -235,7 +235,7 @@ static double x_gradient(int param, struct reflpeak *rp, struct detector *det,
tt = asin(lambda * resolution(cell, h, k, l));
clen = rp->panel->clen;
azi = atan2(yh, xh);
- azf = 2.0*cos(azi); /* FIXME: Why factor of 2? */
+ azf = cos(azi);
switch ( param ) {
@@ -258,13 +258,22 @@ static double x_gradient(int param, struct reflpeak *rp, struct detector *det,
return 0.0;
case GPARAM_ASZ :
- return -h * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -h * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
case GPARAM_BSZ :
- return -k * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -k * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
case GPARAM_CSZ :
- return -l * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -l * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+
+ case GPARAM_DETX :
+ return -1;
+
+ case GPARAM_DETY :
+ return 0;
+
+ case GPARAM_CLEN :
+ return azf * cos(tt);
}
@@ -290,7 +299,7 @@ static double y_gradient(int param, struct reflpeak *rp, struct detector *det,
tt = asin(lambda * resolution(cell, h, k, l));
clen = rp->panel->clen;
azi = atan2(yh, xh);
- azf = 2.0*sin(azi); /* FIXME: Why factor of 2? */
+ azf = sin(azi);
switch ( param ) {
@@ -313,14 +322,22 @@ static double y_gradient(int param, struct reflpeak *rp, struct detector *det,
return l * lambda * clen / cos(tt);
case GPARAM_ASZ :
- return -h * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -h * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
case GPARAM_BSZ :
- return -k * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -k * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
case GPARAM_CSZ :
- return -l * lambda * clen * azf * sin(tt) / (cos(tt)*cos(tt));
+ return -l * lambda * clen * 2*azf * sin(tt) / (cos(tt)*cos(tt));
+
+ case GPARAM_DETX :
+ return 0;
+
+ case GPARAM_DETY :
+ return -1;
+ case GPARAM_CLEN :
+ return azf * cos(tt);
}
ERROR("Positional gradient requested for parameter %i?\n", param);