From 9cdca7b1b9edc7103e41d6805ad009f9cac272fd Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 20 Aug 2018 17:49:57 +0200 Subject: RefList: add contribution list --- libcrystfel/src/reflist.c | 34 ++++++++++++++++++++++++++++++++-- libcrystfel/src/reflist.h | 19 +++++++++++++++++-- 2 files changed, 49 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c index a35aa575..8b5dee3e 100644 --- a/libcrystfel/src/reflist.c +++ b/libcrystfel/src/reflist.c @@ -3,11 +3,11 @@ * * Fast reflection/peak list * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2016 Thomas White + * 2011-2018 Thomas White * * This file is part of CrystFEL. * @@ -100,6 +100,9 @@ struct _refldata { double peak; double mean_bg; + /* Contributions */ + struct reflection_contributions *contribs; + /* User-specified temporary values */ double temp1; double temp2; @@ -587,6 +590,18 @@ int get_flag(const Reflection *refl) } +/** + * get_contributions: + * @refl: A %Reflection + * + * Returns: the reflection's contribution list + * + **/ +struct reflection_contributions *get_contributions(const Reflection *refl) +{ + return refl->data.contribs; +} + /********************************** Setters ***********************************/ /** @@ -848,6 +863,21 @@ void set_flag(Reflection *refl, int flag) } +/** + * set_contributions: + * @refl: A %Reflection + * @contribs: Pointer to the contribution list + * + * Note that the pointer will be stored, not the contents of the structure. + * + **/ +void set_contributions(Reflection *refl, + struct reflection_contributions *contribs) +{ + refl->data.contribs = contribs; +} + + /********************************* Insertion **********************************/ static Reflection *rotate_once(Reflection *refl, int dir) diff --git a/libcrystfel/src/reflist.h b/libcrystfel/src/reflist.h index 9f494474..f2fadb8b 100644 --- a/libcrystfel/src/reflist.h +++ b/libcrystfel/src/reflist.h @@ -3,11 +3,11 @@ * * Fast reflection/peak list * - * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2017 Thomas White + * 2011-2018 Thomas White * * This file is part of CrystFEL. * @@ -38,6 +38,7 @@ #define GET_K(serial) ((((serial) & 0x000ffc00)>>10)-512) #define GET_L(serial) (((serial) & 0x000003ff)-512) + /** * RefList: * @@ -73,6 +74,17 @@ typedef struct _reflistiterator RefListIterator; extern "C" { #endif +typedef struct _crystal Crystal; + +/* Structure representing the contributions to a merged reflection */ +struct reflection_contributions +{ + int n_contrib; + int max_contrib; + Reflection **contribs; + Crystal **contrib_crystals; +}; + /* Creation/deletion */ extern RefList *reflist_new(void); extern void reflist_free(RefList *list); @@ -105,6 +117,7 @@ extern double get_phase(const Reflection *refl, int *have_phase); extern double get_peak(const Reflection *refl); extern double get_mean_bg(const Reflection *refl); extern int get_flag(const Reflection *refl); +extern struct reflection_contributions *get_contributions(const Reflection *refl); /* Set */ extern void copy_data(Reflection *to, const Reflection *from); @@ -126,6 +139,8 @@ extern void set_mean_bg(Reflection *refl, double mean_bg); extern void set_symmetric_indices(Reflection *refl, signed int hs, signed int ks, signed int ls); extern void set_flag(Reflection *refl, int flag); +extern void set_contributions(Reflection *refl, + struct reflection_contributions *contribs); /* Insertion */ extern Reflection *add_refl(RefList *list, -- cgit v1.2.3 From d562542027bced0be31e1aa4e04e6dcb132f1b3e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 20 Aug 2018 18:32:48 +0200 Subject: Formatting fussiness --- libcrystfel/src/reflist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c index 8b5dee3e..f1d759ea 100644 --- a/libcrystfel/src/reflist.c +++ b/libcrystfel/src/reflist.c @@ -649,6 +649,7 @@ void set_panel(Reflection *refl, struct panel *p) refl->data.panel = p; } + /** * set_khalf: * @refl: A %Reflection @@ -662,7 +663,6 @@ void set_khalf(Reflection *refl, double khalf) } - /** * set_kpred: * @refl: A %Reflection -- cgit v1.2.3 From e8fa57ba93687fbd6841cb3a3d09c87037b5c713 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 10 Sep 2018 16:48:31 +0200 Subject: Make sure reflection contribution list gets freed --- libcrystfel/src/reflist-utils.c | 28 ++++++++++++++++++++++++++-- libcrystfel/src/reflist-utils.h | 6 ++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c index 54c467b3..70548994 100644 --- a/libcrystfel/src/reflist-utils.c +++ b/libcrystfel/src/reflist-utils.c @@ -3,11 +3,11 @@ * * Utilities to complement the core reflist.c * - * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2017 Thomas White + * 2011-2018 Thomas White * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -648,6 +648,30 @@ RefList *copy_reflist(RefList *list) } +/** + * free_contribs: + * @list: A %RefList + * + * Goes through @list and frees all the reflection contribution structures. + **/ +void free_contribs(RefList *list) +{ + Reflection *refl; + RefListIterator *iter; + + for ( refl = first_refl(list, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) + { + struct reflection_contributions *c; + c = get_contributions(refl); + free(c->contribs); + free(c->contrib_crystals); + free(c); + } +} + + static char *full_command_line(int argc, char *argv[]) { int i; diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h index f64e9f51..c955491a 100644 --- a/libcrystfel/src/reflist-utils.h +++ b/libcrystfel/src/reflist-utils.h @@ -3,11 +3,11 @@ * * Utilities to complement the core reflist.c * - * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2017 Thomas White + * 2011-2018 Thomas White * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -69,6 +69,8 @@ extern RefList *res_cutoff(RefList *list, UnitCell *cell, extern RefList *copy_reflist(RefList *list); +extern void free_contribs(RefList *list); + extern void reflist_add_command_and_version(RefList *list, int argcv, char *argv[]); -- cgit v1.2.3