The session class¶
The session class is the highest level module of PBjam and is meant to handle analysing several sets of data. It essentially wraps number of star class instances, which is one of the core modules of PBjam. Each star class instance in the Session then runs the lowest-level analysis modules of PBjam which are the modeID and peakbag modules. For more information on these modules see the relevant notebooks in the Examples directory. If you want more bespoke control of
the data and inputs used to analyze each individual star, you can in principle do it via the session class, but it is recommended that you build your own pipeline using the lower-level modules.
Analyzing a single star¶
Let’s start by looking at a single star though for now. In this case we’ll look at a main-sequence star KIC10963065. We’ll supply PBjam with some basic observational parameter which it uses to define the prior probability during the mode ID process. The obs dictionary must contain \(\nu_{\mathrm{max}}\), \(\Delta\nu\), \(T_{\mathrm{eff}}\) and the Gaia \(G_{\mathrm{bp}}-G_{\mathrm{rp}}\) color index.
[1]:
name = 'KIC10963065'
obs = {'numax': (2204, 100), #muHz
'dnu' : (103.2, 0.54), #muHz
'teff' : (6140, 77), #K
'bp_rp': (0.70026, 0.05), #mag
}
Since we’ll be looking up the time series online with Lightkurve, the name of the target has to be one that is resolvable on MAST. Most common names that you can find on Simbad will probably do.
Next we’ll initialize the session class, where we provide the name, obs dictionary and a dictionary with keywords for Lightkurve. In this case, since it’s a main-sequence star we’re looking at, we’ll pick an exposure time of 60s, and we’ll use the observations from quarter 6 of the Kepler mission. PBjam will then download the relevant data, reduce it to a useable form, and compute the power density spectrum.
[2]:
from pbjam.core import session
sess = session(name, obs, lk_kwargs={'exptime': 60, 'mission': 'Kepler', 'quarter': 6})
The next step is doing the analysis is calling the session class instance, where we supply a keyword N_p=7 to the mode ID stage. Other keywords may be supplied in this way to the modeID module, or the peakbag module.
[3]:
sess(modeID_kwargs={'N_p': 7})
Target: KIC10963065
16832it [02:04, 135.21it/s, +600 | bound: 166 | nc: 1 | ncall: 492389 | eff(%): 3.545 | loglstar: -inf < -6255.061 < inf | logz: -6280.804 +/- 0.193 | dlogz: 0.000 > 0.100]
Input Teff=6140K and dnu=103.2muHz suggests the appropriate l=1 model is: ms
1563it [00:05, 311.84it/s, +150 | bound: 46 | nc: 1 | ncall: 29369 | eff(%): 5.863 | loglstar: -inf < -5941.568 < inf | logz: -5949.616 +/- 0.208 | dlogz: 0.001 > 0.100]
4343it [00:11, 385.30it/s, +150 | bound: 167 | nc: 1 | ncall: 93309 | eff(%): 4.823 | loglstar: -inf < -5941.487 < inf | logz: -5949.615 +/- 0.196 | dlogz: 0.000 > 0.000]
Using emcee to sample.
Peakbagging slice 1/1
Burning in sampler
Convergence >> 1: 20.0
Convergence >> 1: 7.5
Convergence >> 1: 4.2
Convergence >> 1: 2.6
Convergence >> 1: 1.7
Convergence >> 1: 1.2
Convergence >> 1: 1.3
Convergence >> 1: 1.1
Convergence >> 1: 0.9
Sampling posterior.
Time taken 9.9 minutes
To access the results of the run you can either plot them using the various built-in methods in PBjam or simply output the results in the form of a dictionary. There are various ways of viewing the results as plots, which are covered in a separate notebook.
[9]:
st = sess.stars[0]
print(st.modeID.result)
print(st.peakbag.result)
{'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([-1., -1., -1., -1., -1., -1., -1., 17., 18., 19., 20., 21., 22.,
23., 16., 17., 18., 19., 20., 21., 22.]), 'emm': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0.]), 'zeta': array([0., 0., 0., 0., 0., 0., 0., 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.93395541e+03, 2.03688791e+03, 2.13995293e+03, 2.24314840e+03,
2.34647962e+03, 2.44994072e+03, 2.55353791e+03, 1.88638822e+03,
1.98932073e+03, 2.09238574e+03, 2.19558122e+03, 2.29891244e+03,
2.40237353e+03, 2.50597073e+03, 1.87884775e+03, 1.98178288e+03,
2.08484872e+03, 2.18804814e+03, 2.29137536e+03, 2.39483613e+03,
2.49843251e+03],
[1.14842366e-01, 1.14842366e-01, 1.14842366e-01, 1.14842366e-01,
1.14842366e-01, 1.14842366e-01, 1.14842366e-01, 1.36812952e-01,
1.24882184e-01, 1.24714659e-01, 1.34168523e-01, 1.51840218e-01,
1.77545729e-01, 2.14595773e-01, 1.85430703e-01, 1.65204898e-01,
1.53674014e-01, 1.51996170e-01, 1.59073430e-01, 1.74676692e-01,
1.99312565e-01]]), 'height': array([[3.43871187e+00, 5.59594330e+00, 7.24821659e+00, 7.46597431e+00,
6.11018181e+00, 3.96966226e+00, 2.04544141e+00, 2.06911055e+00,
3.74248344e+00, 5.40990856e+00, 6.20861719e+00, 5.66122728e+00,
4.08895874e+00, 2.34227730e+00, 1.39381284e+00, 2.56391290e+00,
3.76759093e+00, 4.39821684e+00, 4.07737220e+00, 2.99631037e+00,
1.74531737e+00],
[2.30635987e-03, 2.32717297e-03, 1.16477870e-03, 7.07759094e-04,
2.14244434e-03, 2.40878447e-03, 1.76583577e-03, 1.43515739e-01,
2.10465446e-01, 2.74078611e-01, 3.23656278e-01, 3.07548629e-01,
2.43769123e-01, 1.68387344e-01, 9.92170661e-02, 1.45826015e-01,
1.93740870e-01, 2.28669575e-01, 2.20053029e-01, 1.77090720e-01,
1.23622747e-01]]), 'width': array([[1.59364011, 1.59364011, 1.59364011, 1.59364011, 1.59364011,
1.59364011, 1.59364011, 1.59364011, 1.59364011, 1.59364011,
1.59364011, 1.59364011, 1.59364011, 1.59364011, 1.59364011,
1.59364011, 1.59364011, 1.59364011, 1.59364011, 1.59364011,
1.59364011],
[0.03451303, 0.03451303, 0.03451303, 0.03451303, 0.03451303,
0.03451303, 0.03451303, 0.03451303, 0.03451303, 0.03451303,
0.03451303, 0.03451303, 0.03451303, 0.03451303, 0.03451303,
0.03451303, 0.03451303, 0.03451303, 0.03451303, 0.03451303,
0.03451303]]), 'rotAsym': array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0.]]), 'd01': array([47.56718356, 0.11484237]), 'nurot_e': array([0.67792527, 0.18818178]), 'inc': array([1.0174272 , 0.23252368]), 'dnu': array([1.03277614e+02, 4.21410434e-02]), 'numax': array([2204.8556618 , 4.85255443]), 'eps_p': array([1.25905487, 0.00824217]), 'd02': array([7.53956764, 0.11660034]), 'alpha_p': array([1.27255304e-03, 8.89110585e-05]), 'env_width': array([215.37152956, 4.69657152]), 'env_height': array([3.10857386, 0.16305447]), 'mode_width': array([1.59364011, 0.03451303]), 'teff': array([6187.71211775, 19.26715139]), 'bp_rp': array([0.68803702, 0.00804031]), 'H1_nu': array([1393.91955579, 126.82269393]), 'H1_exp': array([2.82384978, 0.28409248]), 'H_power': array([792.72282744, 36.59243046]), 'H2_nu': array([467.9672305, 13.9439951]), 'H2_exp': array([2.58411666, 0.17762907]), 'H3_power': array([424.19313762, 688.52618419]), 'H3_nu': array([0.63593638, 1.27249079]), 'H3_exp': array([4.61358885, 0.41997328]), 'shot': array([0.81197622, 0.01121766])}, 'samples': {'freq': array([[1933.85443266, 2036.78693998, 2139.85195543, ..., 2291.41375872,
2394.84464046, 2498.41547846],
[1934.04177 , 2036.97427732, 2140.03929277, ..., 2291.12369493,
2394.64637796, 2498.29359903],
[1934.04608162, 2036.97858893, 2140.04360439, ..., 2291.38201392,
2394.87525194, 2498.49684502],
...,
[1933.80638589, 2036.73889321, 2139.80390866, ..., 2291.36803705,
2394.85083701, 2498.46618854],
[1934.06310272, 2036.99561003, 2140.06062549, ..., 2291.39778806,
2394.82815478, 2498.40577173],
[1934.04608162, 2036.97858893, 2140.04360439, ..., 2291.30994531,
2394.76418256, 2498.3620293 ]]), 'height': array([[3.43668426, 5.59389696, 7.24719182, ..., 3.56943248, 2.59516708,
1.50165061],
[3.4404465 , 5.59769321, 7.24909196, ..., 4.02248249, 3.01066569,
1.79584776],
[3.4405331 , 5.59778056, 7.24913564, ..., 4.03865747, 3.02036693,
1.78657753],
...,
[3.43571959, 5.59292307, 7.24670368, ..., 4.37399672, 3.27071506,
1.9323839 ],
[3.44087501, 5.59812539, 7.24930802, ..., 4.68247144, 3.46407562,
2.03978351],
[3.4405331 , 5.59778056, 7.24913564, ..., 3.88918069, 2.85950369,
1.68118498]]), 'width': array([[1.59364011, 1.59364011, 1.59364011, ..., 1.56675665, 1.56675665,
1.56675665],
[1.59364011, 1.59364011, 1.59364011, ..., 1.65813511, 1.65813511,
1.65813511],
[1.59364011, 1.59364011, 1.59364011, ..., 1.62352119, 1.62352119,
1.62352119],
...,
[1.59364011, 1.59364011, 1.59364011, ..., 1.58789633, 1.58789633,
1.58789633],
[1.59364011, 1.59364011, 1.59364011, ..., 1.60875278, 1.60875278,
1.60875278],
[1.59364011, 1.59364011, 1.59364011, ..., 1.58776951, 1.58776951,
1.58776951]]), 'rotAsym': array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]]), 'd01': array([47.46621121, 47.65354854, 47.65786016, ..., 47.41816443,
47.67488126, 47.65786016]), 'nurot_e': array([0.01049648, 0.63014271, 0.63114985, ..., 0.82903005, 0.6688502 ,
0.8077866 ]), 'inc': array([1.44820977, 1.0359723 , 1.08892851, ..., 0.97304386, 1.1754836 ,
1.07675617]), 'dnu': array([103.22429417, 103.35366366, 103.32406724, ..., 103.30316547,
103.25007575, 103.24470347]), 'numax': array([2198.16964088, 2210.27714973, 2214.4926159 , ..., 2209.55418042,
2202.61174252, 2205.10344507]), 'eps_p': array([1.27116708, 1.24274204, 1.2504864 , ..., 1.2539149 , 1.26401824,
1.26568339]), 'd02': array([7.57841439, 7.79093603, 7.67168056, ..., 7.40245731, 7.58699461,
7.52452385]), 'alpha_p': array([0.00135585, 0.00120497, 0.00124226, ..., 0.00113896, 0.00137209,
0.00121241]), 'env_width': array([216.88002433, 217.67055394, 214.06161383, ..., 209.92385705,
219.06005914, 210.5310651 ]), 'env_height': array([2.75707796, 3.03501896, 3.03364602, ..., 3.59879638, 3.15413696,
2.98819459]), 'mode_width': array([1.56675665, 1.65813511, 1.62352119, ..., 1.57887391, 1.62962834,
1.55376982]), 'teff': array([6143.00022947, 6214.55703851, 6203.09126594, ..., 6233.73440418,
6162.26979372, 6182.40762548]), 'bp_rp': array([0.70551507, 0.68461372, 0.68936111, ..., 0.66882225, 0.69776842,
0.69333576]), 'H1_nu': array([1461.76733529, 1646.18212804, 1600.67614154, ..., 1266.29756192,
1500.31931728, 1445.7548317 ]), 'H1_exp': array([2.82176501, 3.32107764, 3.07666319, ..., 2.71948038, 2.96438249,
2.86403214]), 'H_power': array([880.01194032, 785.95075047, 833.12416159, ..., 683.24255382,
838.19969207, 818.60846781]), 'H2_nu': array([471.01076734, 495.93759376, 486.0365799 , ..., 458.11414946,
477.32182148, 470.91694814]), 'H2_exp': array([2.55800161, 2.66803401, 2.30665923, ..., 2.59361377, 2.55902336,
2.43658702]), 'H3_power': array([ 983.55489218, 1953.80350773, 1721.23121942, ..., 797.67531088,
733.38708383, 281.85257031]), 'H3_nu': array([0.22841461, 0.10049829, 0.48349865, ..., 0.76067943, 0.16409145,
0.8406847 ]), 'H3_exp': array([2.54859376, 4.51935058, 4.76704678, ..., 4.88631305, 4.78127376,
4.17971173]), 'shot': array([0.81826943, 0.81067767, 0.7985582 , ..., 0.82492945, 0.80912955,
0.81707296])}}
{'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.93364558e+03, 2.03659418e+03, 2.14044521e+03, 2.24300911e+03,
2.34697545e+03, 2.44984485e+03, 2.55407529e+03, 1.88663837e+03,
1.98908501e+03, 2.09197083e+03, 2.19596944e+03, 2.29900051e+03,
2.40107319e+03, 2.50570934e+03, 1.87861835e+03, 1.98134342e+03,
2.08570446e+03, 2.18863482e+03, 2.29358299e+03, 2.39583234e+03,
2.49726091e+03],
[2.87675131e-01, 2.24354717e-01, 2.42353129e-01, 2.32907574e-01,
3.78890526e-01, 4.19780801e-01, 4.16929541e-01, 3.04823764e-01,
2.63665208e-01, 2.95927679e-01, 3.11029187e-01, 4.18940384e-01,
5.08331618e-01, 3.85906263e-01, 8.72819295e-01, 6.25692901e-01,
6.64543267e-01, 4.89678556e-01, 6.47453332e-01, 8.20523188e-01,
1.21320626e+00]]), 'height': array([[ 8.00728341, 6.77672931, 8.38562977, 11.12725105, 8.61194262,
3.70666446, 4.87362703, 2.71802299, 5.26251998, 5.27839877,
6.138736 , 5.45620718, 5.55240165, 2.86963552, 1.63882941,
2.99994176, 3.4717859 , 4.30451325, 4.32335288, 3.71393309,
1.64686201],
[ 2.2177241 , 1.95401894, 2.34508851, 3.03935809, 2.3344242 ,
1.17731095, 1.43308035, 1.0047621 , 1.72071235, 1.69682553,
1.90354535, 1.82525335, 1.85744673, 1.03292288, 0.70641387,
1.03346124, 1.17459963, 1.34591056, 1.44751044, 1.37228561,
0.73141548]]), 'width': array([[1.59508719, 1.34794895, 1.34406153, 1.55044253, 2.41429062,
1.52819251, 1.75643976, 1.55881556, 1.6530988 , 1.62465683,
1.66664239, 1.8354384 , 2.05451131, 1.70254192, 1.61827216,
1.63876186, 1.6080802 , 1.51899042, 1.66141158, 1.732811 ,
1.62709008],
[0.31058605, 0.27158423, 0.25801734, 0.28563721, 0.42429619,
0.3208956 , 0.34404898, 0.32273651, 0.33867755, 0.30964364,
0.30632171, 0.37572551, 0.42327572, 0.36295061, 0.36971354,
0.35907879, 0.34563218, 0.33447556, 0.37152958, 0.39815885,
0.37715689]])}, 'samples': {'freq': array([[1933.39396235, 2036.221698 , 2140.81413659, ..., 2293.53418089,
2394.4040709 , 2498.55425676],
[1933.64937631, 2036.61702149, 2140.4060141 , ..., 2292.86448417,
2395.64559079, 2497.27513365],
[1933.54137099, 2036.83789834, 2140.75994331, ..., 2292.94050233,
2396.50451272, 2497.12291614],
...,
[1933.79514007, 2037.02042156, 2140.15598421, ..., 2292.41166337,
2395.12220031, 2496.94870959],
[1933.44528234, 2036.47098482, 2140.55902187, ..., 2293.86385841,
2393.61468568, 2499.1424266 ],
[1933.73582716, 2036.81168155, 2140.44199171, ..., 2294.18862424,
2395.57647973, 2496.65762037]]), 'height': array([[ 5.02052136, 6.26941168, 10.06634431, ..., 3.72989665,
2.2860466 , 2.18200026],
[ 6.83978872, 6.48003271, 8.13335986, ..., 2.9912075 ,
2.32901787, 1.3956044 ],
[ 8.24616785, 5.10110242, 8.12438712, ..., 3.56392591,
5.09039411, 0.93560168],
...,
[ 9.12899783, 8.59213088, 8.36675838, ..., 4.93116442,
4.46108955, 1.1826913 ],
[ 8.46364982, 6.372377 , 9.07544855, ..., 5.92535195,
1.55026254, 1.41926584],
[ 7.1529792 , 7.8458176 , 11.25670149, ..., 6.44447745,
2.26235335, 2.82631563]]), 'width': array([[1.5746438 , 1.32302114, 0.96265147, ..., 1.45683309, 2.42980918,
1.59508146],
[1.37119507, 1.29409491, 1.21299149, ..., 1.27235345, 1.67739538,
1.58581191],
[1.66945586, 1.43149614, 1.34827488, ..., 1.53436869, 2.11879966,
1.45488613],
...,
[1.4995019 , 1.24851838, 1.47034814, ..., 1.58238258, 1.33556481,
1.33061977],
[2.00089262, 1.43495002, 1.27783214, ..., 1.72953763, 1.87377627,
1.7697762 ],
[2.05648656, 1.04992435, 1.08546434, ..., 1.13148864, 2.53489646,
1.1937131 ]])}, '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.44677564, 0.46484518, 0.4795488 , 0.4362341 , 0.44503292,
0.38326087, 0.44115463, 0.43099494, 0.43999085, 0.45333069,
0.44549191, 0.37992427, 0.52648015, 0.4123269 , 0.29436004,
0.37806912, 0.4226273 , 0.45162585, 0.59958439, 0.41271373,
0.34426471])}}
Analyzing multiple targets in one session¶
Analyzing multiple targets in the same session is a handy way to treat groups of targets in a similar way. Doing this is very similar to just running a single target session, however, the name argument is now a list and the supplied dictionaries should now be organized according to the target names.
[ ]:
from pbjam.core import session
name1 = 'KIC10963065'
name2 = 'KIC5184732'
obs = {name1 : {'numax': (2204, 100), #muHz
'dnu' : (103.2, 0.54), #muHz
'teff' : (6140, 77), #K
'bp_rp': (0.70026, 0.05), #mag
},
name2 : {'teff' : (5846, 80), # K
'bp_rp': (0.819174, 0.05), # mag
'numax': (2089.3, 20.0), # muHz
'dnu' : (95.545, 0.5)} # muHz
}
lk_kwargs = {name1 : {'exptime': 60, 'mission': 'Kepler', 'quarter': 6},
name2 : {'exptime': 60, 'mission': 'Kepler', 'quarter': 11}}
multi_sess = session([name1, name2], obs, lk_kwargs=lk_kwargs)
Note: You may encounter memory issues if you are analyzing hundreds of stars in a single session. It is therefore advisable to create your own pipeline using the star class and iteratively save each run for each star. A small handful of stars shouldn’t be a problem for a session instance on most machines though.
[ ]:
multi_sess(modeID_kwargs={name1 : {'N_p': 7},
name2 : {'N_p': 10}})