Commit a3983aab authored by Yan's avatar Yan
Browse files

Fixed ZCE

parent 720d1973
......@@ -29,8 +29,8 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
zcespec.clear()
gradspect.clear()
coff_x = data_set[0]['masses'] - 196
coff_y = np.mean(data_set[0]['matrix'], axis=0)
masses, coff_y = data_set.get_spectra()[0]
coff_x = masses - 196
grad_x = coff_x
halfl = int(len(grad_x)/2)
grad_y = -np.gradient(coff_y)\
......@@ -68,9 +68,9 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
zcespec.figure.canvas.draw()
def exp_zce(zce_spec, zcegrad_spec, fn, parent):
def exp_zce(zce_spec, zcegrad_spec, data_set, parent):
"""export the ZCE graph into the .dat file format"""
if fn is None:
if data_set is None:
QtWidgets.QMessageBox.warning(
parent, "Export ZCE spectrum",
"Nothing to export, cancelling request")
......@@ -82,8 +82,8 @@ def exp_zce(zce_spec, zcegrad_spec, fn, parent):
expf.write("mass ion_count ion_count_gradient fwhm_x fwhm_y\n"
"m/z\n"
"{} zce={} fwhm={} hmcenter={}\n".format(
os.path.basename(fn), zcegrad_spec['gmax'],
zcegrad_spec['fwhm'],
os.path.basename(data_set.filename),
zcegrad_spec['gmax'], zcegrad_spec['fwhm'],
np.mean(zcegrad_spec['fwhm_x'])))
for i in range(len(zce_spec['x'])):
fwhm = ["", ""]
......@@ -101,13 +101,13 @@ def help_msg(pw):
pw, "TSQ zce tool help", "{}".format(helpstr))
def paint_override(self, ds, coff, coffgrad, filename):
def paint_override(self, ds, coff, coffgrad):
overlay = self.plot.twinx()
textfield = QtWidgets.QLabel()
pop_dial(self.plot, overlay, ds, coff, coffgrad, textfield, filename, None)
pop_dial(self.plot, overlay, ds, coff, coffgrad, textfield, None)
def print_graph(ds, coff, coffgrad, filename):
def print_graph(ds, coff, coffgrad):
def printimage(printdevice, img):
printer.setResolution(600)
painter = QtGui.QPainter(printdevice)
......@@ -119,19 +119,18 @@ def print_graph(ds, coff, coffgrad, filename):
printer.setPageSize(printer.A5)
printer.setDuplex(printer.DuplexNone)
imggen = imgt.ImagePainter("msspec", printer)
imggen.popfig = lambda: paint_override(imggen, ds, coff, coffgrad, filename)
imggen.popfig = lambda: paint_override(imggen, ds, coff, coffgrad)
image = imggen.paint()
printPreview.paintRequested.connect(lambda: printimage(printer, image))
printPreview.exec()
def key_pressed(event, ds, coff, coffgrad, filename):
def key_pressed(event, ds, coff, coffgrad):
print("trigged")
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
painter = imgt.ImagePainter("zcespec")
painter.popfig = lambda: paint_override(
painter, ds, coff, coffgrad, filename)
painter.popfig = lambda: paint_override(painter, ds, coff, coffgrad)
painter.clip()
......@@ -168,7 +167,7 @@ def dialog(parent, augCanvas, update_signal):
zce_export = QtWidgets.QPushButton("Export ZCE")
zce_export.clicked.connect(lambda: exp_zce(
coff, coffgrad, augCanvas.ds.filename, parent))
coff, coffgrad, augCanvas.ds, parent))
zce_print = QtWidgets.QPushButton("Print ZCE")
zce_print.clicked.connect(lambda: print_graph(
augCanvas.ds, coff, coffgrad))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment