From 0288b1012bb463dde7b310eb320971ea070e2caf Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 30 Sep 2011 14:36:22 -0400 Subject: [PATCH] Fix problems with the transition to the new nested-Config h5config package. Also restore BumpConfig's `initial-position` setting, since it's critical to running a bump. I removed it when I mistakenly thought it was storeing the output voltage used as the initial position (something that you'd measure during a bump). I guess I should have read the help string before I deleted it ;). There are also a number of numpy array -> float conversions when loading HDF5. This avoids excessive numpy-fication with h5py v2.0. --- calibcant/calibrate.py | 153 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 136 insertions(+), 17 deletions(-) diff --git a/calibcant/calibrate.py b/calibcant/calibrate.py index 426abbf..2f850e1 100644 --- a/calibcant/calibrate.py +++ b/calibcant/calibrate.py @@ -187,7 +187,7 @@ def calib(afm, calibration_config, filename=None, group='/'): >>> 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 @@ -222,19 +222,18 @@ def calib(afm, calibration_config, filename=None, group='/'): >>> 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. @@ -256,16 +255,137 @@ def calib(afm, calibration_config, filename=None, group='/'): 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 + + 200 + ... + /bump/0/config/deflection + /bump/0/config/deflection/channel + + 0 + ... + /bump/0/config/z + /bump/0/config/z/axis + /bump/0/config/z/axis/channel + + 0 + ... + + 20 + ... + + ... + /bump/0/raw + + [...] + + [...] + /bump/1 + ... + /calibration + /calibration/config + /calibration/config/bump + + 200 + ... + + 10 + ... + /calibration/processed + /calibration/processed/spring-constant + + ... + + ... + + N/m + /calibration/raw + /calibration/raw/photodiode-sensitivity + + [...] + + V/m + /calibration/raw/temperature + + [...] + + K + /calibration/raw/thermal-vibration-variance + + [...] + + V^2 + /temperature + /temperature/0 + /temperature/0/config + + False + + Celsius + + 295.15 + + 22 + /temperature/1 + ... + /vibration + /vibration/0 + /vibration/0/config + /vibration/0/config/deflection + + 0 + ... + /vibration/0/config/vibration + + 2048 + ... + + ... + /vibration/0/raw + + [...] + /vibration/1 + ... + /vibration/19 + ... + /vibration/19/raw + + [...] >>> everything = calib_load_all(filename, '/') - >>> pprint(everything) - + >>> pprint(everything) # doctest: +ELLIPSIS, +REPORT_UDIFF + {'bump_details': [{'bump_config': , + 'deflection_channel_config': , + 'processed_bump': ..., + 'raw_bump': {'deflection': array([...], dtype=uint16), + 'z': array([...], dtype=uint16)}, + 'z_axis_config': }, + ...], + 'bumps': array([...]), + 'calibration_config': , + 'k': ..., + 'k_s': ..., + 'temperature_details': [{'processed_temperature': ..., + 'raw_temperature': array(22), + 'temperature_config': }, + ...], + 'temperatures': array([...]), + 'vibration_details': [{'deflection_channel_config': , + 'processed_vibration': ..., + 'raw_vibration': array([...], dtype=uint16), + 'vibration_config': }, + ...], + 'vibrations': array([...])} + Close the Comedi device. >>> d.close() @@ -275,8 +395,7 @@ def calib(afm, calibration_config, filename=None, group='/'): 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, -- 2.26.2