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 🛠️
- Download Python: Visit here to install Python
- Download pip: Visit here to install pip
- Run Install Command: Run the command in terminal:
pip install fossyl
Manual Installation
- Download Python: Visit here to install Python
- Download pip: Visit here to install pip
- Downloading fossyl: Download the latest version of fossyl in the "Releases" tab of the Github page
- pip Packages: Go into the directory of fossyl and run the command:
pip install -r requirements.txt
⚙️ Using fossyl ⚙️
How to Use h5grid
- 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. - Ensure that model spectra are assigned as: column 1 (wavelength) and column 2 (flux)
- Assign the relavent variables as described below.
- 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.
-
Required Variables:
-
model_directory: File path/name to your model spectra: string:
- example:
/Desktop/spectra/test.csv
- example:
-
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)']
- example:
-
output_file: File path/name of output file: string:
- example:
/models/test
- example:
-
-
Optional Variables:
- wavelength_region: The wavelength region saved for each spectrum: list
- example:
[0, 10], default=[0, np.inf]
- example:
- wavelength_region: The wavelength region saved for each spectrum: list
How to Use mcfit
- Ensure that your model is compiled into a h5 file using
h5grid - Ensure that the observed spectra are assigned as: column 1 (wavelength), column 2 (flux), and column 3 (uncertainty)
- Once fossyl is successfully imported, define the relevant variables as shown below. Ensure that all required variables are formatted correctly.
- 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.
-
Required Variables:
-
input_file: File path/name to your input spectrum: string:
- example:
/Desktop/spectra/test.csv
- example:
-
output_file: File path/name of output file: string: (do not include file type)
- example:
/Output/test
- example:
-
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
- example:
-
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
- example:
-
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]
- example:
-
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))]
- example:
-
walkers: Number of walkers for emcee calculation: int
- example:
25, default=15
- example:
-
steps: Number of max steps for emcee calculation: int: May be cutoff before this as a result of auto-correlation
- example:
15000, default=1000
- example:
-
rv_fit: Whether a radial velocity is fit: boolean
- example:
True, default=False
- example:
-
monitor: Whether a monitoring step figure is displayed every 1000 steps: boolean
- example:
True, default=False
- example:
-
save_output: Whether the output tables and figures are saved: boolean
- example:
True, default=True
- example:
-
📞 Support & Development Team 📞
- Mr. Hunter Brooks
- Email: hcb98@nau.edu
📖 Acknowledgments 📖
-
If you intend to publish any calculations done by fossyl, please reference Brooks et al. (in prep.).
-
Please reference the relavent model citation.
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
851ec5f7b2edfc55ad162e0a9992b685f515ee708d7d28105d0c1fbb5b973804
|
|
| MD5 |
b45f8da5ab64aa8dd6eae1d02286a025
|
|
| BLAKE2b-256 |
702a65210b1809b97e5ffe1deba33202d8956b7e8eb6b2ccc0afaee1f2a9f83c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fdd1c25e0d7d93aa773c268bbe6e3bfe0ad85ba79694f61f992a54a9e06c66d
|
|
| MD5 |
bee15ee5671218c9da15afe680d01288
|
|
| BLAKE2b-256 |
2bd244f6b5cd4fcaca30e109ffaea80bb080627cc5b96f26c1b44aa27db279bb
|