Run update-copyright.py.
[calibcant.git] / calibcant / T_analyze.py
index be9852131e8501e14fc691f8257591b7667f3128..3635e2d52c362e4be10aa7cb98d202b177862b8d 100644 (file)
@@ -1,22 +1,20 @@
 # 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.
 
@@ -30,14 +28,14 @@ The relevant physical quantities are:
 >>> import os
 >>> import tempfile
 >>> import numpy
->>> from .config import HDF5_TemperatureConfig
->>> from pypiezo.config 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)
@@ -49,8 +47,8 @@ The relevant physical quantities are:
 /
   /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">
@@ -84,13 +82,14 @@ except (ImportError, RuntimeError), e:
     _matplotlib = None
     _matplotlib_import_error = e
 
-from pypiezo.config 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 base_config as _base_config
+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):
@@ -114,9 +113,10 @@ def T_save(filename, group='/', raw_T=None, temperature_config=None,
             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']
@@ -132,8 +132,8 @@ def T_load(filename, group='/'):
             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:
@@ -163,4 +163,5 @@ def T_plot(raw_T=None, processed_T=None):
     if axes2:
         axes2.set_title('Processed Temperatures %s' % timestamp)
         axes2.plot(processed_T, label='processed')
-    figure.show()
+    if hasattr(figure, 'show'):
+        figure.show()