Skip to main content

UCDMCMC

Markov Chain Monte Carlo (MCMC) fitting code for low-temperature stars, brown dwarfs and extrasolar planet spectra, tuned particularly to the near-infrared. This code is continually being updated, so please suggest fixes, features, and/or improvements.

INSTALLATION NOTES

ucdmcmc can be installed from pip:

pip install ucdmcmc

or from git:

git clone https://github.com/aburgasser/ucdmcmc.git
cd ucdmcmc
python -m setup.py install

It is recommended that you install in a conda environment to ensure the dependencies do not conflict with your own installation

conda create -n ucdmcmc python=3.13
conda activate ucdmcmc
pip install ucdmcmc

A check that this worked is that you can import ucdmcmc into python/jupyter noteobook, and that the ucdmcmc.MODEL_FOLDER points to the models folder that was downloaded

ucdmcmc uses the following external packages:

Optionally install SPLAT

To generate new model sets using the built-in generateModels() function, you will need to install SPLAT (note: this is not necessary for the other functionality in this code). SPLAT is not automatically installed on setup. The instructions are essentially the same:

git clone https://github.com/aburgasser/splat.git
cd splat
python -m pip install .

See https://github.com/aburgasser/splat for additional instructions

Models

ucdmcmc comes with a starter set of models that play nicely with the code. An extended set can be downloaded from https://spexarchive.coolstarlab.ucsd.edu/ucdmcmc/. These should be placed in the folder .ucdmcmc_models in your home directory (i.e., /home/adam/.ucdmcmc_models). If it doesn't already exist, this directory will be created on the first call to ucdmcmc. In addition, models that exist on this website and not present in this folder will be downloaded directly when getModelSet()`` is called. You can also generate your own set of models using the generateModels()` function (see note above).

ucdmcmc has been successfully run with the following models:

Additional models are continuously being added, please let us know if there are models you'd like to see included!

Spectra

ucdmcmc comes with a starter set of spectra for the following instruments:

User spectra can be read in using ucdmcmc.Spectrum("filename"). Files can be .fits, .csv, .txt (space-delimited), or .tsv (tab-delimited), and should have wavelength, flux, and uncertainty arrays. You can also read in these files separately and create a Spectrum object using the call ucdmcmc.Spectrum(wave=[wave array,flux=[flux array],noise=[uncertainty array]). See the docstring for ucdmcmc.Spectrum for further details.

Usage

ucdmcmc comes with samples to help you test the code which you can read in with the function ucdmcmc.getSample():

import ucdmcmc
sp = ucdmcmc.getSample('JWST-NIRSPEC-PRISM')
sp.plot()
plot1

Fitting requires reading in a model set; for existing sets specify the model name and the instrument:

models,wave = ucdmcmc.getModelSet('elfowl24','JWST-NIRSPEC-PRISM')

We map our spectrum to the model wave grid, then we can conduct a grid fit to find the single best fitting model using ucdmcmc.fitGrid():

sp.toWavelengths(wave)
par = ucdmcmc.fitGrid(sp,models)

Output:

Best parameters:
	model = elfowl24
	co = 0.5
	kzz = 7.0
	logg = 4.75
	teff = 600.0
	z = -1.0
	scale = 1.616424519232685e-20
	chis = 1290354.449246344
	radius = 0.056390540414855445
	dof = 853.0
	rchi = 1512.7250284247878
plot2

These grid parameters can be used to initiate an MCMC fit using using ucdmcmc.fitMCMC():

npar = ucdmcmc.fitMCMC(sp,models,par,nstep=100,burn=0.25,absolute=True,verbose=False)

Output:

Best parameters:
	model: elfowl24
	co: 0.580211857460554
	kzz: 7.3919278336945515
	logg: 5.365954958490183
	teff: 633.8145781129864
	z: -0.9388765775373868
	scale: 1.328342456515958e-20
	chis: 1328254.9586724846
	radius: 0.05111914351717615
	dof: 848
	rchi: 1512.7250284247878
plot3

(note: it is recommended to run with more than 100 steps!)

You can visualize the parameter distributions using ucdmcmc.plotCorner():

ucdmcmc.plotCorner(npar)
plot4

There are many variations to these fits, as well as secondary parameters (e.g., RV, vsini, line broadening, reddening, etc) that can be explored. Please see the help files associated with the specific functions.

Opacities

[TBD]

Citing the code

If you use this code in your research, publications, or presentations, please include the following citation:

Burgasser, Brooks, Morrissey, Haynes, & Liou (2025). aburgasser/ucdmcmc (vXXX). Zenodo. https://doi.org/10.5281/zenodo.16921710

or in bibtex:

@software{adam_burgasser_2026_16921710,
  author       = {Adam Burgasser and
                  Brooks, Hunter and
                  Morrissey, Sara and
                  Haynes, Julia and
                  Liou, Tiffany},
  title        = {aburgasser/ucdmcmc: vXXXX},
  month        = jan,
  year         = 2026,
  publisher    = {Zenodo},
  version      = {v1.4},
  doi          = {10.5281/zenodo.16921710},
  url          = {https://doi.org/10.5281/zenodo.16921710},
}

where (vXXX) corresponds to the version used.

ucdmcmc and its antecedents has been used in the following publications:

Please let me know if you make use of the code so we can include your publication in the list above!

Metadata

Release files for ucdmcmc 1.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucdmcmc 1.4.5
File Size Uploaded Provenance
ucdmcmc-1.4.5.tar.gz 62.1 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ucdmcmc 1.4.5
File Interpreter ABI Platform
ucdmcmc-1.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 123.5 MB

Release files / ucdmcmc-1.4.5.tar.gz

Download URL ucdmcmc-1.4.5.tar.gz
Size 62.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7533b3dc53bd364daacc85897ffa27ef980f8e103e726e7386d8f36bd3d29f36
BLAKE2b-256 checksum
How to use checksums
6bf3af0071354f15fd88f40a40f26e84427b0926c18a960cab3413d30ec99a0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / ucdmcmc-1.4.5-py3-none-any.whl

Download URL ucdmcmc-1.4.5-py3-none-any.whl
Size 61.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2b3917776fd4986de201034650ce0f110c6372b108a855af6bc432f18388e9cf
BLAKE2b-256 checksum
How to use checksums
c601647d9f9cb42958cd3a5f41d56abc647a36266746a66c749ce8c0ea094cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Security for ucdmcmc 1.4.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ucdmcmc-1.4.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page