aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-12 14:40:16 -0800
committerThomas White <taw@physics.org>2012-02-22 15:27:14 +0100
commit9a2773d90137c51149c254f376237ba18386ee8e (patch)
tree43ed1bc5a5bd8dc54d92163a9be61300ebe476c5 /src
parent54ff7acab385a0c524b8f2194e95621e92843db1 (diff)
More stream handling and reflection counting
Diffstat (limited to 'src')
-rw-r--r--src/partialator.c13
-rw-r--r--src/stream.c14
2 files changed, 20 insertions, 7 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 31b2b7e9..50f37fd8 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -155,6 +155,9 @@ int main(int argc, char *argv[])
int n_iter = 10;
struct beam_params *beam = NULL;
double *I_full;
+ int n_found = 0;
+ int n_expected = 0;
+ int n_notfound = 0;
/* Long options */
const struct option longopts[] = {
@@ -339,14 +342,15 @@ int main(int argc, char *argv[])
int clamp1, clamp2;
get_indices(refl, &h, &k, &l);
- STATUS("%3i %3i %3i\n", h, k, l);
+ get_detector_pos(refl, &x, &y);
+ n_expected++;
peak = find_refl(peaks, h, k, l);
if ( peak == NULL ) {
- if ( (h==0) && (k==0) && (l==0) ) continue;
- STATUS("%3i %3i %3i not found\n", h, k, l);
+ n_notfound++;
continue;
}
+ n_found++;
get_asymm(h, k, l, &ha, &ka, &la, sym);
add_item(obs, ha, ka, la);
@@ -364,6 +368,9 @@ int main(int argc, char *argv[])
}
fclose(fh);
+ STATUS("Found %5.2f%% of the expected peaks (%i %i %i).\n",
+ 100.0 * (double)n_found / n_expected,
+ n_found, n_notfound, n_expected);
cts = new_list_count();
diff --git a/src/stream.c b/src/stream.c
index 69d64bae..ffee4a6c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -79,10 +79,12 @@ int find_chunk(FILE *fh, UnitCell **cell, char **filename, double *ev)
char *rval = NULL;
int have_ev = 0;
int have_cell = 0;
+ int have_filename = 0;
+ long start_of_chunk = 0;
do {
- long pos = ftell(fh);
+ const long start_of_line = ftell(fh);
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
@@ -96,11 +98,15 @@ int find_chunk(FILE *fh, UnitCell **cell, char **filename, double *ev)
*ev = 0.0;
have_cell = 0;
have_ev = 0;
+ have_filename = 1;
+ start_of_chunk = ftell(fh);
}
+ if ( !have_filename ) continue;
+
if ( strncmp(line, "astar = ", 8) == 0 ) {
- fseek(fh, pos, 0);
+ fseek(fh, start_of_line, 0);
*cell = read_orientation_matrix(fh);
have_cell = 1;
}
@@ -111,8 +117,8 @@ int find_chunk(FILE *fh, UnitCell **cell, char **filename, double *ev)
}
if ( strlen(line) == 0 ) {
- if ( have_cell && have_ev ) {
- fseek(fh, pos, 0);
+ if ( have_filename && have_cell && have_ev ) {
+ fseek(fh, start_of_chunk, 0);
return 0;
}
}