Skip to main content

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelflows-0.0.2.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelflows-0.0.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

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

Hashes for modelflows-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3d01c68690b1af7c9c135980ffb93f1f115e0fda3fe0d9f4b0879362d8693c31
MD5 924ab2f8eda79bf6830468878d3916a8
BLAKE2b-256 568a38722a38c4297ec7271c54ed4dbcbc9de77007b2f10e67eb9817e826a4f4

See more details on using hashes here.

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

Hashes for modelflows-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d004fc6e8a8b92a7879fd717c986806293a452b4c11739308a3d1e48f48711d5
MD5 cb3fe1534854923e654d654693dbb63f
BLAKE2b-256 6fb929401a6d520797f6b64567d7c80537b557c9c01980b10b0171069739af69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page