aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-03-20 17:14:12 +0100
committerThomas White <taw@physics.org>2015-04-20 15:50:39 +0200
commit68c5ab7758b1f065375f180cf574be58f904ba67 (patch)
tree6550e9dfdfab47f4ad792d195e26ef81e4fdd877 /src
parente05288c1074be5928cca8581ab4d07d80853c22a (diff)
refine_prediction(): Improve error handling
Diffstat (limited to 'src')
-rw-r--r--src/predict-refine.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/predict-refine.c b/src/predict-refine.c
index 52496198..ff5fa862 100644
--- a/src/predict-refine.c
+++ b/src/predict-refine.c
@@ -450,6 +450,12 @@ static int iterate(struct reflpeak *rps, int n, UnitCell *cell,
//show_matrix_eqn(M, v);
shifts = solve_svd(v, M, NULL, 0);
+ if ( shifts == NULL ) {
+ ERROR("Failed to solve equations.\n");
+ gsl_matrix_free(M);
+ gsl_vector_free(v);
+ return 1;
+ }
for ( i=0; i<9; i++ ) {
// STATUS("Shift %i = %e\n", i, gsl_vector_get(shifts, i));
@@ -524,8 +530,9 @@ int refine_prediction(struct image *image, Crystal *cr)
reflist = reflist_new();
n = pair_peaks(image, cr, reflist, rps);
if ( n < 10 ) {
- ERROR("Too few paired peaks to refine orientation.\n");
+ ERROR("Too few paired peaks (%i) to refine orientation.\n", n);
free(rps);
+ reflist_free(reflist);
return 1;
}
crystal_set_reflections(cr, reflist);
@@ -547,8 +554,8 @@ int refine_prediction(struct image *image, Crystal *cr)
/* Refine */
for ( i=0; i<MAX_CYCLES; i++ ) {
- iterate(rps, n, crystal_get_cell(cr), image);
update_partialities(cr, PMODEL_SCSPHERE);
+ if ( iterate(rps, n, crystal_get_cell(cr), image) ) return 1;
}
crystal_set_reflections(cr, NULL);