diff options
-rw-r--r-- | libcrystfel/src/image.h | 3 | ||||
-rw-r--r-- | src/indexamajig.c | 25 | ||||
-rw-r--r-- | src/process_image.h | 2 |
3 files changed, 20 insertions, 10 deletions
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index 1cd9f35a..3e46575e 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -224,7 +224,8 @@ struct image { struct spectrum *spectrum; /* Beam spectrum for pink beam data */ - // These only used in pattern_sim, to be changed to struct spectrum from above later... + /* FIXME: These are only used in pattern_sim, which should be changed to + * use the "struct spectrum" from above later */ struct sample *spectrum0; int nsamples; /* Number of wavelengths */ int spectrum_size; /* Size of "spectrum" */ diff --git a/src/indexamajig.c b/src/indexamajig.c index d6ebe3ea..4a80e762 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -244,9 +244,19 @@ static void add_geom_beam_stuff_to_field_list(struct imagefile_field_list *copym static struct spectrum *read_spectrum_fromfile(char *fn) { FILE *f; + struct spectrum *s; + int i; + double k, w; + double w_sum = 0; + f = fopen(fn, "r"); + if ( f == NULL ) { + ERROR("Couldn't open '%s'\n", fn); + return NULL; + } - struct spectrum *s = malloc(sizeof(struct spectrum)); + s = malloc(sizeof(struct spectrum)); + if ( s == NULL ) return NULL; if ( fscanf(f, "%d", &s->n) == EOF ) { return NULL; @@ -268,15 +278,14 @@ static struct spectrum *read_spectrum_fromfile(char *fn) return NULL; } - int i; - double k, w; - double w_sum = 0; - for ( i = 0; i < s->n; i++ ) { - if (fscanf(f, "%lf %lf", &k, &w) != EOF) { + for ( i=0; i<s->n; i++ ) { + if ( fscanf(f, "%lf %lf", &k, &w) != EOF ) { s->ks[i] = ph_eV_to_k(k); s->weights[i] = w; w_sum += w; - } else break; + } else { + break; + } } if ( i < s->n - 1 ) { @@ -284,7 +293,7 @@ static struct spectrum *read_spectrum_fromfile(char *fn) return NULL; } - for ( i = 0; i < s->n; i++ ) { + for ( i=0; i<s->n; i++ ) { s->weights[i] /= w_sum; } diff --git a/src/process_image.h b/src/process_image.h index 14b2aae8..d4dcbf04 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -110,7 +110,7 @@ struct index_args int overpredict; int profile; /* Whether or not to do wall clock profiling */ struct taketwo_options taketwo_opts; - struct xgandalf_options xgandalf_opts; + struct xgandalf_options xgandalf_opts; struct felix_options felix_opts; struct spectrum *spectrum; }; |