Skip to main content

normalising Flow exoPlanet Parameter Inference Toolkyt

Project description

FlopPITy

normalizing Flow exoplanet Parameter Inference Toolkyt

FlopPITy allows the user to easily perform atmospheric retrievals using SNPE-C (citation) and neural spline flows (citation).

Installation guide

Currently FlopPITy doesn't work with python 3.13

$ conda create -n floppity_env python==3.12.9
$ conda activate floppity_env
$ pip install floppity

Basic usage:

  • First, import FlopPITy:
from floppity import Retrieval
  • Now you can initialize the retrieval class with a simulator. A simulator is a function that takes in parameters and returns spectra, look below to see specifically how it needs to be written. Functionality for ARCiS and PICASO comes built-in (you need to install them separately). Look further down for examples.
R = Retrieval(your_simulator_function, 'emis')
  • Read in observations and define parameters to retrieve:
R.get_obs({obs_0:'path/to/obs_0', obs_1:'path/to/obs_1',..., obs_n:np.array(shape=[n_wvl,>3])})
    
R.add_parameter(par_0, min, max)
R.add_parameter(par_1, min, max)
...
R.add_parameter(par_m, min, max)
  • You can now run the retrieval, indicating the number of rounds and samples per round:
R.run(n_rounds=10, n_samples=1000, simulator_kwargs=simulator_kwargs)
  • Great! You can now inspect your posterior:
fig = R.plot_corner()

ARCiS example:

  • Firstly, initialize your retrieval object:
from floppity import Retrieval
from floppity.simulators import read_ARCiS_input, ARCiS

R = Retrieval(ARCiS, 'emis')
  • For ARCiS, the observations and parameters can be read from the ARCiS input file:
pars, obs_list = read_ARCiS_input('path/to/ARCiS/input')
R.get_obs(obs_list)
R.parameters=pars
  • The input file and output directory need to be passed in a dictionary:
ARCiS_kwargs= dict(
                    ARCiS_dir = "/path/to/ARCiS/executable", #only needs to be set if ARCiS is not on the default path
                    input_file = 'path/to/ARCiS/input',
                    output_dir = 'path/to/output',
                  )
  • You can now run the retrieval as usual:
R.run(n_rounds=10, n_samples=1000, simulator_kwargs=ARCiS_kwargs)

PICASO example:

  • Running a retrieval with PICASO is very similar (this only works with the gridtree branch):
from floppity import Retrieval
from floppity.simulators import read_PICASO_config, PICASO

R = Retrieval(PICASO, 'emis')

pars, obs_list = read_PICASO_config('path/to/config.toml')
R.get_obs(obs_list)
R.parameters=pars
  • The configuration file needs to be passed as a kwarg:
PICASO_kwargs= dict(
                    config_file = 'path/to/config.toml'
                  )
  • You can now run the retrieval as usual:
R.run(n_rounds=10, n_samples=1000, simulator_kwargs=PICASO_kwargs)

Writing a simulator

Writing a simulator to work for FlopPITy is relatively straightforward. All that's needed is a function that takes in observations and parameters and returns spectra. The spectra need to be returned in a dictionary where each key represents each of the observations simulated (e.g. simulated['prism'] contains PRISM spectra and simulated['lrs'] contains MIRI/LRS spectra):

def simulator(obs, parameters, **kwargs):
    wvl_prism = obs['prism'][:,0]
    wvl_lrs = obs['lrs'][:,0]
    ...
    wvl_n = obs[n][:,0]

    spectra={}
    spectra['prism'] = # array of shape (ndims, len(wvl_prism))
    spectra['lrs'] = # array of shape (ndims, len(wvl_lrs))
    ...
    spectra[n] = # array of shape (ndims, len(wvl_n))

    return spectra

Advanced options:

  • Additional post processing parameters (currently RV, vrot, offset and scaling) can be added, for example:
R.add_parameter('RV', -100, 100, post_process=True) # km/s

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

floppity-0.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

floppity-0.1-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

Details for the file floppity-0.1.tar.gz.

File metadata

  • Download URL: floppity-0.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for floppity-0.1.tar.gz
Algorithm Hash digest
SHA256 509a8394a26ec7099a2d3c990e65d39e4c99db673bff4b4479da15705b7247e0
MD5 650d89f1cb50aeaf3020cb8de2f02ec4
BLAKE2b-256 4cce2da18ef62e7ea0048e8ce1ef79a20b645001af75817d3a0dcb6d1e1ac62c

See more details on using hashes here.

File details

Details for the file floppity-0.1-py3-none-any.whl.

File metadata

  • Download URL: floppity-0.1-py3-none-any.whl
  • Upload date:
  • Size: 70.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for floppity-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b39aa28fafd282ef38b0a192c193bdf38146a86a8fceb4dfe3e62a82a772b2
MD5 ef43ea66869ddade0fbd8db02c18df8c
BLAKE2b-256 3f39edca1152931a15f3136cb26b729e88e8ffc5109de4baebc6727f153925a4

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