aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2012-07-23 15:00:33 +0200
committerThomas White <taw@physics.org>2012-07-23 15:00:33 +0200
commit9964cdeafc1338f5841270bc5392ad8e3c8eb33e (patch)
tree0fe784c1f27967034690b32bc67cb4426d79aae3 /libcrystfel/src
parente63626f4207fa58d3ea70b68f2862630d281598d (diff)
parent6eb751c2230226723884cc7bc473d65b91064b81 (diff)
Merge branch 'tom/speed'
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/cell.c2
-rw-r--r--libcrystfel/src/cell.h2
-rw-r--r--libcrystfel/src/index.c2
-rw-r--r--libcrystfel/src/index.h3
-rw-r--r--libcrystfel/src/mosflm.c7
-rw-r--r--libcrystfel/src/peaks.c42
-rw-r--r--libcrystfel/src/reax.c7
7 files changed, 50 insertions, 15 deletions
diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c
index 31d3b9b1..b6ea010b 100644
--- a/libcrystfel/src/cell.c
+++ b/libcrystfel/src/cell.c
@@ -694,7 +694,7 @@ static int same_vector(struct cvec a, struct cvec b)
/* Attempt to make 'cell' fit into 'template' somehow */
UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose,
- float *tols, int reduce)
+ const float *tols, int reduce)
{
signed int n1l, n2l, n3l;
double asx, asy, asz;
diff --git a/libcrystfel/src/cell.h b/libcrystfel/src/cell.h
index cbe84772..bd2719dd 100644
--- a/libcrystfel/src/cell.h
+++ b/libcrystfel/src/cell.h
@@ -118,7 +118,7 @@ extern UnitCell *rotate_cell(UnitCell *in, double omega, double phi,
extern void cell_print(UnitCell *cell);
extern UnitCell *match_cell(UnitCell *cell, UnitCell *tempcell, int verbose,
- float *ltl, int reduce);
+ const float *ltl, int reduce);
extern UnitCell *match_cell_ab(UnitCell *cell, UnitCell *tempcell);
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index f4bc9d6c..102a5312 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -167,7 +167,7 @@ void map_all_peaks(struct image *image)
void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm,
int cellr, int verbose, IndexingPrivate **ipriv,
- int config_insane, float *ltl)
+ int config_insane, const float *ltl)
{
int i;
int n = 0;
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index c4e15f09..9d23f3fb 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -74,7 +74,8 @@ extern void map_all_peaks(struct image *image);
extern void index_pattern(struct image *image, UnitCell *cell,
IndexingMethod *indm, int cellr, int verbose,
- IndexingPrivate **priv, int config_insane, float *ltl);
+ IndexingPrivate **priv, int config_insane,
+ const float *ltl);
extern void cleanup_indexing(IndexingPrivate **priv);
diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c
index 410b779a..ed118aa4 100644
--- a/libcrystfel/src/mosflm.c
+++ b/libcrystfel/src/mosflm.c
@@ -379,7 +379,6 @@ static int mosflm_readable(struct image *image, struct mosflm_data *mosflm)
rval = read(mosflm->pty, mosflm->rbuffer+mosflm->rbufpos,
mosflm->rbuflen-mosflm->rbufpos);
-
if ( (rval == -1) || (rval == 0) ) return 1;
mosflm->rbufpos += rval;
@@ -436,7 +435,6 @@ static int mosflm_readable(struct image *image, struct mosflm_data *mosflm)
break;
case MOSFLM_INPUT_PROMPT :
-
mosflm_send_next(image, mosflm);
endbit_length = i+7;
break;
@@ -513,6 +511,7 @@ void run_mosflm(struct image *image, UnitCell *cell)
remove(mosflm->newmatfile);
mosflm->pid = forkpty(&mosflm->pty, NULL, NULL, NULL);
+
if ( mosflm->pid == -1 ) {
ERROR("Failed to fork for MOSFLM\n");
free(mosflm);
@@ -545,6 +544,7 @@ void run_mosflm(struct image *image, UnitCell *cell)
mosflm->step = 1; /* This starts the "initialisation" procedure */
mosflm->finished_ok = 0;
+
do {
fd_set fds;
@@ -559,7 +559,7 @@ void run_mosflm(struct image *image, UnitCell *cell)
sval = select(mosflm->pty+1, &fds, NULL, NULL, &tv);
- if ( sval == -1 ) {
+ if ( sval == -1 ) {
int err = errno;
ERROR("select() failed: %s\n", strerror(err));
rval = 1;
@@ -570,6 +570,7 @@ void run_mosflm(struct image *image, UnitCell *cell)
rval = 1;
}
+
} while ( !rval );
close(mosflm->pty);
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index ffe77290..0a6a439c 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -160,6 +160,8 @@ static int *make_BgMask(struct image *image, struct panel *p,
mask = calloc(w*h, sizeof(int));
if ( mask == NULL ) return NULL;
+ if ( image->reflections == NULL ) return mask;
+
/* Loop over all reflections */
for ( refl = first_refl(image->reflections, &iter);
refl != NULL;
@@ -278,17 +280,26 @@ static int integrate_peak(struct image *image, int cfs, int css,
/* It must have all the "good" bits to be valid */
if ( !((flags & image->det->mask_good)
- == image->det->mask_good) ) return 1;
+ == image->det->mask_good) ) {
+ free(bgPkMask);
+ return 1;
+ }
/* If it has any of the "bad" bits, reject */
- if ( flags & image->det->mask_bad ) return 1;
+ if ( flags & image->det->mask_bad ) {
+ free(bgPkMask);
+ return 1;
+ }
}
val = image->data[idx];
/* Veto peak if it contains saturation in bg region */
- if ( use_max_adu && (val > p->max_adu) ) return 1;
+ if ( use_max_adu && (val > p->max_adu) ) {
+ free(bgPkMask);
+ return 1;
+ }
bg_tot += val;
bg_tot_sq += pow(val, 2.0);
@@ -297,7 +308,10 @@ static int integrate_peak(struct image *image, int cfs, int css,
}
}
- if ( bg_counts == 0 ) return 1;
+ if ( bg_counts == 0 ) {
+ free(bgPkMask);
+ return 1;
+ }
bg_mean = bg_tot / bg_counts;
bg_var = (bg_tot_sq/bg_counts) - pow(bg_mean, 2.0);
@@ -330,17 +344,26 @@ static int integrate_peak(struct image *image, int cfs, int css,
/* It must have all the "good" bits to be valid */
if ( !((flags & image->det->mask_good)
- == image->det->mask_good) ) return 1;
+ == image->det->mask_good) ) {
+ free(bgPkMask);
+ return 1;
+ }
/* If it has any of the "bad" bits, reject */
- if ( flags & image->det->mask_bad ) return 1;
+ if ( flags & image->det->mask_bad ) {
+ free(bgPkMask);
+ return 1;
+ }
}
val = image->data[idx] - bg_mean;
/* Veto peak if it contains saturation */
- if ( use_max_adu && (image->data[idx] > p->max_adu) ) return 1;
+ if ( use_max_adu && (image->data[idx] > p->max_adu) ) {
+ free(bgPkMask);
+ return 1;
+ }
pk_counts++;
pk_total += val;
@@ -358,7 +381,10 @@ static int integrate_peak(struct image *image, int cfs, int css,
var = pk_counts * bg_var;
var += aduph * pk_total;
- if ( var < 0.0 ) return 1;
+ if ( var < 0.0 ) {
+ free(bgPkMask);
+ return 1;
+ }
if ( intensity != NULL ) *intensity = pk_total;
if ( sigma != NULL ) *sigma = sqrt(var);
diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c
index 58dce40a..3124a77c 100644
--- a/libcrystfel/src/reax.c
+++ b/libcrystfel/src/reax.c
@@ -348,6 +348,7 @@ static double iterate_refine_vector(double *x, double *y, double *z,
gsl_matrix_free(C);
gsl_vector_free(A);
+ gsl_vector_free(t);
return dtmax;
}
@@ -1019,6 +1020,7 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell)
fftw_complex *fft_out;
double pmax;
struct reax_search *s;
+ int i;
assert(pp->indm == INDEXING_REAX);
p = (struct reax_private *)pp;
@@ -1045,6 +1047,11 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell)
assemble_cells_from_candidates(image, s, cell);
+ for ( i=0; i<s->n_search; i++ ) {
+ free(s->search[i].cand);
+ }
+ free(s->search);
+ free(s);
fftw_free(fft_in);
fftw_free(fft_out);
}