Commits

Georg Brandl committed 665c737

data: quick fixes

Comments (0)

Files changed (6)

ufit/data/dataset.py

             else:
                 self.yaxis += ' / %s' % ncol
         else:
-            self.norm = ones(len(self.y_raw))
+            self.norm_raw = self.norm = ones(len(self.y_raw))
 
         self.y = self.y_raw / self.norm
         self.dy = self.dy_raw / self.norm

ufit/data/loader.py

 from ufit.data.dataset import Dataset, DataList
 
 
-# XXX standardize column names (or select a few to standardize)
-
-
 class Loader(object):
     def __init__(self):
         self.format = 'auto'
             meta['filenumber'] = n
         if 'filedesc' not in meta:
             meta['filedesc'] = str(n)
+        if 'environment' not in meta:
+            meta['environment'] = []
         meta['datafilename'] = filename
         datarr = ones((len(coldata), 4))
         datarr[:,0] = coldata[:,colnames.index(xcol)]

ufit/data/simple.py

         colnames = dtline.split()
     else:
         fp.seek(0, 0)
+        colnames = None
     arr = loadtxt(fp, ndmin=2)
+    if colnames is None:
+        colnames = ['Column %d' % i for i in range(1, arr.shape[1]+1)]
     return colnames, arr, {}

ufit/gui/dataloader.py

         self.xcol.clear()
         self.ycol.clear()
         self.moncol.clear()
+        self.moncol.addItem('(none)')
+        self.moncol.setCurrentIndex(0)
         for i, name in enumerate(cols):
             self.xcol.addItem(name)
             self.ycol.addItem(name)
             if name == yguess:
                 self.ycol.setCurrentIndex(i)
             if name == mguess:
-                self.moncol.setCurrentIndex(i)
-        self.monscale.setText(str(nmon))
+                self.moncol.setCurrentIndex(i+1)
+        self.monscale.setText(str(nmon or 1))
         self.numors.setText(str(numor))
         self.open_data()
 
         xcol = str(self.xcol.currentText())
         ycol = str(self.ycol.currentText())
         mcol = str(self.moncol.currentText())
+        if mcol == '(none)':
+            mcol = None
         try:
             mscale = int(self.monscale.text())
         except Exception:

ufit/gui/dataops.py

     @qtsig('')
     def on_rebinBtn_clicked(self):
         binsize = self.precision.value()
-        new_array = rebin(self.data.x, self.data.y_raw, self.data.norm_raw,
-                          binsize)
-        self.data.__init__([self.data.xcol, self.data.ycol, self.data.ncol],
-                           new_array, self.data.meta,
+        new_array = rebin(self.data._data, binsize)
+        self.data.__init__(self.data.meta, new_array,
                            self.data.xcol, self.data.ycol, self.data.ncol,
                            self.data.nscale, name=self.data.name,
                            sources=self.data.sources)
-        self.emit(SIGNAL('replotRequest'))
+        self.emit(SIGNAL('replotRequest'), None)
 
     @qtsig('')
     def on_mulBtn_clicked(self):
             return
         self.data.y += const
         self.data.y_raw += const * self.data.norm
-        # XXX how to treat dy?
         self.emit(SIGNAL('replotRequest'), None)
 
     @qtsig('')
         self.canvas = MPLCanvas(self)
         self.canvas.mpl_connect('button_press_event', self.on_canvas_pick)
         self.canvas.mpl_connect('pick_event', self.on_canvas_pick)
-        # XXX can one add to the MPL toolbar?
         self.toolbar = MPLToolbar(self.canvas, self)
         layout2.addWidget(self.toolbar)
         layout2.addWidget(self.canvas)