1 # calibcant - tools for thermally calibrating AFM cantilevers
3 # Copyright (C) 2007-2009 William Trevor King
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # The author may be contacted at <wking@drexel.edu> on the Internet, or
21 # write to Trevor King, Drexel University, Physics Dept., 3141 Chestnut St.,
22 # Philadelphia PA 19104, USA.
29 # handle extra verbose input modules, only imported if we need them
31 _final_flush_plot = None
35 def _import_pylab() : # TODO: auto detect no DISPLAY and abort
36 """Import pylab plotting functions for when we need to plot. This
37 function can be called multiple times, and ensures that the pylab
38 setup is only imported once. It defines the functions
39 _flush_plot() to be called after incremental changes,
40 _final_flush_plot(), to be called at the end of any graphical processing, and
41 _pylab, a reference to the pylab module."""
44 global _final_flush_plot
46 import pylab as _pylab
47 if _flush_plot == None :
48 if config.PYLAB_INTERACTIVE :
49 _flush_plot = _pylab.draw
51 _flush_plot = _pylab.show #_dummy_fn
52 if _final_flush_plot == None :
53 if config.PYLAB_INTERACTIVE :
54 _final_flush_plot = _pylab.draw
56 _final_flush_plot = _dummy_fn # _pylab.show
58 def write_array(ofile, array, seperator):
59 """Erite an iterable array seperated by seperator.
60 Terminate the output with an endline."""
61 strings = [repr(x) for x in array]
62 ofile.write(seperator.join(strings))