Skip to content
Snippets Groups Projects
Commit 0e334024 authored by GuenterQuast's avatar GuenterQuast
Browse files

added option to select size of smoothing window

parent 66bcd153
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,9 @@ parser.add_argument('-f','--fit_range_factor',
parser.add_argument('-t','--threshold',
help = "threshold, i.e. minimum valid channel nmber (51)",
type=float, default=51)
parser.add_argument('-s','--smooth',
help = "smoothing-window size (5) ",
type=float, default=5)
parser.add_argument('-n','--noplot', action='store_true')
parser.add_argument('-k','--kafe2_plots', action='store_true')
parser.add_argument('-v','--verbose', action='store_true')
......@@ -68,6 +71,8 @@ rel_height = args.rel_height # width at half peak height (i.e. FWHM)
# constants for fit range
fit_range_factor = args.fit_range_factor # fit range = fit_range_factor * fwhm
min_channel = args.threshold # threshold for min. valid channel number
smoothing_window = args.smooth
verbose = args.verbose
plot = not args.noplot
kafe2_plots = args.kafe2_plots
......@@ -81,7 +86,10 @@ bin_edges= np.linspace(0, len(hst), len(hst)+1, endpoint=True)
# find maxima with scipy.signal.find_peaks()
# firts, smoothen data to reduce statistical noise
hst_s = meanFilter(hst, max(1, min_width//4))
if smoothing_window > 1:
hst_s = meanFilter(hst, smoothing_window)
else:
hst_s = hst
# search for peaks
peaks, peak_props = find_peaks(hst_s,
prominence=min_prominence,
......@@ -173,7 +181,7 @@ if plot:
ax0.plot(xhst, hst_s, 'b-', linewidth=1, zorder=2, label = 'smoothed channel counts')
ax0.errorbar(xhst, hst, yerr=np.sqrt(hst), zorder=1, label='channel counts',
fmt='.', color='grey', markersize=2, linewidth=2, alpha=0.5, )
ax0.plot(peaks, hst_s[peaks], '*', color='red', markersize=10, zorder=3,
ax0.plot(peaks, hst_s[peaks], 'x', color='red', markersize=10, zorder=3,
label='result of find_peaks()')
ax0.legend(loc = 'best')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment