Commit ad6b4461 authored by Yan's avatar Yan
Browse files

zooming the Y axis with shift+scroll action.

parent 45a507cd
## Prasopes
Prasopes is a free and open source Thermo/Finnigan .RAW spectra viewer. It is an implementation example of rawFin library. Its limitation of the supported format range is limited by the current developemnt state of this library.
Prasopes is a free and open source Thermo/Finnigan .RAW spectra viewer. It is an implementation example of the rawFin library. Its limitation in means of the supported format scope is defined by the current developemnt state of the rawFin library.
## Usage
If running from cmdline, the first argument is taken as a spectrum file. Otherwise use File -> Open or Ctrl+O to open a spectrum.
......@@ -17,37 +17,28 @@ matplotlib.use("Qt5Agg")
def zoom_factory(ax, base_scale, das=None):
def zoom_fun(event, das):
if event.inaxes == ax:
# get the current x and y limits
cur_xlim = ax.get_xlim()
# cur_ylim = ax.get_ylim()
# set the range
# cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5
# cur_yrange = (cur_ylim[1] - cur_ylim[0])*.5
xdata = event.xdata # get event x location
# ydata = event.ydata # get event y location
# generate better understanding of our position
x_left = xdata - cur_xlim[0]
x_right = cur_xlim[1] - xdata
# y_top = ydata - cur_ylim[0]
# y_bottom = cur_ylim[1] - ydata
if event.button == 'up':
# deal with zoom in
#zoom in
scale_factor = 1/base_scale
elif event.button == 'down':
# deal with zoom out
#zoom out
scale_factor = base_scale
else:
# deal with something that should never happen
#should not happen
scale_factor = 1
print(event.button)
# set new limits
ax.set_xlim([xdata - x_left*scale_factor,
xdata + x_right*scale_factor])
# ax.set_ylim([ydata - y_top*scale_factor,
# ydata + y_bottom*scale_factor])
ax.figure.canvas.draw() # force re-draw
if das != None:
print("TODO_NOT READY YET")
if event.key == 'shift':
data = event.ydata
newtop = data + (ax.get_ylim()[1] - data)*scale_factor
ax.set_ylim([newtop*-0.01,newtop])
else:
data = event.xdata
xleft = data - ax.get_xlim()[0]
xright = ax.get_xlim()[1] - data
ax.set_xlim([data - xleft*scale_factor,
data + xright*scale_factor])
ax.figure.canvas.draw()
fig = ax.get_figure() # get the figure of interest
# attach the call back
......@@ -130,12 +121,13 @@ def spectrPlot(spetrum,mass,intensity, an):
spectrum.set_title("Spectrum:", loc = "right")
spectrum.set_xlabel("m/z")
spectrum.set_ylabel("ion count")
spectrum.set_ylim(spectrum.get_ylim()[1]*-0.01,)
spectrum.ticklabel_format(scilimits=(0,0),axis='y')
annSpectr(spectrum, mass, intensity, an)
def chromPlot(chromatogram,times,tic):
chromatogram.plot(times,tic)
chromatogram.set_ylim(bottom=0,top=chromatogram.get_ylim()[1]*1.1)
chromatogram.set_ylim(chromatogram.get_ylim()[1]*-0.011,chromatogram.get_ylim()[1]*1.1)
chromatogram.set_title("Chromatogram:", loc = "right")
chromatogram.set_xlabel("time (min)")
chromatogram.set_ylabel("total ion count")
......@@ -167,6 +159,7 @@ if __name__=="__main__":
mpl_canvas = FigureCanvas(graph)
mpl_canvas.setStyleSheet("background-color:transparent;")
mpl_canvas.setAutoFillBackground(False)
mpl_canvas.setFocusPolicy( QtCore.Qt.ClickFocus )
timeSelector=[None]
annotation=[]
......@@ -189,13 +182,15 @@ if __name__=="__main__":
layout = QtWidgets.QVBoxLayout(main_widget)
layout.addWidget(mpl_canvas)
mpl_canvas.setFocus()
try:
rawfile=sys.argv[1]
ds['chromdat'],ds['masses'],ds['matrix'] = load_raw(rawfile)
populate(chromatogram, spectrum, ds, timeSelector,annotation)
except:
None
spectrPlot(spectrum, [0], [0], annotation)
chromPlot(chromatogram, [0], [0])
main_window.show()
sys.exit(app.exec_())
......
Supports Markdown
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