SED fitting library suitable for single or multiple stars
You can install sed_fit is as a pip package. Simply run the following within the context of your own base or custom python virtual environment:
$ pip install git+https://github.com/SteveOv/sed_fitThis will install the fitter module, the pre-built stellar grids and any required support libraries. With this setup you will be able to perform both minimize fitting and mcmc sampling of SED observations against the pre-built stellar grids.
While the binary_sed_fit.ipynb jupyter page is not installed as part of the package, it can be viewed directly on GitHub where it offers a useful tutorial on using the fitter and model grids.
Alternatively you can set up the entire code base, which has been developed within a Python3 virtual environment supporting Python 3.9-3.12, matplotlib, astropy, astroquery, lightkurve, emcee, and the custom deblib package upon which the code is dependent. The dependencies are documented in the requirements.txt file.
Having first cloned this GitHub repo, open a Terminal at the root of the local repo and run the following commands. First to create and activate the venv;
$ python -m venv .sed_fit
$ source .sed_fit/bin/activateThen run the following to set up the required packages:
$ pip install -r requirements.txtYou may need to install the jupyter kernel in the new venv if you wish to run binary_sed_fit.ipynb:
$ ipython kernel install --user --name=.sed_fitTo set up an sed_fit conda environment, from the root of the local repo run the
following command;
$ conda env create -f environment.yamlYou will need to activate the environment whenever you wish to run any of these modules. Use the following command;
$ conda activate sed_fitFirstly, you have my sympathy. Secondly, you may encounter an incompatibility
between emcee and python's multiprocessing pool which can lead to the
following error being raised when an MCMC is run (such as with fit_testing);
NameError: name '_fixed_theta' is not defined
The issue appears to be related to the start method used to create the pool processes, which in this case is not copying over the global state required for the MCMC. The documentation for python in context and start methods states that from python 3.8 on "spawn" is the default start method on MacOS. If you experience the above failure you can switch to the alternative "fork" method with the following code (which resolved the issue for me);
from multiprocessing import set_start_method
set_start_method("fork", force=True)You should run this as early as possible, ideally soon after entering a
if __name__ == "__main__": block. The alternative solution, which comes
at the expense of throughput, is to avoid the use of a pool within mcmc_fit
by setting its processes argument to 1.