aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/geometry.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-11-08 16:24:41 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:34 +0100
commite377768607f11d48106bd1381f1312379c342d7e (patch)
tree1e662f0557127e1bd92febd27dfda26f2d5a1960 /libcrystfel/src/geometry.c
parentf3b25d69e888cb66e6a2add491a4f6d5e18f30af (diff)
Crystal: Remove reference to image structure (part 1)
Diffstat (limited to 'libcrystfel/src/geometry.c')
-rw-r--r--libcrystfel/src/geometry.c58
1 files changed, 19 insertions, 39 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c
index 674fe4d0..32da348a 100644
--- a/libcrystfel/src/geometry.c
+++ b/libcrystfel/src/geometry.c
@@ -425,14 +425,15 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
/**
* \param cryst: A \ref Crystal
+ * \param image: An image structure
* \param max_res: Maximum resolution to predict to (m^-1)
*
- * Calculates reflection positions for \p crys, up to maximum 1/d value
- * \p max_res
+ * Calculates reflection positions for \p crys, as seen in \p image,
+ * up to maximum 1/d value \p max_res
*
* \returns A list of predicted reflections
*/
-RefList *predict_to_res(Crystal *cryst, double max_res)
+RefList *predict_to_res(Crystal *cryst, struct image *image, double max_res)
{
double ax, ay, az;
double bx, by, bz;
@@ -445,7 +446,6 @@ RefList *predict_to_res(Crystal *cryst, double max_res)
double mres;
signed int h, k, l;
UnitCell *cell;
- struct image *image;
cell = crystal_get_cell(cryst);
if ( cell == NULL ) return NULL;
@@ -462,7 +462,6 @@ RefList *predict_to_res(Crystal *cryst, double max_res)
cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
- image = crystal_get_image(cryst);
mres = detgeom_max_resolution(image->detgeom, image->lambda);
if ( mres > max_res ) mres = max_res;
@@ -498,7 +497,7 @@ RefList *predict_to_res(Crystal *cryst, double max_res)
yl = h*asy + k*bsy + l*csy;
zl = h*asz + k*bsz + l*csz;
- refl = check_reflection(crystal_get_image(cryst), cryst,
+ refl = check_reflection(image, cryst,
h, k, l, xl, yl, zl, NULL);
if ( refl != NULL ) {
@@ -534,12 +533,11 @@ static void set_unity_partialities(Crystal *cryst)
}
-static void set_random_partialities(Crystal *cryst)
+static void set_random_partialities(Crystal *cryst, int image_serial)
{
RefList *list;
Reflection *refl;
RefListIterator *iter;
- struct image *image;
list = crystal_get_reflections(cryst);
if ( list == NULL ) {
@@ -547,19 +545,13 @@ static void set_random_partialities(Crystal *cryst)
return;
}
- image = crystal_get_image(cryst);
- if ( image == NULL ) {
- ERROR("No image structure for partiality calculation!\n");
- return;
- }
-
for ( refl = first_refl(list, &iter);
refl != NULL;
refl = next_refl(refl, iter) )
{
signed int h, k, l;
get_symmetric_indices(refl, &h, &k, &l);
- set_partiality(refl, random_partiality(h, k, l, image->serial));
+ set_partiality(refl, random_partiality(h, k, l, image_serial));
set_lorentz(refl, 1.0);
}
}
@@ -682,13 +674,12 @@ static double do_integral(double q2, double zl, double R,
}
-static void ginn_spectrum_partialities(Crystal *cryst)
+static void ginn_spectrum_partialities(Crystal *cryst, struct image *image)
{
RefList *list;
Reflection *refl;
RefListIterator *iter;
double r0, m;
- struct image *image;
UnitCell *cell;
double asx, asy, asz, bsx, bsy, bsz, csx, csy, csz;
@@ -698,12 +689,6 @@ static void ginn_spectrum_partialities(Crystal *cryst)
return;
}
- image = crystal_get_image(cryst);
- if ( image == NULL ) {
- ERROR("No image for partiality calculation!\n");
- return;
- }
-
cell = crystal_get_cell(cryst);
if ( cell == NULL ) {
ERROR("No unit cell for partiality calculation!\n");
@@ -753,13 +738,12 @@ static void ginn_spectrum_partialities(Crystal *cryst)
}
-static void ewald_offset_partialities(Crystal *cryst)
+static void ewald_offset_partialities(Crystal *cryst, struct image *image)
{
RefList *list;
Reflection *refl;
RefListIterator *iter;
double r0, m;
- struct image *image;
UnitCell *cell;
double asx, asy, asz, bsx, bsy, bsz, csx, csy, csz;
@@ -769,12 +753,6 @@ static void ewald_offset_partialities(Crystal *cryst)
return;
}
- image = crystal_get_image(cryst);
- if ( image == NULL ) {
- ERROR("No image for partiality calculation!\n");
- return;
- }
-
cell = crystal_get_cell(cryst);
if ( cell == NULL ) {
ERROR("No unit cell for partiality calculation!\n");
@@ -826,7 +804,8 @@ static void ewald_offset_partialities(Crystal *cryst)
* called \ref predict_to_res or \ref update_predictions, because this function
* relies on the limiting wavelength values calculated by those functions.
*/
-void calculate_partialities(Crystal *cryst, PartialityModel pmodel)
+void calculate_partialities(Crystal *cryst, struct image *image,
+ PartialityModel pmodel)
{
switch ( pmodel ) {
@@ -835,15 +814,15 @@ void calculate_partialities(Crystal *cryst, PartialityModel pmodel)
break;
case PMODEL_XSPHERE :
- ginn_spectrum_partialities(cryst);
+ ginn_spectrum_partialities(cryst, image);
break;
case PMODEL_OFFSET :
- ewald_offset_partialities(cryst);
+ ewald_offset_partialities(cryst, image);
break;
case PMODEL_RANDOM :
- set_random_partialities(cryst);
+ set_random_partialities(cryst, image->serial);
break;
case PMODEL_GGPM :
@@ -861,22 +840,23 @@ void calculate_partialities(Crystal *cryst, PartialityModel pmodel)
/**
* \param cryst A \ref Crystal
+ * \param image An image structure
*
* Updates the predicted reflections (positions and excitation errors, but not
- * the actual partialities) of \p cryst's reflections according to
- * the current state of the crystal (e.g. its unit cell parameters).
+ * the actual partialities) of \p cryst's reflections as seen in \p image,
+ * according to the current state of the crystal (e.g. its unit cell
+ * parameters).
*
* If you need to update the partialities as well, call
* \ref calculate_partialities afterwards.
*/
-void update_predictions(Crystal *cryst)
+void update_predictions(Crystal *cryst, struct image *image)
{
Reflection *refl;
RefListIterator *iter;
double asx, asy, asz;
double bsx, bsy, bsz;
double csx, csy, csz;
- struct image *image = crystal_get_image(cryst);
cell_get_reciprocal(crystal_get_cell(cryst), &asx, &asy, &asz,
&bsx, &bsy, &bsz, &csx, &csy, &csz);