# calibcant - tools for thermally calibrating AFM cantilevers
#
-# Copyright (C) 2008-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2008-2012 W. Trevor King <wking@drexel.edu>
#
# This file is part of calibcant.
#
-# calibcant is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
+# calibcant is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
#
-# calibcant is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
+# calibcant is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU Lesser General Public
-# License along with calibcant. If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License along with
+# calibcant. If not, see <http://www.gnu.org/licenses/>.
"""Temperature analysis.
>>> import os
>>> import tempfile
>>> import numpy
->>> from .config import HDF5_TemperatureConfig
->>> from h5config.hdf5 import pprint_HDF5
+>>> from .config import TemperatureConfig
+>>> from h5config.storage.hdf5 import pprint_HDF5, HDF5_Storage
>>> fd,filename = tempfile.mkstemp(suffix='.h5', prefix='calibcant-')
>>> os.close(fd)
->>> temperature_config = HDF5_TemperatureConfig(
-... filename=filename, group='/T/config/')
+>>> temperature_config = TemperatureConfig(storage=HDF5_Storage(
+... filename=filename, group='/T/config/'))
>>> raw_T = numpy.array([22, 23.5, 24])
>>> processed_T = T_analyze(raw_T, temperature_config)
/
/T
/T/config
- <HDF5 dataset "default": shape (), type "|S3">
- yes
+ <HDF5 dataset "default": shape (), type "|b1">
+ True
<HDF5 dataset "units": shape (), type "|S7">
Celsius
<HDF5 dataset "processed": shape (3,), type "<f8">
_matplotlib = None
_matplotlib_import_error = e
-from h5config.hdf5 import h5_create_group as _h5_create_group
+from h5config.storage.hdf5 import HDF5_Storage as _HDF5_Storage
+from h5config.storage.hdf5 import h5_create_group as _h5_create_group
from . import LOG as _LOG
from . import package_config as _package_config
from .config import Celsius as _Celsius
from .config import Kelvin as _Kelvin
-from .config import HDF5_TemperatureConfig as _HDF5_TemperatureConfig
+from .config import TemperatureConfig as _TemperatureConfig
def T_analyze(T, temperature_config):
except KeyError:
pass
cwg['raw'] = raw_T
- if temperature_config:
+ if temperature_config is not None:
config_cwg = _h5_create_group(cwg, 'config')
- temperature_config.save(group=config_cwg)
+ storage = _HDF5_Storage()
+ storage.save(config=temperature_config, group=config_cwg)
if processed_T is not None:
try:
del cwg['processed']
raw_T = f[group+'raw'][...]
except KeyError:
pass
- temperature_config = _HDF5_TemperatureConfig(
- filename=filename, group=group+'config/')
+ temperature_config = _TemperatureConfig(storage=_HDF5_Storage(
+ filename=filename, group=group+'config/'))
try:
processed_T = f[group+'processed'][...]
except KeyError:
if axes2:
axes2.set_title('Processed Temperatures %s' % timestamp)
axes2.plot(processed_T, label='processed')
- figure.show()
+ if hasattr(figure, 'show'):
+ figure.show()