Skip to main content

MCMC Tool for Spectral Model Fitting

Project description


🦴 fossyl 🦴

fossyl is a package designed to efficiently run Markov-Chain Monte-Carlo simulations using the emcee package. It uses a Radial Basis Function Interpolator to perform efficient interpolation. The algorithm is streamlined for ease of use, requiring only four input variables to run simulations on any spectral model calculated on a grid. However, additional input variables are available for more customization and control. This software supports both regular and irregular grids, making it versatile and adaptable to various modeling scenarios. An example jupyter notebook for using fossyl is provided. Where fossyl outputs: a step figure for each parameter, the best fit spectra alongside your input spectra with a corner plot to the right, and a h5 file with the walker data.

🛠️ Installation 🛠️

pip Installation
  1. Download Python: Visit here to install Python
  2. Download pip: Visit here to install pip
  3. Run Install Command: Run the command in terminal:
    pip install fossyl
    

Manual Installation

  1. Download Python: Visit here to install Python
  2. Download pip: Visit here to install pip
  3. Downloading fossyl: Download the latest version of fossyl in the "Releases" tab of the Github page
  4. pip Packages: Go into the directory of fossyl and run the command:
    pip install -r requirements.txt
    

⚙️ Using fossyl ⚙️

How to Use h5grid

  1. After fossyl is installed, verify the installation by running the following command: from fossyl.h5grid import *. If you encounter any issues during installation, please reach out to Hunter Brooks for assistance.
  2. Ensure that model spectra are assigned as: column 1 (wavelength) and column 2 (flux)
  3. Assign the relavent variables as described below.
  4. To compile code, execute the command: h5grid(model_directory, model_parm, output_h5). These are the minimum required parameters for fossyl to run. You can include optional variables if needed.
Relavent Variables For h5grid
  • Required Variables:

    • model_directory: File path/name to your model spectra: string:

      • example: /Desktop/spectra/test.csv
    • model_parameters: Model parameter names: list: (must be in order that the paramters are in the file name)

      • example: ['Teff', 'log(g)', '[M/H]', 'C/O', 'log(Kzz)']
    • output_file: File path/name of output file: string:

      • example: /models/test
  • Optional Variables:

    • wavelength_region: The wavelength region saved for each spectrum: list
      • example: [0, 10], default=[0, np.inf]

How to Use mcfit

  1. Ensure that your model is compiled into a h5 file using h5grid
  2. Ensure that the observed spectra are assigned as: column 1 (wavelength), column 2 (flux), and column 3 (uncertainty)
  3. Once fossyl is successfully imported, define the relevant variables as shown below. Ensure that all required variables are formatted correctly.
  4. To run the Markov-Chain Monte-Carlo simulation, execute the command: mcmcfit(input_file, output_file, h5_directory, model_parm). These are the minimum required parameters for fossyl to run. You can include optional variables if needed.
Relavent Variables For mcfit
  • Required Variables:

    • input_file: File path/name to your input spectrum: string:

      • example: /Desktop/spectra/test.csv
    • output_file: File path/name of output file: string: (do not include file type)

      • example: /Output/test
    • h5_directory: Directory name to model spectra h5 file: string: (ensure no numbers are included in path name outside of numbers in model file name)

      • example: /Desktop/model/LOWZ.h5
    • model_parm: Model parameter names: list: (must be the exact name used in h5 file)

    • example code: ['Teff', 'log(g)', '[M/H]', 'C/O', 'log(Kzz)']

  • Optional Variables:

    • grid_scale: Number of grid points around best grid point in each dimension: int

      • example: 50, default=10
    • unit_wave: Astropy units of the observed and model wavelength units: list: (first index is observed, second index is model)

      • example: [u.um, u.um], default=[u.um, u.um]
    • unit_flux: Astropy units of the observed and model flux units: list: (first index is observed, second index is model)

      • example: [u.Jy, (u.erg / (u.cm**2 * u.s * u.um))], default=[(u.erg / (u.cm**2 * u.s * u.um)), (u.erg / (u.cm**2 * u.s * u.um))]
    • walkers: Number of walkers for emcee calculation: int

      • example: 25, default=15
    • steps: Number of max steps for emcee calculation: int: May be cutoff before this as a result of auto-correlation

      • example: 15000, default=1000
    • rv_fit: Whether a radial velocity is fit: boolean

      • example: True, default=False
    • monitor: Whether a monitoring step figure is displayed every 1000 steps: boolean

      • example: True, default=False
    • save_output: Whether the output tables and figures are saved: boolean

      • example: True, default=True

📞 Support & Development Team 📞

📖 Acknowledgments 📖

  1. If you intend to publish any calculations done by fossyl, please reference Brooks et al. (in prep.).

  2. Please reference the relavent model citation.

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

fossyl-0.6.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

fossyl-0.6.2-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file fossyl-0.6.2.tar.gz.

File metadata

  • Download URL: fossyl-0.6.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for fossyl-0.6.2.tar.gz
Algorithm Hash digest
SHA256 851ec5f7b2edfc55ad162e0a9992b685f515ee708d7d28105d0c1fbb5b973804
MD5 b45f8da5ab64aa8dd6eae1d02286a025
BLAKE2b-256 702a65210b1809b97e5ffe1deba33202d8956b7e8eb6b2ccc0afaee1f2a9f83c

See more details on using hashes here.

File details

Details for the file fossyl-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: fossyl-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for fossyl-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8fdd1c25e0d7d93aa773c268bbe6e3bfe0ad85ba79694f61f992a54a9e06c66d
MD5 bee15ee5671218c9da15afe680d01288
BLAKE2b-256 2bd244f6b5cd4fcaca30e109ffaea80bb080627cc5b96f26c1b44aa27db279bb

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