diff options
author | Thomas White <taw@physics.org> | 2023-11-08 16:24:41 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | e377768607f11d48106bd1381f1312379c342d7e (patch) | |
tree | 1e662f0557127e1bd92febd27dfda26f2d5a1960 /libcrystfel | |
parent | f3b25d69e888cb66e6a2add491a4f6d5e18f30af (diff) |
Crystal: Remove reference to image structure (part 1)
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/crystal.c | 21 | ||||
-rw-r--r-- | libcrystfel/src/crystal.h | 3 | ||||
-rw-r--r-- | libcrystfel/src/geometry.c | 58 | ||||
-rw-r--r-- | libcrystfel/src/geometry.h | 8 | ||||
-rw-r--r-- | libcrystfel/src/index.c | 1 | ||||
-rw-r--r-- | libcrystfel/src/integration.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/predict-refine.c | 6 |
7 files changed, 28 insertions, 71 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c index 71d707d6..cece3eb4 100644 --- a/libcrystfel/src/crystal.c +++ b/libcrystfel/src/crystal.c @@ -41,9 +41,6 @@ struct _crystal { - /* The image containing the crystal */ - struct image *image; - /* Information about the crystal */ UnitCell *cell; double m; /* Mosaicity in radians */ @@ -222,18 +219,6 @@ long long int crystal_get_num_implausible_reflections(Crystal *cryst) } -struct image *crystal_get_image(Crystal *cryst) -{ - return cryst->image; -} - - -const struct image *crystal_get_image_const(const Crystal *cryst) -{ - return cryst->image; -} - - double crystal_get_osf(Crystal *cryst) { return cryst->osf; @@ -311,12 +296,6 @@ void crystal_set_num_implausible_reflections(Crystal *cryst, long long int n) } -void crystal_set_image(Crystal *cryst, struct image *image) -{ - cryst->image = image; -} - - void crystal_set_osf(Crystal *cryst, double osf) { cryst->osf = osf; diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h index 5a4ca3f6..33764bc0 100644 --- a/libcrystfel/src/crystal.h +++ b/libcrystfel/src/crystal.h @@ -64,8 +64,6 @@ extern long long int crystal_get_num_implausible_reflections(Crystal *cryst); extern int crystal_get_user_flag(Crystal *cryst); extern double crystal_get_osf(Crystal *cryst); extern double crystal_get_Bfac(Crystal *cryst); -extern struct image *crystal_get_image(Crystal *cryst); -extern const struct image *crystal_get_image_const(const 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, @@ -82,7 +80,6 @@ extern void crystal_set_num_implausible_reflections(Crystal *cryst, extern void crystal_set_user_flag(Crystal *cryst, int flag); extern void crystal_set_osf(Crystal *cryst, double osf); 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, 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); diff --git a/libcrystfel/src/geometry.h b/libcrystfel/src/geometry.h index d05c8832..b9f98694 100644 --- a/libcrystfel/src/geometry.h +++ b/libcrystfel/src/geometry.h @@ -35,6 +35,7 @@ #include "cell.h" #include "crystal.h" #include "detgeom.h" +#include "image.h" #ifdef __cplusplus extern "C" { @@ -77,11 +78,12 @@ struct polarisation }; -extern RefList *predict_to_res(Crystal *cryst, double max_res); +extern RefList *predict_to_res(Crystal *cryst, struct image *image, double max_res); -extern void calculate_partialities(Crystal *cryst, PartialityModel pmodel); +extern void calculate_partialities(Crystal *cryst, struct image *image, + PartialityModel pmodel); -extern void update_predictions(Crystal *cryst); +extern void update_predictions(Crystal *cryst, struct image *image); extern struct polarisation parse_polarisation(const char *text); extern void polarisation_correction(RefList *list, UnitCell *cell, struct polarisation p); diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index d93664b1..db2058a5 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -701,7 +701,6 @@ static int try_indexer(struct image *image, IndexingMethod indm, /* ... starting at the end of the (complete) list ... */ Crystal *cr = image->crystals[this_crystal]; - crystal_set_image(cr, image); crystal_set_profile_radius(cr, 0.02e9); crystal_set_mosaicity(cr, 0.0); diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 8b05efe7..3912114a 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -1665,7 +1665,7 @@ void integrate_all_5(struct image *image, IntegrationMethod meth, res = estimate_resolution(image->crystals[i], image); crystal_set_resolution_limit(image->crystals[i], res); - list = predict_to_res(image->crystals[i], res+push_res); + list = predict_to_res(image->crystals[i], image, res+push_res); crystal_set_reflections(image->crystals[i], list); if ( overpredict ) { diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c index d5a3b403..24045ddb 100644 --- a/libcrystfel/src/predict-refine.c +++ b/libcrystfel/src/predict-refine.c @@ -489,7 +489,7 @@ static int pair_peaks(struct image *image, Crystal *cr, /* Get the excitation errors and detector positions for the candidate * reflections */ crystal_set_reflections(cr, all_reflist); - update_predictions(cr); + update_predictions(cr, image); /* Pass over the peaks again, keeping only the ones which look like * good pairings */ @@ -570,7 +570,7 @@ int refine_radius(Crystal *cr, struct image *image) return 1; } crystal_set_reflections(cr, reflist); - update_predictions(cr); + update_predictions(cr, image); crystal_set_reflections(cr, NULL); qsort(rps, n_acc, sizeof(struct reflpeak), cmpd2); @@ -855,7 +855,7 @@ int refine_prediction(struct image *image, Crystal *cr, /* Refine (max 5 cycles) */ for ( i=0; i<5; i++ ) { - update_predictions(cr); + update_predictions(cr, image); if ( iterate(rps, n, crystal_get_cell(cr), image, Minvs, total_shifts) ) { crystal_set_reflections(cr, NULL); |