aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-17 16:43:32 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:34 +0100
commit513827a44d1ddd395f677a74617b42934ca9bc64 (patch)
treec0ca0b1d14afb8026c9ff4e1f081453f3f3cfed3 /libcrystfel
parent4ad424f132dc3311502567e58b695fecdeb10106 (diff)
Crystals shouldn't own RefLists (part 1)
This is a terrible bit of API. A Crystal contains both the parameters for a calculation (e.g. prediction) and the results. Just look at post-refinement.c for an example of the mess this makes when trying to do calculations. This commit removes the reflection list from the Crystal structure. Future commits in this series will fix the resulting build carnage. This also gets rid of vestigial field pr_dud, and adds initialisers for all (remaining) fields.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/crystal.c55
-rw-r--r--libcrystfel/src/crystal.h25
-rw-r--r--libcrystfel/src/image.c1
3 files changed, 21 insertions, 60 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
index e5978795..a21283f9 100644
--- a/libcrystfel/src/crystal.c
+++ b/libcrystfel/src/crystal.c
@@ -3,11 +3,11 @@
*
* A class representing a single crystal
*
- * Copyright © 2013-2021 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2013-2024 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2013-2020 Thomas White <taw@physics.org>
+ * 2013-2024 Thomas White <taw@physics.org>
* 2016 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -31,7 +31,6 @@
#include "crystal.h"
#include "utils.h"
-#include "reflist-utils.h"
/**
@@ -41,30 +40,18 @@
struct _crystal
{
- /* Information about the crystal */
- UnitCell *cell;
+ UnitCell *cell;
double m; /* Mosaicity in radians */
double osf;
double Bfac;
double profile_radius;
- int pr_dud;
double resolution_limit;
-
- /* Integrated (or about-to-be-integrated) reflections */
- RefList *reflections;
- long long int n_saturated; /* Number of overloads */
- long long int n_implausible; /* Number of implausibly
- * negative reflectionss */
-
- /* User flag, e.g. for "this is a bad crystal". */
+ long long int n_saturated; /* Number of overloads */
+ long long int n_implausible; /* Number of implausibly negative reflectionss */
int user_flag;
-
- /* Text notes, which go in the stream */
- char *notes;
-
- /* Detector shift in metres */
- double det_shift_x;
- double det_shift_y;
+ char *notes; /* Text notes, which go in the stream */
+ double det_shift_x; /* Detector x-shift in metres */
+ double det_shift_y; /* Detector y-shift in metres */
};
@@ -85,12 +72,15 @@ Crystal *crystal_new()
if ( cryst == NULL ) return NULL;
cryst->cell = NULL;
- cryst->reflections = NULL;
+ cryst->m = 0.0;
+ cryst->osf = 1.0;
+ cryst->Bfac = 0.0;
+ cryst->profile_radius = 0.0;
cryst->resolution_limit = INFINITY;
cryst->n_saturated = 0;
cryst->n_implausible = 0;
- cryst->notes = NULL;
cryst->user_flag = 0;
+ cryst->notes = NULL;
cryst->det_shift_x = 0;
cryst->det_shift_y = 0;
@@ -149,13 +139,6 @@ Crystal *crystal_copy_deep(const Crystal *cryst)
c->cell = cell;
}
- if ( cryst->reflections != NULL ) {
- RefList *refls;
- refls = copy_reflist(cryst->reflections);
- if ( refls == NULL ) return NULL;
- c->reflections = refls;
- }
-
return c;
}
@@ -195,12 +178,6 @@ double crystal_get_profile_radius(const Crystal *cryst)
}
-RefList *crystal_get_reflections(Crystal *cryst)
-{
- return cryst->reflections;
-}
-
-
double crystal_get_resolution_limit(Crystal *cryst)
{
return cryst->resolution_limit;
@@ -272,12 +249,6 @@ void crystal_set_profile_radius(Crystal *cryst, double r)
}
-void crystal_set_reflections(Crystal *cryst, RefList *reflist)
-{
- cryst->reflections = reflist;
-}
-
-
void crystal_set_resolution_limit(Crystal *cryst, double res)
{
cryst->resolution_limit = res;
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
index 33764bc0..3f19386c 100644
--- a/libcrystfel/src/crystal.h
+++ b/libcrystfel/src/crystal.h
@@ -3,11 +3,11 @@
*
* A class representing a single crystal
*
- * Copyright © 2013-2021 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2013-2024 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2013-2020 Thomas White <taw@physics.org>
+ * 2013-2024 Thomas White <taw@physics.org>
* 2016 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -43,8 +43,6 @@
**/
typedef struct _crystal Crystal;
-#include "reflist.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -55,36 +53,29 @@ extern Crystal *crystal_copy_deep(const Crystal *cryst);
extern void crystal_free(Crystal *cryst);
extern UnitCell *crystal_get_cell(Crystal *cryst);
-extern const UnitCell *crystal_get_cell_const(const Crystal *cryst);
extern double crystal_get_profile_radius(const Crystal *cryst);
-extern RefList *crystal_get_reflections(Crystal *cryst);
extern double crystal_get_resolution_limit(Crystal *cryst);
-extern long long int crystal_get_num_saturated_reflections(Crystal *cryst);
-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 double crystal_get_mosaicity(Crystal *cryst);
extern const char *crystal_get_notes(Crystal *cryst);
-extern void crystal_get_det_shift(Crystal *cryst,
- double *shift_x, double* shift_y);
+extern void crystal_get_det_shift(Crystal *cryst, double *shift_x, double *shift_y);
+extern long long int crystal_get_num_saturated_reflections(Crystal *cryst);
+extern long long int crystal_get_num_implausible_reflections(Crystal *cryst);
extern void crystal_set_cell(Crystal *cryst, UnitCell *cell);
extern void crystal_set_profile_radius(Crystal *cryst, double r);
-extern void crystal_set_reflections(Crystal *cryst, RefList *reflist);
extern void crystal_set_resolution_limit(Crystal *cryst, double res);
-extern void crystal_set_num_saturated_reflections(Crystal *cryst,
- long long int n);
-extern void crystal_set_num_implausible_reflections(Crystal *cryst,
- long long int n);
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_mosaicity(Crystal *cryst, double m);
extern void crystal_set_notes(Crystal *cryst, const char *notes);
-extern void crystal_set_det_shift(Crystal *cryst,
- double shift_x, double shift_y);
extern void crystal_add_notes(Crystal *cryst, const char *notes_add);
+extern void crystal_set_det_shift(Crystal *cryst, double shift_x, double shift_y);
+extern void crystal_set_num_saturated_reflections(Crystal *cryst, long long int n);
+extern void crystal_set_num_implausible_reflections(Crystal *cryst, long long int n);
#ifdef __cplusplus
}
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 0789c6a3..9e9af85c 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -366,7 +366,6 @@ void free_all_crystals(struct image *image)
if ( image->crystals == NULL ) return;
for ( i=0; i<image->n_crystals; i++ ) {
Crystal *cr = image->crystals[i];
- reflist_free(crystal_get_reflections(cr));
cell_free(crystal_get_cell(cr));
crystal_free(image->crystals[i]);
}