Git Product home page Git Product logo

asterion's Introduction

Logos

Asterion

Documentation status Build status Issues closed License

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].

Installation

To install, run one of the following.

Latest

pip install git+https://github.com/alexlyttle/asterion@main#egg=asterion

Stable

An official release on PyPI for this package is coming soon...

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.

Contributing

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.

Authors and license

Copyright © 2022, Alexander Lyttle @ University of Birmingham

Licensed under the MIT license

asterion's People

Contributors

actions-user avatar alexlyttle avatar guyrhysdavies avatar

Watchers

 avatar

asterion's Issues

Inference data types

Be consistent with inference data types in Inference class. Validate n, nu and nu_err to make jax.numpy.ndarray.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.