From 42967aa382f2a629371b71b5da716918effe32de Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 28 Aug 2010 08:42:19 -0400 Subject: [PATCH] Document fit parameter extraction via PyYAML. --- doc/tutorial.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/doc/tutorial.txt b/doc/tutorial.txt index 65d288e..f8f06c3 100644 --- a/doc/tutorial.txt +++ b/doc/tutorial.txt @@ -308,9 +308,64 @@ ways.:: hooke> remove_cantilever_from_extension --block retract hooke> flat_peaks_to_polymer_peaks --block retract hooke> polymer_fit_peaks --block retract - hooke> export_block --block retract --output myblock.dat -See each command's `Help`_ for details. +This stores the fit parameters in the block's +:attr:`~hooke.curve.Data.info` dictionary (see each command's `Help`_ +for details). To access the parameters, save the playlist,:: + + hooke> save_playlist --output mylist.hkp + +load it with PyYAML_:: + + $ python + >>> import yaml + >>> import hooke.util.yaml + >>> mylist = yaml.load(open('mylist.hkp', 'r')) + +navigate to your curve,:: + + >>> mylist.jump(1234) + +and extract your parameter.:: + + >>> mylist.current().data[1].info['polymer peak 0']['contour length (m)'] + 2.124...e-08 + +You can also get a list of all available parameters:: + + >>> mylist.current().data[1].info['polymer peak 0'].keys() + ['model', 'contour length (m)', 'temperature (K)', 'fit', + 'persistence length (m)'] + +or just pprint_ the whole thing:: + + >>> from pprint import pprint + >>> pprint(mylist.current().data[1].info['polymer peak 0']) + {'contour length (m)': 2.1248220207858103e-08, + 'fit': {'active fitted parameters': 3.7024307200788127, + 'active parameters': 3.7024307200788127, + 'convergence flag': 1, + 'covariance matrix': None, + 'data scale factor': 5.2716380732198972e-10, + 'fitted parameters': -2.5663294148411571, + 'info': {'fjac': None, + 'fvec': None, + 'ipvt': None, + 'nfev': 16, + 'qtf': None}, + 'initial parameters': [-0.69314718055994529], + 'message': 'Both actual and predicted relative reductions in the sum of squares\n are at most 0.000000', + 'rescaled': True, + 'scale': None}, + 'model': u'WLC', + 'persistence length (m)': 4.0000000000000001e-10, + 'temperature (K)': 301.0} + +.. _PyYAML: http://pyyaml.org/ +.. _pprint: http://docs.python.org/library/pprint.html + +.. todo:: UI access to block (and curve?) info dicts. Someone should + make a tree-based object browser ;). Command stacks ~~~~~~~~~~~~~~ -- 2.26.2