Commits

Georg Brandl committed 343d99b

data: implement "merging" with binsize=0 for hkl data

Comments (0)

Files changed (3)

ufit/data/dataset.py

         alldata = concatenate([dset._data for dset in allsets])
         new_array = rebin(alldata, binsize)
         sources = sum((dset.sources for dset in allsets), [])
-        # XXX should we merge meta's?
-        return self.__class__(self.meta, new_array,
-                              self.xcol, self.ycol, self.ncol, self.nscale,
-                              name='_'.join(d.name for d in allsets),
-                              sources=sources)
+        new_meta = self.meta.copy()
+        # XXX hkl data is a mess
+        if 'is_hkldata' in self.meta and binsize == 0:
+            new_meta['hkle'] = concatenate([dset.meta['hkle']
+                                            for dset in allsets])
+            print new_meta['hkle']
+        # XXX should we merge other meta's?
+        ret = self.__class__(new_meta, new_array,
+                             self.xcol, self.ycol, self.ncol, self.nscale,
+                             name='_'.join(d.name for d in allsets),
+                             sources=sources)
+        if 'is_hkldata' in self.meta:
+            ret.x = ret.meta['hkle']
+        return ret
 
     def plot(self, axes=None, symbols=True, lines=False):
         """Plot the dataset using matplotlib.

ufit/data/loader.py

             elif isinstance(col, str):
                 return col
             return colnames[col - 1]   # 1-based indices
+        if use_hkl:
+            meta['is_hkldata'] = True
         dset = Dataset(meta, datarr, colname(xcol), colname(ycol),
                        colname(ncol), nscale)
         if use_hkl and 'hkle' in dset.meta:  # 3-axis support

ufit/data/merge.py

     """Simple rebinning of (x, y, dy, n) data."""
     # XXX make it work with hkle 4-d x data
 
+    if binsize == 0:
+        # no merging, just concatenate
+        return data
+
     x, y, dy, n = data.T
 
     # calculate new x values
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.