def onCalibrate(self, event=None): x, y = [], [] mca = self.mca # save old calib old_calib = mca.offset, mca.slope init_calib = copy.deepcopy(mca.init_calib) for roiname, eknown, ecen, w_ncen, w_ndif, w_nwid, w_use in self.wids: if not w_use.IsChecked(): mca.init_calib.pop(roiname) xrf_calib_compute(mca, apply=True, _larch=self.larch) offset, slope = mca.new_calib self.calib_updated = True self.new_offset.SetValue("% .3f" % (1000 * offset)) self.new_slope.SetValue("% .3f" % (1000 * slope)) # find ROI peak positions using this new calibration xrf_calib_fitrois(mca, _larch=self.larch) for roi in self.mca.rois: eknown, ecen, fwhm, amp, fit = mca.init_calib[roi.name] diff = ecen - eknown for roiname, eknown, ocen, w_ncen, w_ndif, w_nwid, w_use in self.wids: if roiname == roi.name: w_ncen.SetLabel("%.1f" % (1000 * ecen)) w_ndif.SetLabel("% .1f" % (1000 * diff)) w_nwid.SetLabel("%.1f" % (1000 * fwhm)) break # restore calibration to old values until new values are accepted xrf_calib_apply(mca, offset=old_calib[0], slope=old_calib[1], _larch=self.larch) mca.init_calib = init_calib tsize = self.GetSize() self.SetSize((tsize[0] + 1, tsize[1])) self.SetSize((tsize[0], tsize[1]))
def onUseCalib(self, event=None): mca = self.mca offset = float(self.new_offset.GetValue()) slope = float(self.new_slope.GetValue()) mca.new_calib = offset, slope xrf_calib_apply(mca, offset=offset, slope=slope, _larch=self.larch) if hasattr(self.callback, "__call__"): self.callback(offset, slope, mca=mca) self.Destroy()
def onUseCalib(self, event=None): mca = self.mca offset = float(self.new_offset.GetValue()) slope = float(self.new_slope.GetValue()) mca.new_calib = offset, slope xrf_calib_apply(mca, offset=offset, slope=slope, _larch=self.larch) if hasattr(self.callback, '__call__'): self.callback(offset, slope, mca=mca) self.Destroy()
def onUseCalib(self, event=None): mca = self.mca offset = 0.001*float(self.new_offset.GetValue()) slope = 0.001*float(self.new_slope.GetValue()) mca.new_calib = offset, slope xrf_calib_apply(mca, offset=offset, slope=slope, _larch=self.larch) if callable(self.callback): self.callback(mca) self.Destroy()
def onCalibrate(self, event=None): x, y = [], [] mca = self.mca # save old calib old_calib = mca.offset, mca.slope init_calib = copy.deepcopy(mca.init_calib) for roiname, eknown, ecen, w_ncen, w_ndif, w_nwid, w_use in self.wids: if not w_use.IsChecked(): mca.init_calib.pop(roiname) xrf_calib_compute(mca, apply=True, _larch=self.larch) offset, slope = mca.new_calib self.calib_updated = True self.new_offset.SetValue("% .3f" % (1000 * offset)) self.new_slope.SetValue("% .3f" % (1000 * slope)) # find ROI peak positions using this new calibration xrf_calib_fitrois(mca, _larch=self.larch) for roi in self.mca.rois: try: eknown, ecen, fwhm, amp, fit = mca.init_calib[roi.name] except: continue diff = ecen - eknown for roiname, eknown, ocen, w_ncen, w_ndif, w_nwid, w_use in self.wids: if roiname == roi.name: w_ncen.SetLabel("%.1f" % (1000 * ecen)) w_ndif.SetLabel("% .1f" % (1000 * diff)) w_nwid.SetLabel("%.1f" % (1000 * fwhm)) break # restore calibration to old values until new values are accepted xrf_calib_apply(mca, offset=old_calib[0], slope=old_calib[1], _larch=self.larch) mca.init_calib = init_calib tsize = self.GetSize() self.SetSize((tsize[0] + 1, tsize[1])) self.SetSize((tsize[0], tsize[1]))