From 54006b85266f4de00c4c6caf4d062be4e1c73c3d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 1 Feb 2018 15:36:22 +0100 Subject: Create a separate image structure for each image Because the wavelength is going to be refined and shouldn't be shared. In the future, the wavelength should somehow be refined jointly between multi-crystal images. --- src/partialator.c | 67 +++++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 42 deletions(-) (limited to 'src/partialator.c') diff --git a/src/partialator.c b/src/partialator.c index 157c525c..4e3cd5da 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -849,7 +849,6 @@ int main(int argc, char *argv[]) SymOpList *sym; int nthreads = 1; int i; - struct image *images; int n_iter = 10; RefList *full; int n_images = 0; @@ -1119,7 +1118,6 @@ int main(int argc, char *argv[]) n_images = 0; n_crystals = 0; n_crystals_seen = 0; - images = NULL; crystals = NULL; if ( sparams_fn != NULL ) { char line[1024]; @@ -1143,35 +1141,27 @@ int main(int argc, char *argv[]) RefList *as; int i; - struct image *images_new; - struct image *cur; + struct image cur; - images_new = realloc(images, (n_images+1)*sizeof(struct image)); - if ( images_new == NULL ) { - ERROR("Failed to allocate memory for image list.\n"); - return 1; - } - images = images_new; - cur = &images[n_images]; - - cur->div = NAN; - cur->bw = NAN; - cur->det = NULL; - if ( read_chunk_2(st, cur, STREAM_READ_REFLECTIONS - | STREAM_READ_UNITCELL) != 0 ) { + cur.div = NAN; + cur.bw = NAN; + cur.det = NULL; + if ( read_chunk_2(st, &cur, STREAM_READ_REFLECTIONS + | STREAM_READ_UNITCELL) != 0 ) { break; } - if ( isnan(cur->div) || isnan(cur->bw) ) { + if ( isnan(cur.div) || isnan(cur.bw) ) { ERROR("Chunk doesn't contain beam parameters.\n"); return 1; } - for ( i=0; in_crystals; i++ ) { + for ( i=0; icrystals[i]; + crystals[n_crystals] = cur.crystals[i]; cr = crystals[n_crystals]; - /* Image pointer will change due to later reallocs */ - crystal_set_image(cr, NULL); + image = malloc(sizeof(struct image)); + if ( image == NULL ) { + ERROR("Failed to allocatea memory for image.\n"); + return 1; + } + + crystal_set_image(cr, image); + *image = cur; + image->n_crystals = 1; + image->crystals = &crystals[n_crystals]; /* This is the raw list of reflections */ cr_refl = crystal_get_reflections(cr); @@ -1198,7 +1196,7 @@ int main(int argc, char *argv[]) if ( polarisation ) { polarisation_correction(cr_refl, crystal_get_cell(cr), - cur); + image); } if ( !no_free ) select_free_reflections(cr_refl, rng); @@ -1234,22 +1232,11 @@ int main(int argc, char *argv[]) close_stream(st); - /* Fill in image pointers */ STATUS("Initial partiality calculation...\n"); - for ( i=0; i