Ejemplo n.º 1
0
    def on_subtractBtn_clicked(self):
        from ufit.gui.scanitem import ScanDataItem
        dlg = QDialog(self)
        loadUi(dlg, 'subtract.ui')
        data2obj = dlg.setList.populate(ScanDataItem)
        if dlg.exec_() != QDialog.Accepted:
            return
        witems = dlg.setList.selectedItems()
        if not witems:
            return
        try:
            prec = float(dlg.precisionEdit.text())
        except ValueError:
            QMessageBox.warning(self, 'Error',
                                'Please enter a valid precision.')
            return

        new_data = self.data.subtract(data2obj[witems[0].type()].data, prec,
                                      dlg.destructBox.isChecked())

        if not dlg.destructBox.isChecked():
            new_model = self.model.copy()
            from ufit.gui.scanitem import ScanDataItem
            session.add_item(ScanDataItem(new_data, new_model),
                             self.item.group)
        else:
            self.replotRequest.emit(None)
            session.set_dirty()
Ejemplo n.º 2
0
    def on_fftBtn_clicked(self):
        try:
            npoints = int(self.fftNpointsEdit.text())
        except ValueError:
            QMessageBox.warning(self, 'Error',
                                'Please enter a valid number of points.')
            return
        xmin = self.data.x.min()
        xmax = self.data.x.max()
        xinterp = linspace(xmin, xmax, npoints)
        yinterp = interp1d(self.data.x, self.data.y, kind='linear')
        yfft = fft(yinterp(xinterp))
        p2 = abs(yfft) / npoints
        p1 = p2[:npoints // 2 + 2]
        p1[1:-1] *= 2
        dx = (xmax - xmin) / (npoints - 1)

        new_data = ScanData.from_arrays(name='FFT(' + self.data.name + ')',
                                        x=(1. / dx) *
                                        arange(npoints // 2 + 2) / npoints,
                                        y=p1,
                                        dy=0.01 * ones(p1.shape),
                                        xcol='1/' + self.data.xaxis,
                                        ycol='|P1|')
        new_model = self.model.copy()
        from ufit.gui.scanitem import ScanDataItem
        session.add_item(ScanDataItem(new_data, new_model), self.item.group)
Ejemplo n.º 3
0
 def on_integrateBtn_clicked(self):
     xname = self.xparamBox.currentText()
     if xname == 'image #':
         xdata = arange(1, len(self.datas) + 1)
     else:
         xdata = array([data.meta[xname] for data in self.datas])
     boxnorm = self.boxNormBox.isChecked()
     for box in self.boxes:
         x1, y1, x2, y2 = box.x1Box.value(), box.y1Box.value(), \
             box.x2Box.value(), box.y2Box.value()
         name = box.nameBox.text()
         ydata = array(
             [data.arr[x1:x2, y1:y2].sum() for data in self.datas])
         dydata = array([
             sqrt((data.darr[x1:x2, y1:y2]**2).sum()) for data in self.datas
         ])
         yname = 'box counts'
         if boxnorm:
             factor = 1. / ((y2 - y1) * (x2 - x1))
             ydata *= factor
             dydata *= factor
             yname = 'box counts (norm)'
         scan = ScanData.from_arrays(name,
                                     xdata,
                                     ydata,
                                     dydata,
                                     xcol=xname,
                                     ycol=yname)
         session.add_item(ScanDataItem(scan))
Ejemplo n.º 4
0
 def on_mergeBtn_clicked(self):
     try:
         precision = float(self.mergeEdit.text())
     except ValueError:
         QMessageBox.warning(self, 'Error', 'Enter a valid precision.')
         return
     new_data = self.datas[0].merge(precision, *self.datas[1:])
     session.add_item(ScanDataItem(new_data), self.items[-1].group)
Ejemplo n.º 5
0
 def insert_session(self, filename):
     temp_session.load(filename)
     basename = path.basename(filename)
     if basename.endswith('.ufit'):
         basename = basename[:-5]
     # XXX slight HACK
     for group in temp_session.groups:
         session.add_group(group.name + ' (from %s)' % basename)
         for item in group.items:
             session.add_item(item)
Ejemplo n.º 6
0
 def on_actionMergeData_triggered(self):
     items = self.selected_items(ScanDataItem)
     if len(items) < 2:
         return
     dlg = QDialog(self)
     loadUi(dlg, 'rebin.ui')
     if dlg.exec_():
         try:
             precision = float(dlg.precisionEdit.text())
         except ValueError:
             return
         datalist = [i.data for i in items]
         new_data = datalist[0].merge(precision, *datalist[1:])
         session.add_item(ScanDataItem(new_data), self.items[-1].group)
Ejemplo n.º 7
0
 def on_cloneBtn_clicked(self):
     new_data = self.data.copy()
     new_model = self.model.copy()
     from ufit.gui.scanitem import ScanDataItem
     session.add_item(ScanDataItem(new_data, new_model), self.item.group)
Ejemplo n.º 8
0
 def on_mappingBtn_clicked(self):
     item = MappingItem([item.data for item in self.items], None)
     session.add_item(item, self.items[-1].group)
Ejemplo n.º 9
0
 def on_paramsetBtn_clicked(self):
     dlg = ParamSetDialog(self, self.items)
     if dlg.exec_() != QDialog.Accepted:
         return
     session.add_item(ScanDataItem(dlg.new_data), self.items[-1].group)