module only contains methods that require the capabilities of both.
"""
+try:
+ import matplotlib as _matplotlib
+ import matplotlib.pyplot as _matplotlib_pyplot
+ import time as _time # for timestamping lines on plots
+except (ImportError, RuntimeError), e:
+ _matplotlib = None
+ _matplotlib_import_error = e
+
from pypiezo.afm import AFMPiezo as _AFMPiezo
from pypiezo.base import convert_bits_to_meters as _convert_bits_to_meters
from pypiezo.base import convert_meters_to_bits as _convert_meters_to_bits
from pypiezo.surface import SurfaceError as _SurfaceError
from . import LOG as _LOG
+from . import package_config as _package_config
from .stepper import Stepper as _Stepper
from .temperature import Temperature as _Temperature
def stepper_approach(self, target_deflection):
_LOG.info('approach with stepper until deflection > {}'.format(
target_deflection))
+ record_data = _package_config['matplotlib']
+ if record_data:
+ position = []
+ deflection = []
self._check_target_deflection(deflection=target_deflection)
cd = self.piezo.read_deflection() # cd = current deflection in bits
_LOG.debug('single stepping approach')
cd, target_deflection))
self.stepper.single_step(1) # step in
cd = self.piezo.read_deflection()
+ if record_data:
+ position.append(self.stepper.position)
+ deflection.append(cd)
+ if _package_config['matplotlib']:
+ figure = _matplotlib_pyplot.figure()
+ axes = figure.add_subplot(1, 1, 1)
+ axes.hold(False)
+ timestamp = _time.strftime('%H-%M-%S')
+ axes.set_title('stepper approach {}'.format(timestamp))
+ plot = axes.plot(position, deflection, 'b.-')
+ figure.canvas.draw()
+ figure.show()
+ if not _matplotlib.is_interactive():
+ _matplotlib_pyplot.show()
def move_toward_surface(self, distance):
"""Step in approximately `distance` meters.
class PackageConfig (_h5config_tools.PackageConfig):
"Configure `pyafm` module operation"
- pass
+ settings = _h5config_tools.PackageConfig.settings + [
+ _config.BooleanSetting(
+ name='matplotlib',
+ help='Plot pyafm actions using `matplotlib`.',
+ default=False),
+ ]
class _TemperatureUnit (object):