diff options
author | Thomas White <taw@physics.org> | 2010-09-24 17:15:27 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:59 +0100 |
commit | a48a07c11a473112d79a455cb8daa8cf4ba7a2d9 (patch) | |
tree | 953d492e4ccc92e6360f79d3fe7f03a958976344 | |
parent | 237f0f65e210812db7566ffd2d95ac2ada65cf34 (diff) |
process_hkl: Add another type of scaling
-rw-r--r-- | src/process_hkl.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/process_hkl.c b/src/process_hkl.c index 82bbbb74..b9a3fbd6 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -304,6 +304,13 @@ static void merge_pattern(double *model, ReflItemList *observed, } +enum { + SCALE_NONE, + SCALE_CONSTINT, + SCALE_TWOPASS +}; + + static void scale_intensities(const double *model, ReflItemList *model_items, double *new_pattern, ReflItemList *new_items, double f0, int f0_valid, const char *sym) @@ -312,6 +319,7 @@ static void scale_intensities(const double *model, ReflItemList *model_items, double top = 0.0; double bot = 0.0; unsigned int i; + const int scaling = SCALE_CONSTINT; for ( i=0; i<num_items(new_items); i++ ) { @@ -322,20 +330,43 @@ static void scale_intensities(const double *model, ReflItemList *model_items, /* Get the next item in the list of new reflections */ it = get_item(new_items, i); - /* Find the (only) partner in the model */ - find_unique_equiv(model_items, it->h, it->k, it->l, sym, - &hu, &ku, &lu); + switch ( scaling ) { + case SCALE_TWOPASS : + + /* Find the (only) partner in the model */ + find_unique_equiv(model_items, it->h, it->k, it->l, sym, + &hu, &ku, &lu); + + i1 = lookup_intensity(model, hu, ku, lu); + i2 = lookup_intensity(new_pattern, it->h, it->k, it->l); + + /* Calculate LSQ estimate of scaling factor */ + top += i1 * i2; + bot += i2 * i2; + + break; + + case SCALE_CONSTINT : + + /* Sum up the intensity in the pattern */ + i2 = lookup_intensity(new_pattern, it->h, it->k, it->l); + top += i2; - i1 = lookup_intensity(model, hu, ku, lu); - i2 = lookup_intensity(new_pattern, it->h, it->k, it->l); + break; - top += i1 * i2; - bot += i2 * i2; + } } - s = top / bot; - if ( f0_valid ) printf("%f %f\n", s, f0); + switch ( scaling ) { + case SCALE_TWOPASS : + s = top / bot; + break; + case SCALE_CONSTINT : + s = 1000.0 / top; + break; + } + //if ( f0_valid ) printf("%f %f\n", s, f0); /* Multiply the new pattern up by "s" */ for ( i=0; i<LIST_SIZE; i++ ) { |