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