1 # calibcant - tools for thermally calibrating AFM cantilevers
3 # Copyright (C) 2008-2010 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/>.
25 # handle extra verbose input modules, only imported if we need them
27 _final_flush_plot = None
31 def _import_pylab() : # TODO: auto detect no DISPLAY and abort
32 """Import pylab plotting functions for when we need to plot. This
33 function can be called multiple times, and ensures that the pylab
34 setup is only imported once. It defines the functions
35 _flush_plot() to be called after incremental changes,
36 _final_flush_plot(), to be called at the end of any graphical processing, and
37 _pylab, a reference to the pylab module."""
40 global _final_flush_plot
42 import pylab as _pylab
43 if _flush_plot == None :
44 if config.PYLAB_INTERACTIVE :
45 _flush_plot = _pylab.draw
47 _flush_plot = _pylab.show #_dummy_fn
48 if _final_flush_plot == None :
49 if config.PYLAB_INTERACTIVE :
50 _final_flush_plot = _pylab.draw
52 _final_flush_plot = _dummy_fn # _pylab.show
54 def write_array(ofile, array, seperator):
55 """Erite an iterable array seperated by seperator.
56 Terminate the output with an endline."""
57 strings = [repr(x) for x in array]
58 ofile.write(seperator.join(strings))