Commit 56502331 authored by Yan's avatar Yan
Browse files

Annotation in mobility views

* minor fixes and changes too
parent 69c89510
...@@ -348,8 +348,8 @@ def main(): ...@@ -348,8 +348,8 @@ def main():
drlact.triggered.connect(lambda: drlgui.main_window( drlact.triggered.connect(lambda: drlgui.main_window(
main_window, augCanvas, update)) main_window, augCanvas, update))
tofact = QtWidgets.QAction(QtGui.QIcon.fromTheme( tofact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"applications-utilities"), "TO&F...", None) "applications-utilities"), "&MOB...", None)
tofact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_F) tofact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_M)
tofact.triggered.connect(lambda: mt.main_window( tofact.triggered.connect(lambda: mt.main_window(
main_window, augCanvas, update)) main_window, augCanvas, update))
aboutact = QtWidgets.QAction("&About Prasopes", None) aboutact = QtWidgets.QAction("&About Prasopes", None)
......
...@@ -305,7 +305,7 @@ def autozoomy(ms_spec): ...@@ -305,7 +305,7 @@ def autozoomy(ms_spec):
ms_spec.figure.canvas.draw() ms_spec.figure.canvas.draw()
def ann_spec(ms_spec, msdata, ann_limit=0.01): def ann_spec(ms_spec, msdata, ann_limit=0.01, coef_x=15, coef_y=20):
"""annotate spectrum """annotate spectrum
First define the array, in which the annotation should occur. First define the array, in which the annotation should occur.
...@@ -313,7 +313,10 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01): ...@@ -313,7 +313,10 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01):
then reduced to a representation of the important ones by the sub_peaks then reduced to a representation of the important ones by the sub_peaks
function""" function"""
def sub_peaks(peakz, hardpeaks, xrange, yrange, coef_x=15, coef_y=20): cx = msdata['ancx'] if 'ancx' in msdata.keys() else 15
cy = msdata['ancy'] if 'ancy' in msdata.keys() else 20
def sub_peaks(peakz, hardpeaks, xrange, yrange, coef_x=cx, coef_y=cy):
"""Returns reasonable subselection of local maximas""" """Returns reasonable subselection of local maximas"""
hardxy = np.array([i.xy for i in hardpeaks], dtype=[ hardxy = np.array([i.xy for i in hardpeaks], dtype=[
('x', np.float32), ('y', np.float32)]) ('x', np.float32), ('y', np.float32)])
...@@ -351,7 +354,7 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01): ...@@ -351,7 +354,7 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01):
# remove them from tracking # remove them from tracking
msdata['annotation'].clear() msdata['annotation'].clear()
if len(peaks) == 0: if not len(peaks):
return return
peaks = np.concatenate(peaks) peaks = np.concatenate(peaks)
......
...@@ -83,6 +83,7 @@ def pop_dial(augCanvas, dialspect, ionstable, labels): ...@@ -83,6 +83,7 @@ def pop_dial(augCanvas, dialspect, ionstable, labels):
if ionstable.rowCount(): if ionstable.rowCount():
dialspect.autoscale(True) dialspect.autoscale(True)
dialspect.legend(loc=2) dialspect.legend(loc=2)
gt.ann_spec(dialspect, labels)
dialspect.figure.canvas.draw() dialspect.figure.canvas.draw()
return return
...@@ -135,8 +136,8 @@ def export_dial(augCanvas, grph): ...@@ -135,8 +136,8 @@ def export_dial(augCanvas, grph):
exp_f_name = ft.get_save_filename( exp_f_name = ft.get_save_filename(
"Export spectrum", "dat table (*.dat)", "dat", None) "Export spectrum", "dat table (*.dat)", "dat", None)
if exp_f_name != '': if exp_f_name != '':
names = ["time", "intensity"] names = ["1/K_0", "intensity"]
units = ["sec??", ""] units = ["Vs/cm^2", ""]
description = os.path.basename(augCanvas.ds.filename) + " " +\ description = os.path.basename(augCanvas.ds.filename) + " " +\
" -- ".join([line._label for line in grph.get_lines()]) " -- ".join([line._label for line in grph.get_lines()])
expf = open(exp_f_name, 'w') expf = open(exp_f_name, 'w')
...@@ -146,7 +147,8 @@ def export_dial(augCanvas, grph): ...@@ -146,7 +147,8 @@ def export_dial(augCanvas, grph):
def main_window(parent, augCanvas, update_signal): def main_window(parent, augCanvas, update_signal):
reactlabels = dict(name="", xlabel="$1/K_0 (Vs/cm^2)\ \\it→$", reactlabels = dict(name="", xlabel="$1/K_0 (Vs/cm^2)\ \\it→$",
ylabel="$Intensity\ \\it→$") ylabel="$Intensity\ \\it→$", annotation=[], texts=[],
ancx=5, ancy=3)
cache = augCanvas.tofcache cache = augCanvas.tofcache
def onclose(widget, event, ionstable, canvas, cache, update_fnc): def onclose(widget, event, ionstable, canvas, cache, update_fnc):
......
...@@ -80,6 +80,7 @@ def pop_dial(augCanvas, dialspect, ionstable, labels): ...@@ -80,6 +80,7 @@ def pop_dial(augCanvas, dialspect, ionstable, labels):
if ionstable.rowCount(): if ionstable.rowCount():
dialspect.autoscale(True) dialspect.autoscale(True)
dialspect.legend(loc=2) dialspect.legend(loc=2)
gt.ann_spec(dialspect, labels)
dialspect.figure.canvas.draw() dialspect.figure.canvas.draw()
return return
...@@ -143,7 +144,8 @@ def export_dial(augCanvas, grph): ...@@ -143,7 +144,8 @@ def export_dial(augCanvas, grph):
def main_window(parent, augCanvas, update_signal): def main_window(parent, augCanvas, update_signal):
reactlabels = dict(name="", xlabel="$m/z\ \\it→$", reactlabels = dict(name="", xlabel="$m/z\ \\it→$",
ylabel="$Intensity\ \\it→$") ylabel="$Intensity\ \\it→$", annotation=[], texts=[],
ancx=5, ancy=3)
cache = augCanvas.mobontofcache cache = augCanvas.mobontofcache
def onclose(widget, event, ionstable, canvas, cache, update_fnc): def onclose(widget, event, ionstable, canvas, cache, update_fnc):
......
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