Skip to main content

normalising Flow exoPlanet Parameter Inference Toolkyt

Project description

This is a code to perform retrievals on spectra of substellar objects using SNPE-C (citation) and neural spline flows (citation).

  • Known issues:
    • Requires python<3.13 and numpy<2:

      conda create -n name python==3.12

Basic usage:

  • First, import FlopPITy:
from floppity import Retrieval
from floppity.simulators import read_ARCiS_input, ARCiS
  • Now you can initialize the retrieval class with a simulator. A python wrapper for ARCiS comes built-in (you need to install ARCiS on your own tho):
R = Retrieval(ARCiS)
  • Read in observations and define parameters to retrieve:
R.get_obs(['path/to/obs_0', 'path/to/obs_1',..., 'path/to/obs_n'])
    
R.add_parameter(par_0, min, max)
R.add_parameter(par_1, min, max)
...
R.add_parameter(par_m, min, max)
  • 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
  • For retrievals using ARCiS, the input file and output directory need to be passed in a dictionary:
ARCiS_kwargs= dict(
                    input_file = arcis_input,
                    output_dir = 'path/to/output',
                  )
  • You can now run the retrieval, indicating the number of rounds and samples per round:
R.run_retrieval(n_rounds=10, n_samples=1000, simulator_kwargs=ARCiS_kwargs)
  • Great! You can now inspect your posterior:
fig = R.plot_corner()

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[0] contains PRISM spectra and simulated[1] contains MIRI/LRS spectra):

def simulator(obs, parameters, **kwargs):
    wvl_0 = obs[0][:,0]
    wvl_1 = obs[1][:,0]
    ...
    wvl_n = obs[n][:,0]

    spectra={}
    spectra[0] = # array of shape (ndims, len(wvl_0))
    spectra[1] = # array of shape (ndims, len(wvl_1))
    ...
    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.0.3.tar.gz (4.0 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.0.3-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for floppity-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5153f22e5ce4111542a06d8e422d2a51d3ed7b6dc29bb63c463498f23c2c5ee9
MD5 786dcc285226f1de7c8a2f8c9d2a1e6f
BLAKE2b-256 5e35a03908c37927b17bc572b656107f6d33d2c19a4f8b341b6fa2d5045c67b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: floppity-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 58.4 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 98c61fac9a6afb200e186ebe16407646b43c6cdd78f7a14fb823644a5dbd1dcd
MD5 9fcb282501161ab586d9ef5f2d371c65
BLAKE2b-256 5fb4ba3eca90bd38e024130d7850b4696feab3080ff8a17b596c4514b7a7cdeb

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