Detailed peakbagging¶
The detailed peakbagging stage is meant to remove the constraints from the various models we use to define the frequency pattern in the mode ID stage.
It’s possible to run the peakbag stage without doing the mode ID stage first, so that you can supply your own solutions if the mode ID is wonky. It’s even possible to run it with just the angular degree and frequencies as inputs, but performs a lot better if you pass it the mode heights and widths too.
Let’s start by loading in the spectrum.
Note: You may want to use the full resolution spectrum for the detailed peakbagging. It will take longer but should give you the highest precision on your frequencies.
[1]:
from pbjam import IO
tgt = 'KIC5184732'
psd = IO.psd(tgt, lk_kwargs={'exptime': 60, 'mission':'Kepler', 'author':'Kepler'})
psd()
f = psd.freq
s = psd.powerdensity
The peakbag module requires some inputs in the form of mode frequenices, heights and widths. These can be supplied manually, but we’ll use the modeID to generate them for us. You should read the mode ID notebook for more details.
Note: As in the mode ID notebook we use a downsampled version of the spectrum since the full resolution isn’t necessary for mode ID on this star.
[2]:
from pbjam.modeID import modeID
obs = {'teff' : (5846, 80), # K
'bp_rp': (0.819174, 0.05),
'numax': (2089.3, 20.0), # muHz
'dnu' : (95.545, 0.5)} # muHz
downSampling = 10
M = modeID(f[::downSampling], s[::downSampling], obs, N_p=7)
M()
modeID_result = M.result
14000it [03:30, 66.50it/s, +600 | bound: 149 | nc: 1 | ncall: 402184 | eff(%): 3.636 | loglstar: -inf < -7098.590 < inf | logz: -7119.615 +/- 0.171 | dlogz: 0.000 > 0.100]
Input Teff=5846K and dnu=95.545muHz suggests the appropriate l=1 model is: ms
1445it [00:06, 237.29it/s, +150 | bound: 41 | nc: 1 | ncall: 26694 | eff(%): 6.009 | loglstar: -inf < -5834.160 < inf | logz: -5841.417 +/- 0.200 | dlogz: 0.001 > 0.100]
4212it [00:16, 258.88it/s, +150 | bound: 161 | nc: 1 | ncall: 90335 | eff(%): 4.837 | loglstar: -inf < -5834.154 < inf | logz: -5841.417 +/- 0.189 | dlogz: 0.000 > 0.000]
We can now supply the mode ID solution to the peakbag module. Again, these can be supplied manually if you disagree with the mode ID. Furthermore, they can be any combination of angular degrees that you can find. If you supply only \(\ell=2,0\) mode pairs, then PBjam will mask out the regions in between the pairs so reduce the effect of the \(\ell=1\) mode power. This behavior is then identical to that of the first release of PBjam.
At this stage we have the choice of two samplers, either emcee or Dynesty. emcee is likely the best choice for main-sequence or sub-giant stars since the solutions are not likely to be multimodal. However, for red giants, the Dynesty sampler may work better. In this case since we’re looking at a main-sequence star we’ll just use emcee.
[3]:
from pbjam.peakbagging import peakbag
pb = peakbag(f, s,
ell=modeID_result['ell'],
freq=modeID_result['summary']['freq'],
height=modeID_result['summary']['height'],
width=modeID_result['summary']['width'],
samplerType='emcee')
Using emcee to sample.
We can now simply call the pb class instance to start the sampling.
[4]:
pb_result = pb()
Peakbagging slice 1/1
Burning in sampler
Convergence >> 1: 20.0
Convergence >> 1: 7.9
Convergence >> 1: 3.7
Convergence >> 1: 2.1
Convergence >> 1: 1.6
Convergence >> 1: 0.9
Sampling posterior.
Time taken 40.9 minutes
As with the mode ID class we can use there are several plotting functions available with the peakbag class.
[5]:
pb.spectrum();
And the results are stored in the result attribute.
[6]:
pb.result
[6]:
{'ell': array([1., 1., 1., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 2., 2., 2.,
2., 2., 2., 2.]),
'enn': array([], dtype=float64),
'emm': array([], dtype=float64),
'zeta': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0.]),
'summary': {'freq': array([[1.80051325e+03, 1.89561495e+03, 1.99151765e+03, 2.08744830e+03,
2.18331039e+03, 2.27905716e+03, 2.37501062e+03, 1.75667208e+03,
1.85109350e+03, 1.94664732e+03, 2.04237008e+03, 2.13821501e+03,
2.23357230e+03, 2.32915235e+03, 1.75016216e+03, 1.84463450e+03,
1.94039484e+03, 2.03636428e+03, 2.13241863e+03, 2.22800926e+03,
2.32422880e+03],
[8.40673891e-02, 7.50538996e-02, 6.56138458e-02, 7.36483197e-02,
7.32410193e-02, 9.58037752e-02, 1.35408529e-01, 7.67754829e-02,
8.92006983e-02, 5.92298605e-02, 6.18582392e-02, 6.39755237e-02,
8.65581199e-02, 2.19227929e-01, 2.42418023e-01, 9.10180782e-02,
1.06559029e-01, 1.00104906e-01, 1.06280565e-01, 1.27107128e-01,
4.24271752e-01]]),
'height': array([[ 5.79128615, 8.22032029, 11.95249479, 10.76948957, 11.28664018,
5.87968901, 3.28335064, 3.77110819, 3.61778066, 6.9665387 ,
7.25073486, 8.06398178, 5.3557734 , 2.07059552, 1.49291298,
4.03741678, 5.24465475, 6.36840621, 5.88581612, 4.43242587,
1.72085399],
[ 0.91443554, 1.12560223, 1.52357902, 1.24695368, 1.30438551,
0.67193349, 0.37748012, 0.65989506, 0.54623974, 1.10892773,
1.11911167, 1.15869308, 0.70850541, 0.29956018, 0.4805849 ,
1.10865895, 1.1194841 , 1.29569607, 1.06656162, 0.8649597 ,
0.42994869]]),
'width': array([[1.17539568, 1.36182374, 1.22544065, 1.71987551, 1.63334375,
2.30339515, 3.01546331, 1.18456856, 1.52216473, 1.12199093,
1.26975217, 1.26597507, 1.78860729, 2.64380514, 1.66357037,
0.79239644, 1.04514233, 0.97045981, 1.3531044 , 1.36660941,
2.52352623],
[0.15816055, 0.15409301, 0.12133522, 0.15407634, 0.14175993,
0.21622292, 0.31824957, 0.17922021, 0.19202917, 0.13620725,
0.15150876, 0.13958386, 0.20460472, 0.49781099, 0.65158012,
0.23768347, 0.22688362, 0.19196636, 0.25470333, 0.28652632,
0.76112323]])},
'samples': {'freq': array([[1800.45696455, 1895.58652671, 1991.6266081 , ..., 2132.40180627,
2228.02975421, 2324.56840587],
[1800.55295752, 1895.52225684, 1991.54347547, ..., 2132.51033581,
2227.99395204, 2324.34059425],
[1800.41303081, 1895.62118029, 1991.56827201, ..., 2132.44590429,
2228.30015237, 2324.17039188],
...,
[1800.50132343, 1895.63735084, 1991.57298626, ..., 2132.27036641,
2227.99089577, 2323.98830377],
[1800.45624105, 1895.63618123, 1991.61056237, ..., 2132.29100196,
2227.80681509, 2324.11101925],
[1800.45702494, 1895.74367884, 1991.59332777, ..., 2132.44667633,
2227.95631915, 2323.8349625 ]], shape=(5226, 21)),
'height': array([[ 4.19921349, 8.96774968, 11.77024224, ..., 4.83223349,
5.02720812, 1.4472977 ],
[ 5.80495875, 8.24294508, 13.09836967, ..., 6.49803962,
3.88136514, 1.61305667],
[ 4.15985956, 7.88057378, 12.10614834, ..., 4.07950879,
3.81225107, 1.53008184],
...,
[ 6.12680272, 6.54649357, 12.92031861, ..., 4.19881657,
5.24416273, 1.47893829],
[ 5.22250879, 7.01075804, 9.13806246, ..., 7.81823398,
3.78094047, 1.61030786],
[ 5.46150239, 8.54984883, 12.07713072, ..., 6.3565341 ,
5.7708729 , 1.29988244]], shape=(5226, 21)),
'width': array([[1.57116663, 1.21851709, 1.31097587, ..., 1.57059547, 1.22461282,
2.75762082],
[1.2405235 , 1.36733438, 1.20148304, ..., 1.06075531, 1.55413867,
2.30380061],
[1.45864666, 1.3445074 , 1.25666545, ..., 1.93093499, 1.5588693 ,
2.12273995],
...,
[0.92179802, 1.56087916, 1.20509988, ..., 1.71389531, 1.23485994,
1.80143918],
[1.25606277, 1.46011771, 1.52777054, ..., 1.03005689, 1.47549891,
2.26282833],
[1.14040853, 1.29652049, 1.17682926, ..., 1.20994087, 0.90063661,
2.646296 ]], shape=(5226, 21))},
'kstest': {'significant': array([ True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True,
True, True, True]),
'pvalue': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0.]),
'statistic': array([0.48599092, 0.50672442, 0.47275587, 0.48925317, 0.48119263,
0.49476742, 0.51807656, 0.59109806, 0.49098902, 0.51267434,
0.52054528, 0.53065531, 0.62144536, 0.66974976, 0.62831818,
0.53463624, 0.54781342, 0.56803892, 0.58706188, 0.51335538,
0.44454581])}}