Oops, use numpy arrays instead of lists for the last commit.
[calibcant.git] / calibcant / analyze.py
index 4fe5d72dcfe070aa95c364acef8a630dd82c41e3..1033dcc3b692865f9b87f56d7018fad882dc7ad5 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/>.
 
 """Calculate `k` from arrays of bumps, temperatures, and vibrations.
 
@@ -397,6 +395,15 @@ def calib_analyze_all(filename, group='/', maximum_relative_error=1e-5,
     assert group.endswith('/'), group
     bumps,temperatures,vibrations,calibration_config,k,k_s = calib_load(
         filename, group+'calibration/')
+    if bumps is None:
+        bumps = _numpy.zeros(
+            (calibration_config['num-bumps'],), dtype=float)
+    if temperatures is None:
+        temperatures = _numpy.zeros(
+            (calibration_config['num-temperatures'],), dtype=float)
+    if vibrations is None:
+        vibrations = _numpy.zeros(
+            (calibration_config['num-vibrations'],), dtype=float)
     changed_bump = changed_temperature = changed_vibration = False
     for i in range(calibration_config['num-bumps']):
         bump_group = '%sbump/%d/' % (group, i)