Skip to content

Normalizing Flows for the Emulation of Grids of Stellar Models

License

Notifications You must be signed in to change notification settings

mtyhon/modelflows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modelflows

Normalizing Flows for the Emulation of Grids of Stellar Models

An interactive visualization can be found here.

A description of the emulator can be found in the paper, which is under review. Experiments in the paper are described in the notebooks found in this repo, which can be downloaded and ran locally.

The trained conditional normalizing flows (CNFgiant and CNFasfgrid) are presented here, though the code downloads them automatically if not already present.

To run the visualization notebooks involving main sequence models, you will require the CNFdwarf emulator, whose checkpoint is presented here, and grid is presented here. Following the notebooks, the checkpoint should be placed in the FLOW_DIR directory, whereas the grid should be placed in the /grid/ subdirectory.

If you are simply interested in the sampling the emulator to infer stellar parameters, see the following.

Getting Started

A pip-installable package modelflows is available in Python 3. Run the following

pip install modelflows

Sampling From Grids of Stellar Models

First, import and initialize an Emulator instance.

import modelflows as mf

emu = mf.Emulator(grid='asfgrid')

Currently supported grids are asfgrid and cnfgiant. If this is the first time creating an Emulator instance for a particular grid, the normalizing flow model will be downloaded to a local folder on your machine.

To sample from the emulator, first define a dictionary of observations. An example is as follows:

obs = {
    'teff':     4728.,
    'teff_err': 80.,
    'dnu':      4.311,
    'dnu_err':  0.013,
    'numax':    41.39,
    'numax_err':0.54,
    'feh':      -0.15,
    'feh_err':  0.15
}

Then pass the dictionary to Emulator.sample() as follows:

samples = emu.sample(
    num_posterior_samples=5000,
    batch_sample_size=100000,
    observations=obs,
    evstate=0,
    calc_intervals=True,
    plot_posterior=True
)

The use of a CUDA-capable GPU is highly recommended. The displayed arguments for Emulator.sample() are the following:

  • num_posterior_samples: Number of unique draws of a grid parameter (set to age) to build the posterior distribution. Recommended at least 1000.
  • batch_sample_size: Number of draws from the normalizing flow per iteration. These will need to fit in memory per iteration, so scale accordingly.
  • observations: Dictionary of observations.
  • calc_intervals: Prints highest density intervals of the posterior distribution using arviz.
  • plot_posterior: Displays a corner plot of the posterior distribution.

Example posterior corner plot from the asfgrid emulation

Accessing samples

samples provides a $N \times D + 1$ vector, where $N$ is the number of samples drawn from Sampling/Importance Resampling in the process of achieving num_posterior_samples. The last column represents sample likelihoods, while the first $D$ dimensions corresponds to posterior samples. Emulator.labels provides the identity of each column.

Supported observables for the asfgrid grid

asfgrid is defined only for stars with $0.6M_{\odot}\leq M\leq5.5M_{\odot}$ for hydrogen shell-burning (RGB) subgiant stars with $\nu_{\mathrm{max}} \geq 300\mu\text{Hz}$ (evstate=-1), lower RGB stars with $10 \mu\text{Hz} \leq \nu_{\mathrm{max}} < 300 \mu\text{Hz}$ (evstate=0), upper RGB stars with $\nu_{\mathrm{max}} < 10\mu\text{Hz}$ (evstate=1), and core helium-burning (HeB) stars (evstate=2).

Note that evstate is a keyword argument to Emulator.sample().

The following are observables that can be present in the dictionary of observations. Not all observables have to be specified for a given query. However, any given measurement must be accompanied by an uncertainty (e.g., teff with teff_err).

  • teff: Effective temperature in K
  • teff_err: Effective temperature uncertainty in K
  • dnu: Asteroseismic large frequency separation in uHz
  • dnu_err: Asteroseismic large frequency separation uncertainty in uHz
  • numax: Asteroseismic frequency at maximum power in uHz
  • numax_err: Asteroseismic frequency at maximum power uncertainty in uHz
  • feh: Iron abundance in dex
  • feh_err: Iron abundance uncertainty in dex

If you find asfgrid results useful for your research, please consider also citing Sharma et al. (2016) and Stello & Sharma (2022).

Supported observables for the cnfgiant grid

cnfgiant is defined only for hydrogen shell-burning stars with $0.7M_{\odot}\leq M\leq2.5M_{\odot}$ (i.e., on the red giant branch).

The following are observables that can be present in the dictionary of observations. Not all observables have to be specified for a given query. However, any given measurement must be accompanied by an uncertainty (e.g., teff with teff_err).

  • teff: Effective temperature in K
  • teff_err: Effective temperature uncertainty in K
  • dnu: Asteroseismic large frequency separation in uHz
  • dnu_err: Asteroseismic large frequency separation uncertainty in uHz
  • d02: Asteroseismic small frequency separation in uHz
  • d02_err: Asteroseismic small frequency separation uncertainty in uHz
  • numax: Asteroseismic frequency at maximum power in uHz
  • numax_err: Asteroseismic frequency at maximum power uncertainty in uHz
  • feh: Iron abundance in dex
  • feh_err: Iron abundance uncertainty in dex
  • lum: Bolometric stellar luminosity in units of solar luminosity
  • lum_err: Bolometric stellar luminosity uncertainty in units of solar luminosity

TO-DO

  • Batch version of Emulator.sample()
  • Support for other grids

About

Normalizing Flows for the Emulation of Grids of Stellar Models

Resources

License

Stars

Watchers

Forks

Packages

No packages published