Commit 44ccbedb authored by Yan's avatar Yan
Browse files

Simplified pickTimes function in graphtools

parent f4def8f2
......@@ -94,44 +94,25 @@ def pick_times(x_min, x_max, mpl_spectrum, data_set, mpl_chromatogram,
"""plot averaged spectrum of subselected part of the chromatogram"""
chrom_spect['t_start'] = x_min
chrom_spect['t_end'] = x_max
start_scan = None
end_scan = None
for i, time in enumerate(data_set['chrom_dat'][0, :]):
if time > x_min and start_scan is None:
start_scan = i
if time > x_max and end_scan is None:
end_scan = i
if start_scan == end_scan:
if start_scan == 0:
end_scan = 1
elif start_scan is None:
end_scan = len(data_set['chrom_dat'][0, :])
start_scan = end_scan - 1
else:
time = (x_min+x_max)/2
d1 = time - data_set['chrom_dat'][0, start_scan-1]
d2 = data_set['chrom_dat'][0, start_scan] - time
if d1 < d2:
start_scan -= 1
elif d1 > d2:
end_scan += 1
else:
start_scan -= 1
end_scan = start_scan + 2
times = data_set['chrom_dat'][0, :]
timesarg = np.where((times >= x_min) & (times <= x_max))[0]
if len(timesarg) == 0:
aver = (x_min+x_max)/2
timesarg = [(np.abs(times - aver)).argmin()]
slims = [mpl_spectrum.get_xlim(), mpl_spectrum.get_ylim()]
mpl_spectrum.clear()
mass_spect['annotation'].clear()
mass_spect['x'] = data_set['masses']
mass_spect['y'] = np.mean(
data_set['matrix'][start_scan:end_scan], axis=0)
data_set['matrix'][timesarg], axis=0)
pop_plot(mpl_spectrum, mass_spect)
mpl_spectrum.set_xlim(slims[0])
mpl_spectrum.set_ylim(slims[1])
mpl_chromatogram.clear()
pop_plot(mpl_chromatogram, chrom_spect)
dots_x = data_set['chrom_dat'][0, start_scan:end_scan]
dots_y = data_set['chrom_dat'][1, start_scan:end_scan]
dots_x = data_set['chrom_dat'][0, timesarg]
dots_y = data_set['chrom_dat'][1, timesarg]
mpl_chromatogram.plot(dots_x, dots_y, 'b.')
......
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