peakbag

This module is used for constructing a `PyMC3’ model of the power spectrum using the outputs from asy_peakbag as priors.

class pbjam.peakbag.peakbag(starinst, init=True, path=None, verbose=False)[source]

Class for the final peakbagging.

This class is used after getting the frequency intervals from asy_peakbag, that include the $l=0,2$ mode pairs.

The

Examples

Using peakbag from the star class instance (recommended)

>>> st = pbjam.star(ID='KIC4448777', pg=pg, numax=[220.0, 3.0],
                       dnu=[16.97, 0.01], teff=[4750, 100],
                       bp_rp = [1.34, 0.01])
>>> st.run_kde()
>>> st.run_asy_peakbag(norders=7)
>>> st.run_peakbag()

Using peakbag on it’s own. Requires output from `asy_peakbag’.

>>> pb = pbjam.peakbag(st.asy_fit)
>>> pb()
Parameters:
  • f (float, array) – Array of frequency bins of the spectrum (muHz). Truncated to the range around numax.
  • snr (float, array) – Array of SNR values for the frequency bins in f (dimensionless).
  • asy_fit (asy_fit) – The result from the asy_peakbag method.
  • init (bool) – If true runs make_start and trim_ladder to prepare starting guesses for sampling and transforms the data onto a ladder.
f

Array of frequency bins of the spectrum (muHz). Truncated to the range around numax.

Type:float, ndarray
snr

Array of SNR values for the frequency bins in f (dimensionless).

Type:float, ndarray
asy_fit

The result from the asy_peakbag method. This is a dictionary of ‘modeID’ and ‘summary’. ‘modeID’ is a DataFrame with a list of modes and basic properties. ‘summary’ are summary statistics from the asymptotic_fit. See asy_peakbag asymptotic_fit for more details.

Type:asy_fit
init_model(model_type)[source]

Initialize the pymc3 model for peakbag

Sets up the pymc3 model to sample, to perform the final peakbagging.

Two treatements of the mode widths are available, the default independent mode widths for each pair, or modeling the mode widths as a function of freqeuency as a Gaussian Process.

Parameters:model_type (str) – Model choice for the mode widths. The default is to treat the all mode widths independently. Alternatively they can be modeled as a GP.
lor(freq, w, h)[source]

Simple Lorentzian profile

Calculates N Lorentzian profiles, where N is the number of pairs in the frequency list.

Parameters:
  • freq (float, ndarray) – Central frequencies the N Lorentzians
  • w (float, ndarray) – Widths of the N Lorentzians
  • h (float, ndarray) – Heights of the N Lorentzians
Returns:

lors – A list containing one Lorentzian per pair.

Return type:

ndarray

make_start()[source]

Set the starting model for peakbag

Function uses the result of the asymptotic peakbagging and builds a dictionary of starting values for the peakbagging methods.

model(l0, l2, width0, width2, height0, height2, back)[source]

Calcuates a simple model of a flat backgroud plus two lorentzians for each of the N pairs in the list of frequencies under consideration.

Parameters:
  • l0 (ndarray) – Array of length N, of the l=0 mode frequencies.
  • l2 (ndarray) – Array of length N, of the l=2 mode frequencies.
  • width0 (ndarray) – Array of length N, of the l=0 mode widths.
  • width2 (ndarray) – Array of length N, of the l=2 mode widths.
  • height0 (ndarray) – Array of length N, of the l=0 mode heights.
  • height2 (ndarray) – Array of length N, of the l=2 mode heights.
  • back (ndarray) – Array of length N, of the background levels.
Returns:

mod – A 2D array (or ‘ladder’) containing the calculated models for each of the N pairs.

Return type:

ndarray

remove_outsiders(l0, l2)[source]

Drop outliers

Drops modes where the guess frequency is outside of the supplied frequency range.

Parameters:
  • l0 (ndarray) – Array of l0 mode frequencies
  • l2 (ndarray) – Array of l2 mode frequencies
trim_ladder(lw_fac=10, extra=0.01, verbose=False)[source]

Turns mode frequencies into list of pairs

This function turns the list of mode frequencies into pairs and then selects only the pairs in the ladder that have modes that are to be fit.

Each pair is constructed so that the central frequency is the mid point between the l=0 and l=2 modes as determined by the information in the asy_fit dictionary.

Parameters:
  • lw_fac (float) – The factor by which the mode line width is multiplied in order to contribute to the pair width.
  • extra (float) – The factor by which dnu is multiplied in order to contribute to the pair width.