Getting started#

Before you start, make sure you have all of the required inputs and any of the optional inputs.

Required Inputs#

  • Radial (l=0) mode frequencies, \(\nu\)

  • Frequency of maximum power, \(\nu_\max\), and its uncertainty

  • Large frequency separation, \(\Delta\nu\), and its uncertainty

Optional Inputs#

  • Uncertainty on the mode frequencies, \(\sigma_\nu\)

  • Effective temperature of the star, \(T_\mathrm{eff}\)

  • Asymptotic frequency offset/phase, \(\epsilon\), and its uncertainty

Example#

Firstly, define your inputs, for example:

# Prior data
# Location and scale (mean and standard deviation) of a normal distribution
nu_max = (2357.69, 25.0)
delta_nu = (111.84, 0.1)
teff = (5500.0, 200.0)

# Observed data
n = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
nu = [1601.25, 1712.38, 1822.87, 1932.24,
      2042.3 , 2153.48, 2265.2 , 2377.14,
      2488.87, 2601.02, 2713.51, 2826.4 ,
      2939.56, 3052.67]
nu_err = 0.01  # Can be a scalar or a value for each nu

Then, import Asterion and create the model. Pass prior parameters to the model,

from asterion import GlitchModel

model = GlitchModel(nu_max, delta_nu, teff=teff)

Start inference. It is good practice to inspect the prior predictive check that it is sensible. You can do this using Asterion’s plotting functions with the group="prior" keyword argument.

import asterion as ast
from asterion import Inference

infer = Inference(model, n=n, nu=nu, nu_err=nu_err, seed=10)
infer.prior_predictive()  # <-- check prior is sensible
prior_data = infer.get_data()
# Inspect the prior predictive e.g.
ast.plot_glitch(prior_data, group="prior")

If the plot looks wrong, make changes to the prior or model (refer to the API Reference). Once you are happy with the prior, sample from the posterior and inspect the posterior predictive.

# Sample from the posterior
infer.sample()
infer.posterior_predictive()

# Save inference data
data = infer.get_data()
data.to_netcdf("results.nc")  # save inference data as a netCDF4 file

You can use Asterion to make plots with the data and summarise in your favourite format (so long as it’s either Pandas or Astropy).

import matplotlib.pyplot as plt

# Posterior predictive check
# Glitch plots
ast.plot_glitch(data, kind="He")
ast.plot_glitch(data, kind="CZ")

# Echelle plots
ast.plot_echelle(data)
ast.plot_echelle(data, kind="glitchless")

# A corner plot of the helium glitch parameters
print(ast.get_var_names(data))  # <-- to view available variable names in the model
ast.plot_corner(data, var_names=["log_a_he", "log_b_he", "log_tau_he", "phi_he"])

# Save summary of results, e.g.
# Here all 0-dimensional parameters are saved in Astropy's ECSV format which
# preserves data types and units
table = ast.get_table(data, dims=(), fmt="astropy")
table.write("data/summary.ecsv", overwrite=True)

plt.show()  # <-- to display the plots

You can load the inference data using Arviz like so,

import arviz as az
data = az.from_netcdf("results.nc")

See the tutorials or for a more in-depth example.

Notes#

  • Variable names with the prefix 'log_' are base-10 logarithmic

  • The seed argument in GlitchModel is used to sample from the prior on \(\tau\) and should not affect inference.

  • The seed argument in Inference is used for reproducibility and should not affect inference, but it is recommend you confirm this for yourself.