diff options
author | Thomas White <taw@physics.org> | 2013-02-05 18:05:30 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-02-05 18:05:30 +0100 |
commit | 2f06e6a1abf28a22cf78a6c3d89596bec2a6a8c5 (patch) | |
tree | c7c8beda3593ae1dfe31a646f51787c992f59eef | |
parent | 2ce85a95d86e350b785d206405e97d7317672188 (diff) |
Fixes for indexing pipeline
-rw-r--r-- | libcrystfel/src/index.c | 6 | ||||
-rw-r--r-- | libcrystfel/src/mosflm.h | 4 | ||||
-rw-r--r-- | libcrystfel/src/peaks.c | 10 | ||||
-rw-r--r-- | libcrystfel/src/stream.c | 18 | ||||
-rw-r--r-- | libcrystfel/src/stream.h | 10 | ||||
-rw-r--r-- | src/im-sandbox.c | 50 | ||||
-rw-r--r-- | src/im-sandbox.h | 2 | ||||
-rw-r--r-- | src/indexamajig.c | 10 |
8 files changed, 55 insertions, 55 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 821be39a..cd6628e9 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -68,7 +68,6 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, IndexingPrivate **iprivs; while ( indm[nm] != INDEXING_NONE ) nm++; - STATUS("Preparing %i indexing method%s.\n", nm, maybes(nm)); iprivs = malloc((nm+1) * sizeof(IndexingPrivate *)); for ( n=0; n<nm; n++ ) { @@ -76,12 +75,13 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, switch ( indm[n] & INDEXING_METHOD_MASK ) { case INDEXING_DIRAX : - iprivs[n] = dirax_prepare(indm[nm], cell, filename, det, + iprivs[n] = dirax_prepare(indm[n], cell, filename, det, beam, ltl); break; case INDEXING_MOSFLM : - iprivs[n] = NULL; + iprivs[n] = mosflm_prepare(indm[n], cell, filename, det, + beam, ltl); break; case INDEXING_REAX : diff --git a/libcrystfel/src/mosflm.h b/libcrystfel/src/mosflm.h index 1d296cb7..65aeb631 100644 --- a/libcrystfel/src/mosflm.h +++ b/libcrystfel/src/mosflm.h @@ -40,5 +40,9 @@ extern int run_mosflm(struct image *image, IndexingPrivate *ipriv); +extern IndexingPrivate *mosflm_prepare(IndexingMethod indm, UnitCell *cell, + const char *filename, + struct detector *det, + struct beam_params *beam, float *ltl); #endif /* MOSFLM_H */ diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 08595ef5..54ba6468 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -148,7 +148,7 @@ static int cull_peaks(struct image *image) static void add_crystal_to_mask(struct image *image, struct panel *p, - double ir_out, double ir_inn, int w, int h, + double ir_inn, int w, int h, int *mask, Crystal *cr) { Reflection *refl; @@ -200,8 +200,7 @@ static void add_crystal_to_mask(struct image *image, struct panel *p, /* cfs, css relative to panel origin */ -static int *make_BgMask(struct image *image, struct panel *p, - double ir_out, double ir_inn) +static int *make_BgMask(struct image *image, struct panel *p, double ir_inn) { int *mask; int w, h; @@ -215,7 +214,7 @@ static int *make_BgMask(struct image *image, struct panel *p, if ( image->crystals == NULL ) return mask; for ( i=0; i<image->n_crystals; i++ ) { - add_crystal_to_mask(image, p, ir_inn, ir_out, + add_crystal_to_mask(image, p, ir_inn, w, h, mask, image->crystals[i]); } @@ -860,8 +859,7 @@ void integrate_reflections(struct image *image, int use_closer, int bgsub, } for ( i=0; i<image->det->n_panels; i++ ) { int *mask; - mask = make_BgMask(image, &image->det->panels[i], - ir_out, ir_inn); + mask = make_BgMask(image, &image->det->panels[i], ir_inn); if ( mask == NULL ) { ERROR("Couldn't create background mask.\n"); return; diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 113dc359..fbcbaf2e 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -52,16 +52,6 @@ #define LATEST_MAJOR_VERSION (2) #define LATEST_MINOR_VERSION (1) -#define CHUNK_START_MARKER "----- Begin chunk -----" -#define CHUNK_END_MARKER "----- End chunk -----" -#define PEAK_LIST_START_MARKER "Peaks from peak search" -#define PEAK_LIST_END_MARKER "End of peak list" -#define CRYSTAL_START_MARKER "--- Begin crystal" -#define CRYSTAL_END_MARKER "--- End crystal" -#define REFLECTION_START_MARKER "Reflections measured after indexing" -/* REFLECTION_END_MARKER is over in reflist-utils.h because it is also - * used to terminate a standalone list of reflections */ - struct _stream { @@ -184,8 +174,6 @@ static void write_crystal(Stream *st, Crystal *cr, int include_reflections) if ( include_reflections ) { - fprintf(st->fh, "\n"); - if ( reflist != NULL ) { fprintf(st->fh, REFLECTION_START_MARKER"\n"); @@ -199,7 +187,7 @@ static void write_crystal(Stream *st, Crystal *cr, int include_reflections) } } - fprintf(st->fh, CRYSTAL_START_MARKER"\n\n"); + fprintf(st->fh, CRYSTAL_END_MARKER"\n"); } @@ -226,19 +214,17 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, copy_hdf5_fields(hdfile, i->copyme, st->fh); if ( include_peaks ) { - fprintf(st->fh, "\n"); write_peaks(i, st->fh); } fprintf(st->fh, "photon_energy_eV = %f\n", J_to_eV(ph_lambda_to_en(i->lambda))); - fprintf(st->fh, "\n"); for ( j=0; j<i->n_crystals; j++ ) { write_crystal(st, i->crystals[j], include_reflections); } - fprintf(st->fh, CHUNK_END_MARKER"\n\n"); + fprintf(st->fh, CHUNK_END_MARKER"\n"); fflush(st->fh); } diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h index 4d561cd2..cdce0ea2 100644 --- a/libcrystfel/src/stream.h +++ b/libcrystfel/src/stream.h @@ -38,6 +38,16 @@ struct image; struct hdfile; +#define CHUNK_START_MARKER "----- Begin chunk -----" +#define CHUNK_END_MARKER "----- End chunk -----" +#define PEAK_LIST_START_MARKER "Peaks from peak search" +#define PEAK_LIST_END_MARKER "End of peak list" +#define CRYSTAL_START_MARKER "--- Begin crystal" +#define CRYSTAL_END_MARKER "--- End crystal" +#define REFLECTION_START_MARKER "Reflections measured after indexing" +/* REFLECTION_END_MARKER is over in reflist-utils.h because it is also + * used to terminate a standalone list of reflections */ + typedef struct _stream Stream; extern Stream *open_stream_for_read(const char *filename); diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 825f2d6a..d476c72d 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -305,6 +305,8 @@ static void process_image(const struct index_args *iargs, /* Index the pattern */ index_pattern(&image, indm, iargs->ipriv); + pargs->n_crystals = image.n_crystals; + /* Default beam parameters */ image.div = image.beam->divergence; image.bw = image.beam->bandwidth; @@ -328,22 +330,20 @@ static void process_image(const struct index_args *iargs, crystal_set_reflections(image.crystals[i], reflections); - if ( reflections != NULL ) { - - integrate_reflections(&image, - iargs->config_closer, - iargs->config_bgsub, - iargs->min_int_snr, - iargs->ir_inn, - iargs->ir_mid, - iargs->ir_out, - iargs->integrate_saturated); - } - } - write_chunk(st, &image, hdfile, iargs->include_peaks, - iargs->include_reflections); + /* Integrate all the crystals at once - need all the crystals so that + * overlaps can be detected. */ + integrate_reflections(&image, iargs->config_closer, + iargs->config_bgsub, + iargs->min_int_snr, + iargs->ir_inn, + iargs->ir_mid, + iargs->ir_out, + iargs->integrate_saturated); + + write_chunk(st, &image, hdfile, + iargs->include_peaks, iargs->include_reflections); for ( i=0; i<image.n_crystals; i++ ) { crystal_free(image.crystals[i]); @@ -485,15 +485,17 @@ static int pump_chunk(FILE *fh, FILE *ofh) } - if ( strcmp(line, "END\n") == 0 ) { + fprintf(ofh, "%s", line); + + if ( strcmp(line, CHUNK_END_MARKER"\n") == 0 ) { chunk_finished = 1; - } else { + } + if ( strcmp(line, CHUNK_START_MARKER"\n") == 0 ) { chunk_started = 1; - fprintf(ofh, "%s", line); } - } while ( !chunk_finished ); + } while ( !chunk_finished ); return 0; } @@ -711,7 +713,7 @@ static void handle_zombie(struct sandbox *sb) void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, int config_basename, FILE *fh, char *use_this_one_instead, - Stream *st) + FILE *ofh) { int i; int allDone; @@ -738,6 +740,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, pthread_mutex_init(&sb->lock, NULL); + sb->ofh = ofh; sb->stream_pipe_read = calloc(n_proc, sizeof(int)); sb->stream_pipe_write = calloc(n_proc, sizeof(int)); if ( sb->stream_pipe_read == NULL ) { @@ -950,15 +953,12 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, tNow = get_monotonic_seconds(); if ( tNow >= sb->t_last_stats+STATS_EVERY_N_SECONDS ) { - STATUS("Total so far: %i images processed, " + STATUS("%i images processed so far, " "%i had crystals, %i crystals overall. " - "Since the last message: %i images processed," - "%i had crystals, %i crystals overall.\n", + "%i images processed since the last message\n", sb->n_processed, sb->n_hadcrystals, sb->n_crystals, - sb->n_processed - sb->n_processed_last_stats, - sb->n_hadcrystals - sb->n_hadcrystals_last_stats, - sb->n_crystals - sb->n_crystals_last_stats); + sb->n_processed - sb->n_processed_last_stats); sb->n_processed_last_stats = sb->n_processed; sb->n_hadcrystals_last_stats = sb->n_hadcrystals; diff --git a/src/im-sandbox.h b/src/im-sandbox.h index 176bfde0..96311056 100644 --- a/src/im-sandbox.h +++ b/src/im-sandbox.h @@ -76,4 +76,4 @@ struct index_args extern void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, int config_basename, FILE *fh, - char *use_this_one_instead, Stream *st); + char *use_this_one_instead, FILE *stream); diff --git a/src/indexamajig.c b/src/indexamajig.c index 3076ea86..5d57d336 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) char *filename = NULL; char *outfile = NULL; FILE *fh; - Stream *st; + FILE *ofh; char *rval = NULL; int config_noindex = 0; int config_cmfilter = 0; @@ -264,6 +264,7 @@ int main(int argc, char *argv[]) {"peaks", 1, NULL, 2}, {"cell-reduction", 1, NULL, 3}, {"min-gradient", 1, NULL, 4}, + {"record", 1, NULL, 5}, {"cpus", 1, NULL, 6}, {"cpugroup", 1, NULL, 7}, {"cpuoffset", 1, NULL, 8}, @@ -352,6 +353,7 @@ int main(int argc, char *argv[]) case 5 : ERROR("The option '--record' is no longer used.\n"); + /* FIXME: Translate to new style */ break; case 6 : @@ -526,8 +528,8 @@ int main(int argc, char *argv[]) cell = NULL; } - st = open_stream_for_write(outfile); - if ( st == NULL ) { + ofh = fopen(outfile, "w"); + if ( ofh == NULL ) { ERROR("Failed to open stream '%s'\n", outfile); return 1; } @@ -600,7 +602,7 @@ int main(int argc, char *argv[]) iargs.include_reflections = 1; /* FIXME! */ create_sandbox(&iargs, n_proc, prefix, config_basename, fh, - use_this_one_instead, st); + use_this_one_instead, ofh); free(prefix); |