From e9b593711b4c22ee8ce2b31a92162c7c9e448510 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 14 Mar 2012 11:24:57 +0100 Subject: powder_plot: Catch trouble with resolution limits --- src/powder_plot.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/powder_plot.c b/src/powder_plot.c index 5423d759..9df4c301 100644 --- a/src/powder_plot.c +++ b/src/powder_plot.c @@ -661,8 +661,8 @@ static void show_help(const char *s) " linear : linear (default)\n" " wilson : even spacing in Wilson plots\n" " volume : constant volume\n" -" --max=n The maximum 1/d to be considered in plot.\n" -" --min=n The minimum 1/d to be considered in plot.\n" +" --max=n The maximum 1/d to be considered in plot.\n" +" --min=n The minimum 1/d to be considered in plot.\n" " -d, --data= Use to select the kind of stream data in histogram.\n" " Choose from:\n" " reflection : uses peak positons from indexed\n" @@ -695,6 +695,14 @@ static void show_help(const char *s) } +static void rlim_bailout() +{ + ERROR("Unable to automatically determine the resolution limits.\n"); + ERROR("Try again with --min and --max.\n"); + exit(1); +} + + int main(int argc, char *argv[]) { FILE *fh = NULL; @@ -1031,14 +1039,17 @@ int main(int argc, char *argv[]) /* get q range from Miller indices in hkl file. */ if ((hist_info.q_min < 0.0) && (hist_info.q_max < 0.0)) { + if ( image.reflections == NULL ) rlim_bailout(); resolution_limits(image.reflections, cell, &hist_info.q_min, &hist_info.q_max); } else if (hist_info.q_min < 0.0) { double dummy; + if ( image.reflections == NULL ) rlim_bailout(); resolution_limits(image.reflections, cell, &hist_info.q_min, &dummy); } else if (hist_info.q_max < 0.0) { double dummy; + if ( image.reflections == NULL ) rlim_bailout(); resolution_limits(image.reflections, cell, &dummy, &hist_info.q_max); } @@ -1052,8 +1063,8 @@ int main(int argc, char *argv[]) } if ( hist_info.q_min >= hist_info.q_max ) { - ERROR("the minimum 1/d value of: %e " - "is greator then your max 1/d value of: %e\n", + ERROR("the minimum 1/d value (%e) " + "is greater then your max 1/d value (%e).\n", hist_info.q_min, hist_info.q_max); return 1; } -- cgit v1.2.3