Conditional normalizing flows for emulating grids of stellar models
Project description
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 experiments require the grid of models here and the trained conditional normalizing flows (CNFdwarf, CNFgiant, and CNFasfgrid) here. Unzip these files into the main folder. The grid is optional, but necessary to visualize comparisons with its emulation.
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 usingarviz.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 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
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 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
TO-DO
- Batch version of
Emulator.sample() - Support for other grids
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelflows-0.0.2.tar.gz.
File metadata
- Download URL: modelflows-0.0.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d01c68690b1af7c9c135980ffb93f1f115e0fda3fe0d9f4b0879362d8693c31
|
|
| MD5 |
924ab2f8eda79bf6830468878d3916a8
|
|
| BLAKE2b-256 |
568a38722a38c4297ec7271c54ed4dbcbc9de77007b2f10e67eb9817e826a4f4
|
File details
Details for the file modelflows-0.0.2-py3-none-any.whl.
File metadata
- Download URL: modelflows-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d004fc6e8a8b92a7879fd717c986806293a452b4c11739308a3d1e48f48711d5
|
|
| MD5 |
cb3fe1534854923e654d654693dbb63f
|
|
| BLAKE2b-256 |
6fb929401a6d520797f6b64567d7c80537b557c9c01980b10b0171069739af69
|