Reputation: 819
Here's the tuple I obtained when I'm trying to dins the peak of some result:
In: peaks, _ = find_peaks(probsuc,width=4)
peak_prominences(probsuc, peaks, wlen=7)
Out: (array([0.015625 , 0.24166667]), array([ 9, 36]), array([14, 42]))
I just want to obtain two lists: [9,14]
and [36,42]
. What I did was
In: [peak_prominences(probsuc, peaks, wlen=7)[1][0],peak_prominences(probsuc, peaks, wlen=7)[2][0]]
Out: [9, 14]
Is there a shorter way I can obtain the same result? Thanks!!
Upvotes: 0
Views: 47
Reputation: 350167
You should indeed avoid calling peak_prominences
twice.
For instance:
[arr[0] for arr in peak_prominences(probsuc, peaks, wlen=7)[1:]]
Or:
next(zip(*peak_prominences(probsuc, peaks, wlen=7)[1:]))
The latter is a tuple instead of a list. If you need a list, then apply list()
to it.
Upvotes: 1