aboutsummaryrefslogtreecommitdiff
path: root/src/check_hkl.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-09-20 16:56:43 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:37 +0100
commit976170a5a1838077bfb230dfa634ed8310543815 (patch)
treea55ee0ec741b7604a1abf5f5f0274f7ffc8ff176 /src/check_hkl.c
parent1e6a810ad46056154dd8984773d15828838658b5 (diff)
Simplify compare_hkl and check_hkl, remove second to last use of "list types"
Diffstat (limited to 'src/check_hkl.c')
-rw-r--r--src/check_hkl.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/src/check_hkl.c b/src/check_hkl.c
index 6eb1d26e..c9d50c20 100644
--- a/src/check_hkl.c
+++ b/src/check_hkl.c
@@ -54,7 +54,6 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
double num[NBINS];
int cts[NBINS];
int possible[NBINS];
- unsigned int *counted;
unsigned int measurements[NBINS];
unsigned int measured[NBINS];
double total_vol, vol_per_shell;
@@ -73,6 +72,7 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
int nout = 0;
Reflection *refl;
RefListIterator *iter;
+ RefList *counted;
int hmax, kmax, lmax;
double asx, asy, asz;
double bsx, bsy, bsz;
@@ -100,24 +100,7 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
mean[i] = 0;
}
- /* Iterate over all common reflections and calculate min and max
- * resolution */
- rmin = +INFINITY; rmax = 0.0;
- for ( refl = first_refl(list, &iter);
- refl != NULL;
- refl = next_refl(refl, iter) ) {
-
- signed int h, k, l;
- double d;
-
- get_indices(refl, &h, &k, &l);
-
- d = resolution(cell, h, k, l) * 2.0;
- if ( d > rmax ) rmax = d;
- if ( d < rmin ) rmin = d;
-
- }
-
+ resolution_limits(list, cell, &rmin, &rmax);
STATUS("1/d goes from %f to %f nm^-1\n", rmin/1e9, rmax/1e9);
/* Widen the range just a little bit */
@@ -155,7 +138,7 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
rmins[NBINS-1]/1e9, rmaxs[NBINS-1]/1e9);
/* Count the number of reflections possible in each shell */
- counted = new_list_count();
+ counted = reflist_new();
cell_get_reciprocal(cell, &asx, &asy, &asz,
&bsx, &bsy, &bsz,
&csx, &csy, &csz);
@@ -170,7 +153,7 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
signed int hs, ks, ls;
int bin;
- d = resolution(cell, h, k, l) * 2.0;
+ d = 2.0 * resolution(cell, h, k, l);
bin = -1;
for ( i=0; i<NBINS; i++ ) {
@@ -182,21 +165,21 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
if ( bin == -1 ) continue;
get_asymm(sym, h, k, l, &hs, &ks, &ls);
- if ( lookup_count(counted, hs, ks, ls) ) continue;
- set_count(counted, hs, ks, ls, 1);
+ if ( find_refl(counted, hs, ks, ls) != NULL ) continue;
+ add_refl(counted, hs, ks, ls);
possible[bin]++;
}
}
}
- free(counted);
+ reflist_free(counted);
/* Calculate means */
for ( refl = first_refl(list, &iter);
refl != NULL;
- refl = next_refl(refl, iter) ) {
-
+ refl = next_refl(refl, iter) )
+ {
signed int h, k, l;
double d;
int bin;
@@ -213,14 +196,10 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
break;
}
}
- if ( bin == -1 ) {
- nout++;
- continue;
- }
+ if ( bin == -1 ) continue;
measured[bin]++;
mean[bin] += get_intensity(refl);
-
}
for ( i=0; i<NBINS; i++ ) {
@@ -230,8 +209,8 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
/* Characterise the data set */
for ( refl = first_refl(list, &iter);
refl != NULL;
- refl = next_refl(refl, iter) ) {
-
+ refl = next_refl(refl, iter) )
+ {
signed int h, k, l;
double d;
int bin;
@@ -266,7 +245,6 @@ static void plot_shells(RefList *list, UnitCell *cell, const SymOpList *sym,
nmeastot += get_redundancy(refl);
var[bin] += pow(val-mean[bin], 2.0);
-
}
STATUS("overall <snr> = %f\n", snr_total/(double)nmeas);
STATUS("%i measurements in total.\n", nmeastot);