1 # calibcant - tools for thermally calibrating AFM cantilevers
3 # Copyright (C) 2008-2011 W. Trevor King <wking@drexel.edu>
5 # This file is part of calibcant.
7 # calibcant is free software: you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation, either
10 # version 3 of the License, or (at your option) any later version.
12 # calibcant is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with calibcant. If not, see
19 # <http://www.gnu.org/licenses/>.
24 # handle extra verbose input modules, only imported if we need them
26 _final_flush_plot = None
30 def _import_pylab() : # TODO: auto detect no DISPLAY and abort
31 """Import pylab plotting functions for when we need to plot. This
32 function can be called multiple times, and ensures that the pylab
33 setup is only imported once. It defines the functions
34 _flush_plot() to be called after incremental changes,
35 _final_flush_plot(), to be called at the end of any graphical processing, and
36 _pylab, a reference to the pylab module."""
39 global _final_flush_plot
41 import pylab as _pylab
42 if _flush_plot == None :
43 if config.PYLAB_INTERACTIVE :
44 _flush_plot = _pylab.draw
46 _flush_plot = _pylab.show #_dummy_fn
47 if _final_flush_plot == None :
48 if config.PYLAB_INTERACTIVE :
49 _final_flush_plot = _pylab.draw
51 _final_flush_plot = _dummy_fn # _pylab.show
53 def write_array(ofile, array, seperator):
54 """Erite an iterable array seperated by seperator.
55 Terminate the output with an endline."""
56 strings = [repr(x) for x in array]
57 ofile.write(seperator.join(strings))