unique to that experiment.
>>> from .manager.thread import ThreadManager
- >>> velocity_stream = StringIO(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
+ >>> histogram_stream = StringIO(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
>>> param_format_string = (
... '-s cantilever,hooke,0.05 -N1 '
... '-s folded,null -N8 '
... '-k "folded,unfolded,bell,{%g,%g}" -q folded')
>>> m = ThreadManager()
>>> sr = SawsimRunner(sawsim='bin/sawsim', manager=m)
- >>> hm = HistogramMatcher(velocity_stream, param_format_string, sr, N=3)
+ >>> hm = HistogramMatcher(histogram_stream, param_format_string, sr, N=3)
>>> hm.plot([[1e-5,1e-3,3],[0.1e-9,1e-9,3]], logx=True, logy=False)
>>> m.teardown()
"""
def _read_force_histograms(self, stream):
"""
File format:
- # comment and blank lines ignored
- <velocity in m/s><whitespace><path to histogram file>
- ...
+
+ # comment and blank lines ignored
+ #HISTOGRAM: <histogram-specific params>
+ <pysawsim.histogram.Histogram-compatible histogram>
+ #HISTOGRAM: <other histogram-specific params>
+ <another pysawsim.histogram.Histogram-compatible histogram>
+ ...
>>> import sys
>>> stream = StringIO(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
return '%s %s' % (
self.param_format_string % tuple(params), hist_params)
- def get_all_unfolding_data(self, dirname, velocity_string):
- datafile = os.path.join(dirname, "data_" + velocity_string)
- return numpy.fromfile(datafile, sep=" ")
-
- sawsim_histograms = {}
- for velocity in velocities:
- unfolding_forces = self.get_all_unfolding_data(dirname, str(velocity))
- bin_edges = histograms[velocity].bin_edges
- h = Histogram()
- h.from_data(unfolding_forces, bin_edges)
- sawsim_histograms[velocity] = h
- sawsim_histograms[velocity].normalize()
- return sawsim_histograms
-
def _residual(self, params):
residual = 0
for hist_params,experiment_hist in self.experiment_histograms.iteritems():
initial_params = [float(p) for p in options.initial_params.split(",")]
param_ranges = parse_param_ranges_string(options.param_range)
- velocity_file = args[0]
+ histogram_file = args[0]
sr_call_params = sr.initialize_from_options(options)
try:
hm = HistogramMatcher(
- file(velocity_file, 'r'), param_format_string=options.param_format,
+ file(histogram_file, 'r'),
+ param_format_string=options.param_format,
sawsim_runner=sr, residual_type=options.residual,
plot=options.plot_residuals, **sr_call_params)
#hm.fit(initial_params)