Commit 9a2773d9 authored by Thomas White's avatar Thomas White Committed by Thomas White
Browse files

More stream handling and reflection counting

parent 54ff7aca
......@@ -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();
......
......@@ -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;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment