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.
A pip-installable package modelflows is available in Python 3. Run the following
pip install modelflowsFirst, 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 usingarviz.plot_posterior: Displays a corner plot of the posterior distribution.
samples provides a num_posterior_samples. The last column represents sample likelihoods, while the first Emulator.labels provides the identity of each column.
asfgrid is defined only for stars with evstate=-1),
lower RGB stars with evstate=0), upper RGB stars with 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 Kteff_err: Effective temperature uncertainty in Kdnu: Asteroseismic large frequency separation in uHzdnu_err: Asteroseismic large frequency separation uncertainty in uHznumax: Asteroseismic frequency at maximum power in uHznumax_err: Asteroseismic frequency at maximum power uncertainty in uHzfeh: Iron abundance in dexfeh_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).
cnfgiant is defined only for hydrogen shell-burning stars with
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 Kteff_err: Effective temperature uncertainty in Kdnu: Asteroseismic large frequency separation in uHzdnu_err: Asteroseismic large frequency separation uncertainty in uHzd02: Asteroseismic small frequency separation in uHzd02_err: Asteroseismic small frequency separation uncertainty in uHznumax: Asteroseismic frequency at maximum power in uHznumax_err: Asteroseismic frequency at maximum power uncertainty in uHzfeh: Iron abundance in dexfeh_err: Iron abundance uncertainty in dexlum: Bolometric stellar luminosity in units of solar luminositylum_err: Bolometric stellar luminosity uncertainty in units of solar luminosity
- Batch version of
Emulator.sample() - Support for other grids

