From 324679b72a73b57c9c911d4e1229d4a508e89d15 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 18 Oct 2012 13:10:36 -0400 Subject: [PATCH] compare-unfold.py: add --single option for less crowded plots. --- .../compare-unfold.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/posts/Comparing_velocity_clamp_experiments/compare-unfold.py b/posts/Comparing_velocity_clamp_experiments/compare-unfold.py index 9ffd53a..f27127f 100755 --- a/posts/Comparing_velocity_clamp_experiments/compare-unfold.py +++ b/posts/Comparing_velocity_clamp_experiments/compare-unfold.py @@ -26,23 +26,26 @@ from matplotlib import pylab as _pylab from pypiezo import surface as _pypiezo_surface -def load_yang_curves(basedir): +def load_yang_curves(basedir, single=False): for series in sorted(_os.listdir(basedir)): if series.endswith('.ibw'): path = _os.path.join(basedir, series) for curve in _gyang_curve.load_all_traces(path): yield curve + if single: + return -def load_king_curves(basedir): +def load_king_curves(basedir, single=False): for path in sorted(_os.listdir(basedir)): if path.endswith('.h5'): curve = _os.path.join(basedir, path) yield _crunch.load_pull(filename=curve) + if single: + return - -def plot_comparison(yang_dir, king_dir): - yang = load_yang_curves(yang_dir) - king = load_king_curves(king_dir) +def plot_comparison(yang_dir, king_dir, single=False): + yang = load_yang_curves(yang_dir, single=single) + king = load_king_curves(king_dir, single=single) figure = _pylab.figure() axes = figure.add_subplot(1, 1, 1) axes.set_title('velocity clamp unfolding') @@ -55,6 +58,7 @@ def plot_comparison(yang_dir, king_dir): (curve.piezo_expanded + 2**15, curve.deflection + 2**15, 'b')) for curve in king: xyc.append((curve['alpha_v'], curve['alpha_f'], 'r')) + for x, y, c in xyc: ddict = { 'approach': { # for _analyze_surface_position_data @@ -77,6 +81,9 @@ if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + '--single', action='store_const', const=True, + help='compare only a single curve of each type') parser.add_argument( 'yang', metavar='DIR', help="directory for data taken with Prof. Yang's LabVIEW program") @@ -88,5 +95,6 @@ if __name__ == '__main__': plot_comparison( yang_dir=_os.path.expanduser(args.yang), - king_dir=_os.path.expanduser(args.king)) + king_dir=_os.path.expanduser(args.king), + single=args.single) _pylab.show() -- 2.26.2