Index: src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
===================================================================
--- src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py	(revision 2b538cdefcdc3d89de8c018fe7f225f875614c5a)
+++ src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py	(revision 2b538cdefcdc3d89de8c018fe7f225f875614c5a)
@@ -9,15 +9,11 @@
 import sys
 
-from ..data_info import plottable_1D, plottable_2D,\
+from sas.sascalc.dataloader.data_info import plottable_1D, plottable_2D,\
     Data1D, Data2D, DataInfo, Process, Aperture, Collimation, \
     TransmissionSpectrum, Detector
-from ..data_info import combine_data_info_with_plottable
-from ..loader_exceptions import FileContentsException, DefaultReaderException
-from ..file_reader_base_class import FileReader, decode
-
-def h5attr(node, key, default=None):
-    return decode(node.attrs.get(key, default))
-
-class Reader(FileReader):
+from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable
+
+
+class Reader():
     """
     A class for reading in CanSAS v2.0 data files. The existing iteration opens
@@ -29,5 +25,4 @@
     Any number of SASdata sets may be present in a SASentry and the data within
     can be either 1D I(Q) or 2D I(Qx, Qy).
-
     Also supports reading NXcanSAS formatted HDF5 files
 
@@ -44,4 +39,8 @@
     # Raw file contents to be processed
     raw_data = None
+    # Data info currently being read in
+    current_datainfo = None
+    # SASdata set currently being read in
+    current_dataset = None
     # List of plottable1D objects that should be linked to the current_datainfo
     data1d = None
@@ -56,6 +55,8 @@
     # Flag to bypass extension check
     allow_all = True
-
-    def get_file_contents(self):
+    # List of files to return
+    output = None
+
+    def read(self, filename):
         """
         This is the general read method that all SasView data_loaders must have.
@@ -66,8 +67,4 @@
         # Reinitialize when loading a new data file to reset all class variables
         self.reset_class_variables()
-
-        filename = self.f_open.name
-        self.f_open.close() # IO handled by h5py
-
         # Check that the file exists
         if os.path.isfile(filename):
@@ -77,27 +74,13 @@
             if extension in self.ext or self.allow_all:
                 # Load the data file
-                try:
-                    self.raw_data = h5py.File(filename, 'r')
-                except Exception as e:
-                    if extension not in self.ext:
-                        msg = "CanSAS2.0 HDF5 Reader could not load file {}".format(basename + extension)
-                        raise DefaultReaderException(msg)
-                    raise FileContentsException(e.message)
-                try:
-                    # Read in all child elements of top level SASroot
-                    self.read_children(self.raw_data, [])
-                    # Add the last data set to the list of outputs
-                    self.add_data_set()
-                except Exception as exc:
-                    raise FileContentsException(exc.message)
-                finally:
-                    # Close the data file
-                    self.raw_data.close()
-
-                for dataset in self.output:
-                    if isinstance(dataset, Data1D):
-                        if dataset.x.size < 5:
-                            self.output = []
-                            raise FileContentsException("Fewer than 5 data points found.")
+                self.raw_data = h5py.File(filename, 'r')
+                # Read in all child elements of top level SASroot
+                self.read_children(self.raw_data, [])
+                # Add the last data set to the list of outputs
+                self.add_data_set()
+                # Close the data file
+                self.raw_data.close()
+        # Return data set(s)
+        return self.output
 
     def reset_class_variables(self):
@@ -132,7 +115,8 @@
             # Get all information for the current key
             value = data.get(key)
-            class_name = h5attr(value, u'canSAS_class')
-            if class_name is None:
-                class_name = h5attr(value, u'NX_class')
+            if value.attrs.get(u'canSAS_class') is not None:
+                class_name = value.attrs.get(u'canSAS_class')
+            else:
+                class_name = value.attrs.get(u'NX_class')
             if class_name is not None:
                 class_prog = re.compile(class_name)
@@ -141,5 +125,4 @@
 
             if isinstance(value, h5py.Group):
-                # Set parent class before recursion
                 self.parent_class = class_name
                 parent_list.append(key)
@@ -152,6 +135,4 @@
                 # Recursion step to access data within the group
                 self.read_children(value, parent_list)
-                # Reset parent class when returning from recursive method
-                self.parent_class = class_name
                 self.add_intermediate()
                 parent_list.remove(key)
