From d94e9bfa02bc1ee2f0e14132ea9f5f9d2689c757 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 19 Aug 2020 12:27:18 +0200 Subject: Make Stream responsible for its own DataTemplate It makes no sense for a different DataTemplate to be used for every frame in a stream. And this way makes everything much easier for users ot the API. --- src/ambigator.c | 2 +- src/cell_explorer.c | 2 +- src/crystfel_gui.c | 1 - src/im-sandbox.c | 2 +- src/indexamajig.c | 2 +- src/partial_sim.c | 5 ++--- src/partialator.c | 17 +---------------- src/pattern_sim.c | 2 +- src/process_hkl.c | 23 ++++------------------- src/process_image.c | 3 +-- src/whirligig.c | 2 +- 11 files changed, 14 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/ambigator.c b/src/ambigator.c index fa405b4f..c3afd6c1 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -1259,7 +1259,7 @@ int main(int argc, char *argv[]) struct image *image; int i; - image = stream_read_chunk(st, NULL, STREAM_UNITCELL + image = stream_read_chunk(st, STREAM_UNITCELL | STREAM_REFLECTIONS); if ( image == NULL ) break; diff --git a/src/cell_explorer.c b/src/cell_explorer.c index 2eec4a19..84a8aa16 100644 --- a/src/cell_explorer.c +++ b/src/cell_explorer.c @@ -2002,7 +2002,7 @@ int main(int argc, char *argv[]) struct image *image; int i; - image = stream_read_chunk(st, NULL, STREAM_UNITCELL); + image = stream_read_chunk(st, STREAM_UNITCELL); if ( image == NULL ) break; for ( i=0; in_crystals; i++ ) { diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index a941dca6..7f4f29f0 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -145,7 +145,6 @@ static void update_imageview(struct crystfelproject *proj) } image = stream_read_chunk(proj->stream, - proj->dtempl, STREAM_UNITCELL | STREAM_REFLECTIONS | STREAM_PEAKS diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 32c4fc13..1024b738 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -661,7 +661,7 @@ static void start_worker_process(struct sandbox *sb, int slot) * prefix */ - st = stream_open_fd_for_write(stream_pipe[1]); + st = stream_open_fd_for_write(stream_pipe[1], sb->iargs->dtempl); r = run_work(sb->iargs, st, slot, tmp, sb); stream_close(st); diff --git a/src/indexamajig.c b/src/indexamajig.c index 2d0e53c8..15315952 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -993,7 +993,7 @@ int main(int argc, char *argv[]) free(rn); /* Open output stream */ - st = stream_open_for_write(args.outfile); + st = stream_open_for_write(args.outfile, args.iargs.dtempl); if ( st == NULL ) { ERROR("Failed to open stream '%s'\n", args.outfile); return 1; diff --git a/src/partial_sim.c b/src/partial_sim.c index dfadb94f..a0f60e1e 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -346,7 +346,6 @@ static void *create_job(void *vqargs) struct image *image; image = stream_read_chunk(qargs->template_stream, - qargs->dtempl, STREAM_UNITCELL | STREAM_REFLECTIONS); if ( image == NULL ) { ERROR("Failed to read template chunk!\n"); @@ -474,7 +473,7 @@ static void finalise_job(void *vqargs, void *vwargs) int ret; ret = stream_write_chunk(qargs->stream, wargs->image, - qargs->dtempl, STREAM_UNITCELL + STREAM_UNITCELL | STREAM_REFLECTIONS | STREAM_CRYSTALS); if ( ret != 0 ) { @@ -852,7 +851,7 @@ int main(int argc, char *argv[]) ERROR("You must give a filename for the output.\n"); return 1; } - stream = stream_open_for_write(output_file); + stream = stream_open_for_write(output_file, dtempl); if ( stream == NULL ) { ERROR("Couldn't open output file '%s'\n", output_file); return 1; diff --git a/src/partialator.c b/src/partialator.c index 959338ca..1a28e3f3 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -973,8 +973,6 @@ int main(int argc, char *argv[]) PartialityModel pmodel = PMODEL_XSPHERE; int min_measurements = 2; char *rval; - const char *geom_str; - DataTemplate *dtempl; struct polarisation polarisation = {.fraction = 1.0, .angle = 0.0, .disable = 0}; @@ -1249,19 +1247,6 @@ int main(int argc, char *argv[]) return 1; } - geom_str = stream_geometry_file(st); - if ( geom_str == NULL ) { - ERROR("No geometry file\n"); - stream_close(st); - return 1; - } - - dtempl = data_template_new_from_string(geom_str); - if ( dtempl == NULL ) { - stream_close(st); - return 1; - } - if ( outfile == NULL ) { outfile = strdup("partialator.hkl"); } @@ -1420,7 +1405,7 @@ int main(int argc, char *argv[]) RefList *as; int i; - image = stream_read_chunk(st, dtempl, STREAM_REFLECTIONS + image = stream_read_chunk(st, STREAM_REFLECTIONS | STREAM_UNITCELL); if ( image == NULL ) break; diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 4d74589b..b83677b7 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -1049,7 +1049,7 @@ int main(int argc, char *argv[]) Crystal *cr; /* Get data from next chunk */ - templ_image = stream_read_chunk(st, dtempl, + templ_image = stream_read_chunk(st, STREAM_CRYSTALS); if ( templ_image == NULL ) break; if ( templ_image->n_crystals == 0 ) continue; diff --git a/src/process_hkl.c b/src/process_hkl.c index 352bea4a..812903a2 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -397,7 +397,7 @@ static void display_progress(int n_images, int n_crystals, int n_crystals_used) } -static int merge_all(Stream *st, DataTemplate *dtempl, +static int merge_all(Stream *st, RefList *model, RefList *reference, const SymOpList *sym, double **hist_vals, signed int hist_h, @@ -431,7 +431,7 @@ static int merge_all(Stream *st, DataTemplate *dtempl, int i; /* Get data from next chunk */ - image = stream_read_chunk(st, dtempl, + image = stream_read_chunk(st, STREAM_REFLECTIONS | STREAM_UNITCELL); if ( image == NULL ) break; @@ -517,8 +517,6 @@ int main(int argc, char *argv[]) int hist_i; int space_for_hist = 0; char *histo_params = NULL; - const char *geom_str; - DataTemplate *dtempl; struct polarisation polarisation = {.fraction = 1.0, .angle = 0.0, .disable = 0}; @@ -730,19 +728,6 @@ int main(int argc, char *argv[]) return 1; } - geom_str = stream_geometry_file(st); - if ( geom_str == NULL ) { - ERROR("No geometry file found in stream\n"); - stream_close(st); - return 1; - } - - dtempl = data_template_new_from_string(geom_str); - if ( dtempl == NULL ) { - stream_close(st); - return 1; - } - model = reflist_new(); if ( histo != NULL ) { @@ -799,7 +784,7 @@ int main(int argc, char *argv[]) if ( config_scale ) twopass = 1; hist_i = 0; - r = merge_all(st, dtempl, model, NULL, sym, + r = merge_all(st, model, NULL, sym, &hist_vals, hist_h, hist_k, hist_l, &hist_i, polarisation, min_measurements, min_snr, max_adu, start_after, stop_after, min_res, push_res, @@ -834,7 +819,7 @@ int main(int argc, char *argv[]) hist_i = 0; } - r = merge_all(st, dtempl, model, reference, sym, &hist_vals, + r = merge_all(st, model, reference, sym, &hist_vals, hist_h, hist_k, hist_l, &hist_i, polarisation, min_measurements, min_snr, max_adu, start_after, stop_after, min_res, diff --git a/src/process_image.c b/src/process_image.c index a04e9468..60568ede 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -404,8 +404,7 @@ streamwrite: time_accounts_set(taccs, TACC_WRITESTREAM); set_last_task(last_task, "stream write"); sb_shared->pings[cookie]++; - ret = stream_write_chunk(st, image, iargs->dtempl, - iargs->stream_flags); + ret = stream_write_chunk(st, image, iargs->stream_flags); if ( ret != 0 ) { ERROR("Error writing stream file.\n"); } diff --git a/src/whirligig.c b/src/whirligig.c index 16688559..0d5a2f0d 100644 --- a/src/whirligig.c +++ b/src/whirligig.c @@ -720,7 +720,7 @@ int main(int argc, char *argv[]) struct image *image; - image = stream_read_chunk(st, NULL, STREAM_REFLECTIONS + image = stream_read_chunk(st, STREAM_REFLECTIONS | STREAM_UNITCELL); if ( image == NULL ) break; -- cgit v1.2.3