Commit c6b3697a authored by 3Yan's avatar 3Yan Committed by Yan
Browse files

Parameters change support - pt4

* zce fixed
* reformulated time subselection routine - improved readability
parent f937738c
......@@ -108,39 +108,33 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
mpl_chromatogram.clear()
for i,subset in enumerate(ds):
selection = chrom_data['timesarg'][i]
if cf.settings().value("view/oddeven", type=bool):
for j in range(2):
chromx = subset['chrom_dat'][0, :][j::2]
chromy = subset['chrom_dat'][1, :][j::2]
pop_plot(chromx, chromy, mpl_chromatogram, chrom_data,
colornum=i*2+j)
if not np.array_equal(chrom_data['timesarg'][i][j::2], []):
if not chrom_data['timesarg'][i][0] % 2 == 0:
k=1-j
else:
k=j
if not np.array_equal(selection[j::2], []):
clr = i*2+j if selection[0] % 2 == 0\
else i*2+(1-j)
ms_x = subset['masses']
ms_y = np.mean(subset['matrix'][
chrom_data['timesarg'][i][j::2]],
axis=0)
pop_plot(ms_x, ms_y, mpl_spectrum, ms_data, colornum=i*2+k)
dots_x = subset['chrom_dat'][
0, chrom_data['timesarg'][i][j::2]]
dots_y = subset['chrom_dat'][
1, chrom_data['timesarg'][i][j::2]]
ms_y = np.mean(subset['matrix'][selection[j::2]], axis=0)
pop_plot(ms_x, ms_y, mpl_spectrum, ms_data, colornum=clr)
dots_x = subset['chrom_dat'][0, selection[j::2]]
dots_y = subset['chrom_dat'][1, selection[j::2]]
mpl_chromatogram.plot(dots_x, dots_y, '.', color=(
colors[(i*2+k) % len(colors)]/255))
colors[(clr) % len(colors)]/255))
else:
chromx = subset['chrom_dat'][0, :]
chromy = subset['chrom_dat'][1, :]
pop_plot(chromx, chromy, mpl_chromatogram, chrom_data, colornum=i)
if not np.array_equal(chrom_data['timesarg'][i], []):
if not np.array_equal(selection, []):
ms_x = subset['masses']
ms_y = np.mean(subset['matrix'][chrom_data['timesarg'][i]],
axis=0)
ms_y = np.mean(subset['matrix'][selection], axis=0)
pop_plot(ms_x, ms_y, mpl_spectrum, ms_data, colornum=i)
dots_x = subset['chrom_dat'][0, chrom_data['timesarg'][i]]
dots_y = subset['chrom_dat'][1, chrom_data['timesarg'][i]]
dots_x = subset['chrom_dat'][0, selection]
dots_y = subset['chrom_dat'][1, selection]
mpl_chromatogram.plot(dots_x, dots_y, '.', color=(
colors[i % len(colors)]/255))
......
......@@ -25,31 +25,31 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
zcespec.clear()
gradspect.clear()
coff_d['x'] = data_set['masses'] - 196
coff_d['y'] = np.mean(data_set['matrix'], axis=0)
grad_d['x'] = coff_d['x']
halfl = int(len(grad_d['x'])/2)
grad_d['y'] = -np.gradient(coff_d['y'])\
if np.sum(coff_d['y'][:halfl]) > np.sum(coff_d['y'][halfl:])\
else np.gradient(coff_d['y'])
coff_x = data_set[0]['masses'] - 196
coff_y = np.mean(data_set[0]['matrix'], axis=0)
grad_x = coff_x
halfl = int(len(grad_x)/2)
grad_y = -np.gradient(coff_y)\
if np.sum(coff_y[:halfl]) > np.sum(coff_y[halfl:])\
else np.gradient(coff_y)
gradspect.axhline(0, color="#FF000088", linestyle=":")
zcespec.axhline(0, color="#0000FF88", linestyle=":")
gt.pop_plot(zcespec, coff_d)
gt.pop_plot(gradspect, grad_d)
gt.pop_plot(coff_x, coff_y, zcespec, coff_d)
gt.pop_plot(grad_x, grad_y, gradspect, grad_d)
gradspect.lines[-1].set_color("red")
gradspect.set_ylim(bottom=gradspect.get_ylim()[1] * -0.1)
zcespec.set_title("COFF", loc="center")
maxarg = np.argmax(grad_d['y'])
grad_d['gmax'] = coff_d['x'][maxarg]
halfmax = np.max(grad_d['y']) / 2
peakargs = np.where(grad_d['y'] > halfmax)[0]
maxarg = np.argmax(grad_y)
grad_d['gmax'] = coff_x[maxarg]
halfmax = np.max(grad_y) / 2
peakargs = np.where(grad_y > halfmax)[0]
start = [peakargs[0]-1, peakargs[0]]
end = [peakargs[-1]+1, peakargs[-1]]
grad_d['fwhm_y'] = [halfmax, halfmax]
grad_d['fwhm_x'] = [
np.interp(halfmax, grad_d['y'][start], grad_d['x'][start]),
np.interp(halfmax, grad_d['y'][end], grad_d['x'][end])]
np.interp(halfmax, grad_y[start], grad_x[start]),
np.interp(halfmax, grad_y[end], grad_x[end])]
grad_d['fwhm'] = grad_d['fwhm_x'][1] - grad_d['fwhm_x'][0]
gradspect.plot(grad_d['fwhm_x'], grad_d['fwhm_y'], "#880088")
......@@ -60,7 +60,7 @@ def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
gradspect.annotate(' FWHM = {:.2f}'.format(grad_d['fwhm']),
xy=(grad_d['fwhm_x'][1], grad_d['fwhm_y'][1]))
gradspect.annotate('{:.2f}'.format(grad_d['gmax']),
xy=(grad_d['x'][maxarg], grad_d['y'][maxarg]))
xy=(grad_x[maxarg], grad_y[maxarg]))
zcespec.figure.canvas.draw()
......@@ -120,11 +120,10 @@ def print_graph(ds, coff, coffgrad, filename):
def dialog(parent, ds, filename, update_signal):
coff = dict(x=[0], y=[0], name="",
xlabel="Voltage (V)", ylabel="ion count")
coffgrad = dict(x=[0], y=[0], c_ymin=-0.1, name="",
xlabel="", ylabel="ion count gradient", gmax=None,
fwhm_x=None, fwhm_y=None, fwhm=None)
coff = dict(name="", xlabel="Voltage (V)", ylabel="ion count")
coffgrad = dict(c_ymin=-0.1, name="", xlabel="",
ylabel="ion count gradient", gmax=None, fwhm_x=None,
fwhm_y=None, fwhm=None)
def onclose(widget, event, update_fnc):
logger.debug("ZCE window custom close routine called")
......
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