@@ -184,13 +165,4 @@
                         self.current_dataset.x = data_set.flatten()
                     continue
-                elif key == u'Qdev':
-                    self.current_dataset.dx = data_set.flatten()
-                    continue
-                elif key == u'dQw':
-                    self.current_dataset.dxw = data_set.flatten()
-                    continue
-                elif key == u'dQl':
-                    self.current_dataset.dxl = data_set.flatten()
-                    continue
                 elif key == u'Qy':
                     self.current_dataset.yaxis("Q_y", unit)
@@ -226,9 +198,4 @@
 
                 for data_point in data_set:
-                    if isinstance(data_point, np.ndarray):
-                        if data_point.dtype.char == 'S':
-                            data_point = decode(bytes(data_point))
-                    else:
-                        data_point = decode(data_point)
                     # Top Level Meta Data
                     if key == u'definition':
@@ -236,10 +203,4 @@
                     elif key == u'run':
                         self.current_datainfo.run.append(data_point)
-                        try:
-                            run_name = h5attr(value, 'name')
-                            run_dict = {data_point: run_name}
-                            self.current_datainfo.run_name = run_dict
-                        except Exception:
-                            pass
                     elif key == u'title':
                         self.current_datainfo.title = data_point
@@ -450,4 +411,5 @@
         Data1D and Data2D objects
         """
+
         # Type cast data arrays to float64
         if len(self.current_datainfo.trans_spectrum) > 0:
@@ -473,4 +435,20 @@
         # Type cast data arrays to float64 and find min/max as appropriate
         for dataset in self.data2d:
+            dataset.data = dataset.data.astype(np.float64)
+            dataset.err_data = dataset.err_data.astype(np.float64)
+            if dataset.qx_data is not None:
+                dataset.xmin = np.min(dataset.qx_data)
+                dataset.xmax = np.max(dataset.qx_data)
+                dataset.qx_data = dataset.qx_data.astype(np.float64)
+            if dataset.dqx_data is not None:
+                dataset.dqx_data = dataset.dqx_data.astype(np.float64)
+            if dataset.qy_data is not None:
+                dataset.ymin = np.min(dataset.qy_data)
+                dataset.ymax = np.max(dataset.qy_data)
+                dataset.qy_data = dataset.qy_data.astype(np.float64)
+            if dataset.dqy_data is not None:
+                dataset.dqy_data = dataset.dqy_data.astype(np.float64)
+            if dataset.q_data is not None:
+                dataset.q_data = dataset.q_data.astype(np.float64)
             zeros = np.ones(dataset.data.size, dtype=bool)
             try:
@@ -495,10 +473,29 @@
                 dataset.x_bins = dataset.qx_data[:n_cols]
                 dataset.data = dataset.data.flatten()
-            self.current_dataset = dataset
-            self.send_to_output()
+
+            final_dataset = combine_data_info_with_plottable(
+                dataset, self.current_datainfo)
+            self.output.append(final_dataset)
 
         for dataset in self.data1d:
-            self.current_dataset = dataset
-            self.send_to_output()
+            if dataset.x is not None:
+                dataset.x = dataset.x.astype(np.float64)
+                dataset.xmin = np.min(dataset.x)
+                dataset.xmax = np.max(dataset.x)
+            if dataset.y is not None:
+                dataset.y = dataset.y.astype(np.float64)
+                dataset.ymin = np.min(dataset.y)
+                dataset.ymax = np.max(dataset.y)
+            if dataset.dx is not None:
+                dataset.dx = dataset.dx.astype(np.float64)
+            if dataset.dxl is not None:
+                dataset.dxl = dataset.dxl.astype(np.float64)
+            if dataset.dxw is not None:
+                dataset.dxw = dataset.dxw.astype(np.float64)
+            if dataset.dy is not None:
+                dataset.dy = dataset.dy.astype(np.float64)
+            final_dataset = combine_data_info_with_plottable(
+                dataset, self.current_datainfo)
+            self.output.append(final_dataset)
 
     def add_data_set(self, key=""):
@@ -582,7 +579,7 @@
         :return: unit for the value passed to the method
         """
-        unit = h5attr(value, u'units')
+        unit = value.attrs.get(u'units')
         if unit is None:
-            unit = h5attr(value, u'unit')
+            unit = value.attrs.get(u'unit')
         # Convert the unit formats
         if unit == "1/A":
