asy_peakbag

This module fits the asymptotic relation to the p-modes in a frequency range around $ u_{max}$, the central frequency of the seismic mode envelope, in a solar-like oscillator. Only $l=0$ and $l=2$ are fit, $l=1$ modes are currently ignored.

class pbjam.asy_peakbag.asymp_spec_model(f, norders)[source]

Class for spectrum model using asymptotic relation.

This class is meant to provide initial inputs and mode ID for the final fit using peakbag.

As such the spectrum model is simplified. The mode frequencies are estimated by the asymptotic relation, the mode heights by a Gaussian centered at nu_max, and we only use a single width for all modes across the p-mode envelope.

Parameters:
  • f (ndarray) – Array of frequency bins of the spectrum (in muHz).
  • norders (int) – Number of radial order to fit.
model(dnu, numax, eps, d02, alpha, hmax, envwidth, modewidth, *args)[source]

Constructs a spectrum model from the asymptotic relation.

The asymptotic relation for p-modes with angular degree, l=0, is defined as:

$nu_nl = (n + epsilon + lpha/2(n - nmax)^2) * log{dnu}$ ,

where nmax = numax / dnu - epsilon.

We separate the l=0 and l=2 modes by the small separation d02.

Parameters:
  • dnu (float) – Large separation log10(muHz)
  • lognumax (float) – Frequency of maximum power of the p-mode envelope log10(muHz)
  • eps (float) – Phase term of the asymptotic relation (unitless)
  • alpha (float) – Curvature of the asymptotic relation log10(unitless)
  • d02 (float) – Small separation log10(muHz)
  • loghmax (float) – Gaussian height of p-mode envelope log10(SNR)
  • logenvwidth (float) – Gaussian width of the p-mode envelope log10(muHz)
  • logmodewidth (float) – Width of the modes (log10(muHz))
  • *args (array-like) – List of additional parameters (Teff, bp_rp) that aren’t actually used to construct the spectrum model, but just for evaluating the prior.
Returns:

model – spectrum model around the p-mode envelope

Return type:

ndarray

class pbjam.asy_peakbag.asymptotic_fit(st, norders=None)[source]

Class for fitting a spectrum based on the asymptotic relation.

Parameters:
  • st (star class instance.) – The star to fit using the asymptotic relation.
  • norders (int, optional) – Number of radial orders to fit.
f

Numpy array of frequency bins of the spectrum (muHz).

Type:ndarray
s

Numpy array of power in each frequency bin (SNR).

Type:ndarray
sel

Numpy array of boolean values specifying the frequency range to be considered in the asymptotic relation fit.

Type:ndarray, bool
model

Function for computing a spectrum model given a set of parameters.

Type:asymp_spec_model.model instance
prior_file

Path to the csv file containing the prior data. Default is pbjam/data/prior_data.csv

Type:str
par_names

List of parameters names of the spectrum model.

Type:list
_obs

Dictionary of the observational parameters (input parameters).

Type:dict
_log_obs

Dictionary of the observational parametrs in log-scale.

Type:dict
prior_data

Dataframe containing the samples used to the generate the KDE prior.

Type:pandas DataFrame
start_samples

Array of samples drawn from the KDE to set the starting location of the asymptotic relation fit.

Type:ndarray
kde

KDE function used as a prior in the asymptotic relation fit.

Type:statsmodels.kde instance
start

Median of parameters in start_samples.

Type:ndarray
developer_mode

Run asy_peakbag in developer mode. Currently just retains the input value of dnu and numax as priors, for the purposes of expanding the prior sample. Important: This is not good practice for getting science results!

Type:bool
get_modeIDs(fit, norders)[source]

Set mode ID in a dataframe

Evaluates the asymptotic relation for each walker position from the `emcee’ sampling. The median values of the resulting set of frequencies are then returned in a pandas DataFrame

Parameters:
  • fit (mcmc.mcmc class instance) – mcmc class instances used in the fit
  • norders (int) – Number of radial orders to output. Note that doesn’t have to be the same as that used int he fit itself.
Returns:

modeID – Dataframe of radial order, n (best guess), angular degree, l, frequency and frequency error.

Return type:

pandas.DataFrame

likelihood(p)[source]

Likelihood function for set of model parameters

Evaluates the likelihood function for a set of model parameters. This includes the constraint from the observed variables.

The code now includes a penalty to limit very large linewidth examples. The penalty is very basic and in some cases where the true linewidth is much larger than the linewidth in the prior it will become informative. For the most part this should not be a problem because if you care about linewidths you should be using the outpout from the peakbag model.

Parameters:p (ndarray) – Array of model parameters
Returns:lnlike – The log likelihood evaluated at p.
Return type:float
prior(p)[source]

Calculates the log prior

Evaluates the KDE for the parameters p. Additional hard/soft priors can be added here as needed to, e.g., apply boundaries to the fit.

Hard constraints should be applied at the top so function exits early, if necessary.

Parameters:p (ndarray) – Array of model parameters.
Returns:lp – The log likelihood evaluated at p.
Return type:float