diff options
author | Thomas White <taw@physics.org> | 2010-05-27 17:10:04 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-05-27 17:10:04 +0200 |
commit | 0a721b5c0b022208b567dae7e0638b9da9c27cbd (patch) | |
tree | e56273b8177b1dabe2a05ea5ecb49315d4206b3e | |
parent | 7c45e455a6ee020174580355f746e7b03a1119df (diff) |
Handle I0 == 1.0 correctly
-rw-r--r-- | src/hdf5-file.c | 3 | ||||
-rw-r--r-- | src/image.h | 1 | ||||
-rw-r--r-- | src/likelihood.c | 4 | ||||
-rw-r--r-- | src/likelihood.h | 3 | ||||
-rw-r--r-- | src/peaks.c | 7 | ||||
-rw-r--r-- | src/process_hkl.c | 14 |
6 files changed, 24 insertions, 8 deletions
diff --git a/src/hdf5-file.c b/src/hdf5-file.c index d6d646ed..5573267b 100644 --- a/src/hdf5-file.c +++ b/src/hdf5-file.c @@ -343,6 +343,9 @@ int hdf5_read(struct hdfile *f, struct image *image) if ( image->f0 < 0.0 ) { ERROR("Couldn't read incident intensity - using 1.0.\n"); image->f0 = 1.0; + image->f0_available = 0; + } else { + image->f0_available = 1; } debodge_saturation(f, image); diff --git a/src/image.h b/src/image.h index 85265028..db1b491e 100644 --- a/src/image.h +++ b/src/image.h @@ -99,6 +99,7 @@ struct image { /* Incident intensity (if unknown, put 1.0) */ double f0; + int f0_available; int width; int height; diff --git a/src/likelihood.c b/src/likelihood.c index dd10c562..95f005c7 100644 --- a/src/likelihood.c +++ b/src/likelihood.c @@ -26,13 +26,13 @@ void detwin_intensities(const double *model, double *new_pattern, void scale_intensities(const double *model, double *new_pattern, const unsigned int *model_counts, - unsigned int *new_counts, double f0) + unsigned int *new_counts, double f0, int f0_valid) { double s; unsigned int i; s = stat_scale_intensity(model, model_counts, new_pattern, new_counts); - if ( f0 != 1.0 ) printf("%f %f\n", s, f0); + if ( f0_valid ) printf("%f %f\n", s, f0); /* NaN -> abort */ if ( isnan(s) ) return; diff --git a/src/likelihood.h b/src/likelihood.h index 860640b5..0a2bb407 100644 --- a/src/likelihood.h +++ b/src/likelihood.h @@ -23,7 +23,8 @@ extern void detwin_intensities(const double *model, double *new_pattern, extern void scale_intensities(const double *model, double *new_pattern, const unsigned int *model_counts, - unsigned int *new_counts, double f0); + unsigned int *new_counts, double f0, + int f0_valid); #endif /* LIKELIHOOD_H */ diff --git a/src/peaks.c b/src/peaks.c index a44b2913..9d5c305b 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -524,7 +524,12 @@ void output_intensities(struct image *image, UnitCell *cell, printf("cstar = %+9.7f %+9.7f %+9.7f nm^-1\n", csx/1e9, csy/1e9, csz/1e9); - printf("f0 = %7.5f (arbitrary gas detector units)\n", image->f0); + if ( image->f0_available ) { + printf("f0 = %7.5f (arbitrary gas detector units)\n", + image->f0); + } else { + printf("f0 = invalid\n"); + } for ( i=0; i<n_hits; i++ ) { diff --git a/src/process_hkl.c b/src/process_hkl.c index 9a94769a..7c42cd3e 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -246,6 +246,7 @@ int main(int argc, char *argv[]) unsigned int n_total_patterns; unsigned int *truecounts = NULL; float f0; + int f0_valid; /* Long options */ const struct option longopts[] = { @@ -360,7 +361,7 @@ int main(int argc, char *argv[]) STATUS("There are %i patterns to process\n", n_total_patterns); n_patterns = 0; - f0 = -1.0; + f0_valid = 0; do { char line[1024]; @@ -384,7 +385,8 @@ int main(int argc, char *argv[]) model_counts, new_counts); } - if ( config_scale && (f0 == -1.0) ) { + /* Assume a default I0 if we don't have one by now */ + if ( config_scale && !f0_valid ) { ERROR("No f0 value.\n"); f0 = 1.0; } @@ -392,7 +394,8 @@ int main(int argc, char *argv[]) /* Scale if requested */ if ( config_scale ) { scale_intensities(model, new_pattern, - model_counts, new_counts, f0); + model_counts, new_counts, f0, + f0_valid); } /* Start of second or later pattern */ @@ -416,7 +419,7 @@ int main(int argc, char *argv[]) progress_bar(n_patterns, n_total_patterns, "Merging"); - f0 = -1.0; + f0_valid = 0; } @@ -424,8 +427,11 @@ int main(int argc, char *argv[]) r = sscanf(line, "f0 = %f", &f0); if ( r != 1 ) { ERROR("Couldn't understand f0 line.\n"); + f0 = 1.0; + f0_valid = 0; continue; } + f0_valid = 1; } r = sscanf(line, "%i %i %i %f", &h, &k, &l, &intensity); |