>>> from pypiezo.base import PiezoAxis, InputChannel
>>> from pypiezo.config import ChannelConfig, AxisConfig
>>> from stepper import Stepper
- >>> from pyafm import AFM
+ >>> from pyafm.afm import AFM
>>> from .config import (CalibrationConfig, BumpConfig,
... TemperatureConfig, VibrationConfig)
>>> from .analyze import calib_load_all
>>> axis_config.update(
... {'gain':20, 'sensitivity':8e-9, 'minimum':-9})
>>> axis_channel_config = ChannelConfig()
+ >>> axis_channel_config['name'] = 'z'
+ >>> axis_config['channel'] = axis_channel_config
>>> input_channel_config = ChannelConfig()
+ >>> input_channel_config['name'] = 'deflection'
- >>> a = PiezoAxis(axis_config=axis_config,
- ... axis_channel_config=axis_channel_config,
- ... axis_channel=axis_channel, name='z')
+ >>> a = PiezoAxis(config=axis_config, axis_channel=axis_channel)
>>> a.setup_config()
- >>> c = InputChannel(
- ... channel_config=input_channel_config, channel=input_channel,
- ... name='deflection')
+ >>> c = InputChannel(config=input_channel_config, channel=input_channel)
>>> c.setup_config()
- >>> piezo = AFMPiezo(axes=[a], input_channels=[c])
+ >>> piezo = AFMPiezo(axes=[a], inputs=[c])
Setup a `stepper` instance.
Test calibration:
>>> calibration_config = CalibrationConfig()
- >>> bump_config = BumpConfig()
- >>> temperature_config = TemperatureConfig()
- >>> vibration_config = VibrationConfig()
- >>> calib(afm, calibration_config, bump_config, temperature_config,
- ... vibration_config, filename=filename, group='/')
+ >>> calibration_config['bump'] = BumpConfig()
+ >>> calibration_config['temperature'] = TemperatureConfig()
+ >>> calibration_config['vibration'] = VibrationConfig()
+ >>> calib(afm, calibration_config, filename=filename, group='/')
TODO: replace skipped example data with real-world values
>>> pprint_HDF5(filename) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ /
+ /bump
+ /bump/0
+ /bump/0/config
+ /bump/0/config/bump
+ <HDF5 dataset "far-steps": shape (), type "<i4">
+ 200
+ ...
+ /bump/0/config/deflection
+ /bump/0/config/deflection/channel
+ <HDF5 dataset "channel": shape (), type "<i4">
+ 0
+ ...
+ /bump/0/config/z
+ /bump/0/config/z/axis
+ /bump/0/config/z/axis/channel
+ <HDF5 dataset "channel": shape (), type "<i4">
+ 0
+ ...
+ <HDF5 dataset "gain": shape (), type "<i4">
+ 20
+ ...
+ <HDF5 dataset "processed": shape (), type "<f8">
+ ...
+ /bump/0/raw
+ <HDF5 dataset "deflection": shape (2048,), type "<u2">
+ [...]
+ <HDF5 dataset "z": shape (2048,), type "<u2">
+ [...]
+ /bump/1
+ ...
+ /calibration
+ /calibration/config
+ /calibration/config/bump
+ <HDF5 dataset "far-steps": shape (), type "<i4">
+ 200
+ ...
+ <HDF5 dataset "num-bumps": shape (), type "<i4">
+ 10
+ ...
+ /calibration/processed
+ /calibration/processed/spring-constant
+ <HDF5 dataset "data": shape (), type "<f8">
+ ...
+ <HDF5 dataset "standard-deviation": shape (), type "<f8">
+ ...
+ <HDF5 dataset "units": shape (), type "|S3">
+ N/m
+ /calibration/raw
+ /calibration/raw/photodiode-sensitivity
+ <HDF5 dataset "data": shape (10,), type "<f8">
+ [...]
+ <HDF5 dataset "units": shape (), type "|S3">
+ V/m
+ /calibration/raw/temperature
+ <HDF5 dataset "data": shape (10,), type "<f8">
+ [...]
+ <HDF5 dataset "units": shape (), type "|S1">
+ K
+ /calibration/raw/thermal-vibration-variance
+ <HDF5 dataset "data": shape (20,), type "<f8">
+ [...]
+ <HDF5 dataset "units": shape (), type "|S3">
+ V^2
+ /temperature
+ /temperature/0
+ /temperature/0/config
+ <HDF5 dataset "default": shape (), type "|b1">
+ False
+ <HDF5 dataset "units": shape (), type "|S7">
+ Celsius
+ <HDF5 dataset "processed": shape (), type "<f8">
+ 295.15
+ <HDF5 dataset "raw": shape (), type "<i4">
+ 22
+ /temperature/1
+ ...
+ /vibration
+ /vibration/0
+ /vibration/0/config
+ /vibration/0/config/deflection
+ <HDF5 dataset "channel": shape (), type "<i4">
+ 0
+ ...
+ /vibration/0/config/vibration
+ <HDF5 dataset "chunk-size": shape (), type "<i4">
+ 2048
+ ...
+ <HDF5 dataset "processed": shape (), type "<f8">
+ ...
+ /vibration/0/raw
+ <HDF5 dataset "deflection": shape (65536,), type "<u2">
+ [...]
+ /vibration/1
+ ...
+ /vibration/19
+ ...
+ /vibration/19/raw
+ <HDF5 dataset "deflection": shape (65536,), type "<u2">
+ [...]
>>> everything = calib_load_all(filename, '/')
- >>> pprint(everything)
-
+ >>> pprint(everything) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ {'bump_details': [{'bump_config': <BumpConfig ...>,
+ 'deflection_channel_config': <ChannelConfig ...>,
+ 'processed_bump': ...,
+ 'raw_bump': {'deflection': array([...], dtype=uint16),
+ 'z': array([...], dtype=uint16)},
+ 'z_axis_config': <AxisConfig ...>},
+ ...],
+ 'bumps': array([...]),
+ 'calibration_config': <CalibrationConfig ...>,
+ 'k': ...,
+ 'k_s': ...,
+ 'temperature_details': [{'processed_temperature': ...,
+ 'raw_temperature': array(22),
+ 'temperature_config': <TemperatureConfig ...>},
+ ...],
+ 'temperatures': array([...]),
+ 'vibration_details': [{'deflection_channel_config': <ChannelConfig ...>,
+ 'processed_vibration': ...,
+ 'raw_vibration': array([...], dtype=uint16),
+ 'vibration_config': <VibrationConfig ...>},
+ ...],
+ 'vibrations': array([...])}
+
Close the Comedi device.
>>> d.close()
os.remove(filename)
"""
bumps, Ts, vibs = calib_acquire(
- afm, calibration_config, bump_config, temperature_config,
- vibration_config, filename=filename, group=group)
+ afm, calibration_config, filename=filename, group=group)
# TODO: convert vib units?
k,k_s = _calib_analyze(bumps, Ts, vibs)
_calib_save(filename, group=group+'calibration/', bumps=bumps,