From: W. Trevor King Date: Wed, 27 Oct 2010 00:35:24 +0000 (-0400) Subject: Assorted minor cleanups to pysawsim/parameter_scan.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ce84ec3d1de9c833b105f49060660ba901e4f74f;p=sawsim.git Assorted minor cleanups to pysawsim/parameter_scan.py. --- diff --git a/pysawsim/parameter_scan.py b/pysawsim/parameter_scan.py index 377e210..b8e95c0 100644 --- a/pysawsim/parameter_scan.py +++ b/pysawsim/parameter_scan.py @@ -237,7 +237,7 @@ class HistogramMatcher (object): return '%s %s' % ( self.param_format_string % tuple(params), hist_params) - def _residual(self, params): + def residual(self, params): residual = 0 for hist_params,experiment_hist in self.experiment_histograms.iteritems(): sawsim_hist = sawsim_histogram( @@ -253,7 +253,7 @@ class HistogramMatcher (object): self._plot_residual_comparison( experiment_hist, sawsim_hist, residual=r, title=title, filename=filename) - log().debug('residual: %g' % residual) + log().debug('residual %s: %g' % (params, residual)) return residual def plot(self, param_ranges, logx=False, logy=False, contour=False): @@ -276,7 +276,7 @@ class HistogramMatcher (object): log().info('point %d %d (%d of %d)' % (i, j, i*(len(y)-1) + j, (len(x)-1)*(len(y)-1))) params = (xi,yj) - r = self._residual(params) + r = self.residual(params) C[j,i] = numpy.log(r) # better resolution in valleys if MEM_DEBUG == True: log().debug('RSS: %d KB' % rss()) @@ -323,6 +323,8 @@ def parse_param_ranges_string(string): >>> parse_param_ranges_string('[1,2,3],[4,5,6]') [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] + >>> parse_param_ranges_string('[1,2,3]') + [[1.0, 2.0, 3.0]] """ ranges = [] for range_string in string.split("],["): @@ -390,19 +392,20 @@ def main(argv=None): metavar="PARAMS", help="Param range for plotting (%default).", default='[1e-5,1e-3,20],[0.1e-9,1e-9,20]') - parser.add_option("-R","--residual", dest="residual", - metavar="STRING", - help="Residual type (from 'jensen-shannon', 'chi-squared', 'mean', 'std-dev'; default: %default).", - default='jensen-shannon') - parser.add_option("-P","--plot-residuals", dest="plot_residuals", - help="Generate residual difference plots for each point in the plot range.", - default=False, action="store_true") parser.add_option("--logx", dest="logx", help="Use a log scale for the x range.", default=False, action="store_true") parser.add_option("--logy", dest="logy", help="Use a log scale for the y range.", default=False, action="store_true") + parser.add_option("-R","--residual", dest="residual", + metavar="STRING", + help="Residual type (from %s; default: %%default)." + % ', '.join(Histogram().types()), + default='jensen-shannon') + parser.add_option("-P","--plot-residuals", dest="plot_residuals", + help="Generate residual difference plots for each point in the plot range.", + default=False, action="store_true") parser.add_option("-c","--contour-plot", dest="contour_plot", help="Select contour plot (vs. the default pseudocolor plot).", default=False, action="store_true")