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