mtspec
mtspec copied to clipboard
mtspec() : ability to return significant peaks list
When using mtspec function with verbose=True, we see the following in console log :
...
Line components 0.16329378925331473 15.1595049 0.986415267
Line components 0.16922540125610605 8.93782330 0.966565251
Line components 0.17759944173063502 11.3823347 0.977664471
Line components 0.23237962316817862 7.35149050 0.954259753
Line components 0.24982554082344730 7.67269707 0.957247198
Line components 0.25401256106071179 9.99182796 0.972184360
Line components 0.26238660153524074 8.30199242 0.962310731
Line components 0.26308443824145150 20.6504021 0.992203355
...
Where The first column is the freq, the second one the amplitude, and the third one the significance of the peak. Is there a way to get this list returned from mtspec function call instead of logging it out ?
Actually, in order to get this, we have to do something like the following
import pandas as pd
from scipy.stats import percentileofscore as pcos
spec, freq, jack, stats, _ = mtspec(data, 1, 2, statistics=True, fcrit=0.9, rshape=0, verbose=True)
df = pd.DataFrame({'freq':freq, 'spec':spec, 'stats': stats, 'sig':[pcos(stats, x) for x in stats]})
df[df['sig'] > 90].sort('freq')
I guess one would have to modify the fortran code a bit for that to work. Feel free to give it a shot. It should not be too hard.