log().debug('residual %s: %g' % (params, residual))
return residual
- def plot(self, param_ranges, logx=False, logy=False, contour=False):
+ def plot(self, param_ranges, logx=False, logy=False, contour=False,
+ csv=None):
+ if csv:
+ csv.write(','.join(('param 1', 'param 2', 'fit quality')) + '\n')
xranges = param_ranges[0]
yranges = param_ranges[1]
if logx == False:
% (i, j, i*(len(y)-1) + j, (len(x)-1)*(len(y)-1)))
params = (xi,yj)
r = self.residual(params)
+ if csv:
+ csv.write(','.join([str(v) for v in (xi,yj,r)]) + '\n')
C[j,i] = numpy.log(r) # better resolution in valleys
if MEM_DEBUG == True:
log().debug('RSS: %d KB' % rss())
parser.add_option('-c','--contour-plot', dest='contour_plot',
help='Select contour plot (vs. the default pseudocolor plot).',
default=False, action='store_true')
+ parser.add_option('--csv', dest='csv', metavar='FILE',
+ help='Save fit qualities to a comma-separated value file FILE.'),
options,args = parser.parse_args(argv)
initial_params = [float(p) for p in options.initial_params.split(",")]
param_ranges = parse_param_ranges_string(options.param_range)
histogram_file = args[0]
+ csv = None
sr_call_params = sr.initialize_from_options(options)
try:
sawsim_runner=sr, residual_type=options.residual,
plot=options.plot_residuals, **sr_call_params)
#hm.fit(initial_params)
+ if options.csv:
+ csv = open(options.csv, 'w')
hm.plot(param_ranges, logx=options.logx, logy=options.logy,
- contour=options.contour_plot)
+ contour=options.contour_plot, csv=csv)
finally:
sr.teardown()
+ if csv:
+ csv.close()