Ran update_copyright.py, updating all the copyright blurbs and adding AUTHORS.
[hooke.git] / hooke / curve.py
index 5aeaeaac887f3bc3cc26f0b8ead8a73098deb7ee..816a921a86470f842ee2bda1d7d2131a73722de0 100644 (file)
@@ -1,12 +1,34 @@
-"""The curve module provides :class:`Curve` and :class:`Data` for storing
-force curves.
+# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke 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.
+#
+# Hooke 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.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+"""The `curve` module provides :class:`Curve` and :class:`Data` for
+storing force curves.
 """
 
 import os.path
 import numpy
 
-from .driver import NotRecognized
 
+class NotRecognized (ValueError):
+    def __init__(self, curve):
+        msg = 'Not a recognizable curve format: %s' % curve.path
+        ValueError.__init__(self, msg)
+        self.curve = curve
 
 class Data (numpy.ndarray):
     """Stores a single, continuous data set.
@@ -61,14 +83,15 @@ class Curve (object):
       Hooke commands could like to know if they're looking at force
       clamp data, regardless of their origin.
     """
-    def __init__(self, path):
+    def __init__(self, path, info=None):
         #the data dictionary contains: {name of data: list of data sets [{[x], [y]}]
         self.path = path
         self.driver = None
         self.data = []
-        self.info = None
+        if info == None:
+            info = {}
+        self.info = info
         self.name = os.path.basename(path)
-        self.notes = ''
 
     def identify(self, drivers):
         """Identify the appropriate :class:`hooke.driver.Driver` for
@@ -78,7 +101,7 @@ class Curve (object):
             if driver.is_me(self.path):
                 self.driver = driver # remember the working driver
                 return
-        raise NotRecognized(self.path)
+        raise NotRecognized(self)
 
     def load(self):
         """Use the driver to read the curve into memory.