diff options
author | Thomas White <taw@physics.org> | 2015-07-08 14:11:28 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-07-08 15:58:51 +0200 |
commit | 224e98bf0930f654fcfdd4be8ba6cc54510f195a (patch) | |
tree | 9a8e2eca93c1d8f7595e9539bdf5173d9c0caa95 /libcrystfel | |
parent | 3638ffdee226e248c351362fed7fdc213d4d39b0 (diff) |
Move {x,y}_gradient to geometry.h
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/geometry.c | 118 | ||||
-rw-r--r-- | libcrystfel/src/geometry.h | 5 | ||||
-rw-r--r-- | libcrystfel/src/predict-refine.c | 118 |
3 files changed, 123 insertions, 118 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index acfc08ee..048dc9f7 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -563,3 +563,121 @@ void polarisation_correction(RefList *list, UnitCell *cell, struct image *image) set_intensity(refl, intensity / pol); } } + + +/* Returns dx_h/dP, where P = any parameter */ +double x_gradient(int param, Reflection *refl, UnitCell *cell, + struct panel *p, double lambda) +{ + signed int h, k, l; + double x, z, wn; + double ax, ay, az, bx, by, bz, cx, cy, cz; + + get_indices(refl, &h, &k, &l); + wn = 1.0 / lambda; + cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); + x = h*ax + k*bx + l*cx; + z = h*az + k*bz + l*cz; + + switch ( param ) { + + case GPARAM_ASX : + return h * p->clen / (wn+z); + + case GPARAM_BSX : + return k * p->clen / (wn+z); + + case GPARAM_CSX : + return l * p->clen / (wn+z); + + case GPARAM_ASY : + return 0.0; + + case GPARAM_BSY : + return 0.0; + + case GPARAM_CSY : + return 0.0; + + case GPARAM_ASZ : + return -h * x * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_BSZ : + return -k * x * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_CSZ : + return -l * x * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_DETX : + return -1; + + case GPARAM_DETY : + return 0; + + case GPARAM_CLEN : + return x / (wn+z); + + } + + ERROR("Positional gradient requested for parameter %i?\n", param); + abort(); +} + + +/* Returns dy_h/dP, where P = any parameter */ +double y_gradient(int param, Reflection *refl, UnitCell *cell, + struct panel *p, double lambda) +{ + signed int h, k, l; + double y, z, wn; + double ax, ay, az, bx, by, bz, cx, cy, cz; + + get_indices(refl, &h, &k, &l); + wn = 1.0 / lambda; + cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); + y = h*ay + k*by + l*cy; + z = h*az + k*bz + l*cz; + + switch ( param ) { + + case GPARAM_ASX : + return 0.0; + + case GPARAM_BSX : + return 0.0; + + case GPARAM_CSX : + return 0.0; + + case GPARAM_ASY : + return h * p->clen / (wn+z); + + case GPARAM_BSY : + return k * p->clen / (wn+z); + + case GPARAM_CSY : + return l * p->clen / (wn+z); + + case GPARAM_ASZ : + return -h * y * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_BSZ : + return -k * y * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_CSZ : + return -l * y * p->clen / (wn*wn + 2*wn*z + z*z); + + case GPARAM_DETX : + return 0; + + case GPARAM_DETY : + return -1; + + case GPARAM_CLEN : + return y / (wn+z); + + } + + ERROR("Positional gradient requested for parameter %i?\n", param); + abort(); +} diff --git a/libcrystfel/src/geometry.h b/libcrystfel/src/geometry.h index 152c0e47..474755b2 100644 --- a/libcrystfel/src/geometry.h +++ b/libcrystfel/src/geometry.h @@ -98,6 +98,11 @@ extern void polarisation_correction(RefList *list, UnitCell *cell, extern double sphere_fraction(double rlow, double rhigh, double pr); extern double gaussian_fraction(double rlow, double rhigh, double pr); +extern double x_gradient(int param, Reflection *refl, UnitCell *cell, + struct panel *p, double lambda); +extern double y_gradient(int param, Reflection *refl, UnitCell *cell, + struct panel *p, double lambda); + #ifdef __cplusplus } #endif diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c index 6784aae2..135002c9 100644 --- a/libcrystfel/src/predict-refine.c +++ b/libcrystfel/src/predict-refine.c @@ -349,124 +349,6 @@ void refine_radius(Crystal *cr, struct image *image) } -/* Returns dx_h/dP, where P = any parameter */ -static double x_gradient(int param, Reflection *refl, UnitCell *cell, - struct panel *p, double lambda) -{ - signed int h, k, l; - double x, z, wn; - double ax, ay, az, bx, by, bz, cx, cy, cz; - - get_indices(refl, &h, &k, &l); - wn = 1.0 / lambda; - cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); - x = h*ax + k*bx + l*cx; - z = h*az + k*bz + l*cz; - - switch ( param ) { - - case GPARAM_ASX : - return h * p->clen / (wn+z); - - case GPARAM_BSX : - return k * p->clen / (wn+z); - - case GPARAM_CSX : - return l * p->clen / (wn+z); - - case GPARAM_ASY : - return 0.0; - - case GPARAM_BSY : - return 0.0; - - case GPARAM_CSY : - return 0.0; - - case GPARAM_ASZ : - return -h * x * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_BSZ : - return -k * x * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_CSZ : - return -l * x * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_DETX : - return -1; - - case GPARAM_DETY : - return 0; - - case GPARAM_CLEN : - return x / (wn+z); - - } - - ERROR("Positional gradient requested for parameter %i?\n", param); - abort(); -} - - -/* Returns dy_h/dP, where P = any parameter */ -static double y_gradient(int param, Reflection *refl, UnitCell *cell, - struct panel *p, double lambda) -{ - signed int h, k, l; - double y, z, wn; - double ax, ay, az, bx, by, bz, cx, cy, cz; - - get_indices(refl, &h, &k, &l); - wn = 1.0 / lambda; - cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); - y = h*ay + k*by + l*cy; - z = h*az + k*bz + l*cz; - - switch ( param ) { - - case GPARAM_ASX : - return 0.0; - - case GPARAM_BSX : - return 0.0; - - case GPARAM_CSX : - return 0.0; - - case GPARAM_ASY : - return h * p->clen / (wn+z); - - case GPARAM_BSY : - return k * p->clen / (wn+z); - - case GPARAM_CSY : - return l * p->clen / (wn+z); - - case GPARAM_ASZ : - return -h * y * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_BSZ : - return -k * y * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_CSZ : - return -l * y * p->clen / (wn*wn + 2*wn*z + z*z); - - case GPARAM_DETX : - return 0; - - case GPARAM_DETY : - return -1; - - case GPARAM_CLEN : - return y / (wn+z); - - } - - ERROR("Positional gradient requested for parameter %i?\n", param); - abort(); -} - - static void update_detector(struct detector *det, double xoffs, double yoffs, double coffs) { |