Note: Development of this project is on hold while I write up my PhD thesis.
Fit acoustic glitches present in the radial mode frequencies of solar-like oscillators.
Do you have some asteroseismic mode frequencies for a particular star? Do you want to fit a model to those modes? You need not look any further because this is the Python package for you. With this package you can fit a model of the glitch in mode frequencies caused by the helium-II ionisation zone and base of the convective zone in the stellar envelope. This model yields posterior estimates for the amplitudes of these glitches, which you can use to study surface helium content [references].
To install, run one of the following.
pip install git+https://github.com/alexlyttle/asterion@main#egg=asterion
An official release on PyPI for this package is coming soon...
Before you start, make sure you have all of the required inputs and any of the optional inputs.
- Radial (l=0) mode frequencies, \nu
- Frequency of maximum power, \nu_\max, and its uncertainty
- Large frequency separation, \Delta\nu, and its uncertainty
- Uncertainty on the mode frequencies, \sigma_\nu
- Effective temperature of the star, T_\mathrm{eff}
- Asymptotic frequency offset/phase, \epsilon, and its uncertainty
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.
- Variable names with the prefix
'log_'
are base-10 logarithmic - The
seed
argument inGlitchModel
is used to sample from the prior on \tau and should not affect inference. - The
seed
argument inInference
is used for reproducibility and should not affect inference, but it is recommend you confirm this for yourself.
If you find an issue with this package, please search for or raise it on GitHub. If you would like to contribute to the package, please find an issue and let us know in the comments, or fork the repository and make a pull request.
Detailed guidance on contributing to Asterion can be found here.
Copyright © 2022, Alexander Lyttle @ University of Birmingham
Licensed under the MIT license