Code Monkey home page Code Monkey logo

dense_basis's Introduction

Dense Basis SED fitting

An implementation of the Dense Basis method tailored to SED fitting, in particular, to the task of recovering accurate star formation history (SFH) information from galaxy spectral energy distributions (SEDs). The current code is being adapted from its original use-case (simultaneously fitting specific large catalogs of galaxies) to being a general purpose SED fitting code and acting as a module to compress and decompress SFHs.

As such, it is currently in an beta phase, where existing modules are being improved upon and crash-tested and thorough documentation is being written. If you are interested in using, testing or extending the repository, please shoot me an email.

Installation and usage:

To use the package, clone the repository and run python setup.py install within the dense_basis folder. More detailed intstructions can be found at dense-basis.readthedocs.io.

Documentation on usage and basic tutorials can also be found at dense-basis.readthedocs.io.

A good place to get started is here.

References:

Contact:

Changelog

v.0.1.8

  • added plotting functions in the SedFit() class for posterior spectra and SFHs
  • added the dynamic_decoupling flag for the sSFR priors, which automatically sets the timescale on which SFR decoupling occurs (if invoked) to scale with redshift.
  • fixed a bug in the 'sSFRlognormal' sampling of the priors.
  • added parallelization using MultiPool from schwimmbad.
  • pregrid generation can now be parallelized using the generate_atlas_in_parallel_zgrid() command.
  • changed the default value of decouple_sfr_time in tuple_to_sfh() to avoid a low-z error

v.0.1.7

  • added arguments in makespec() to return spectra splined to an input wavelength array
  • added dynamic_norm argument to sed fitter (calculates free norm during fitting for better accuracy, but slower)

v.0.1.6

  • added a class for the SED fitter
  • added the plot_atlas_priors() function
  • overhauled atlas generation with the makespec() function for self-consistency
  • added some bugfixes to the gp_sfh module for high sSFR values

v.0.1.5

  • added basic MCMC support with emcee in the main repo instead of dense_basis_toolbelt

v.0.1.4

  • The FSPS/python-FSPS requirement is no longer necessary, if a user requires only the GP-SFH module.
  • added more options to SFR sampling - flat in SFR, sSFR or lognormal in sSFR. removed the separate sample_sSFR_prior option
  • added option for tx_alpha sampling from IllustrisTNG (0<z<6, Nparam<10)
  • removed the squeeze_tx option - this can be effectively implemented with a larger value for the concentration parameter
  • implemented rough mass-metallicity prior
  • implemented flat and exponential dust priors for the Calzetti law, and a rough implementaion of the CF00 law using priors from Pacifici+16
  • removed sample_all_params_safesSFR, and the safedraw=True in make_N_prior_draws
  • removed the min SFR in the sample_sfh_tuple function
  • updated the GP tuple_to_sfh module to decouple SFR if necessary.
  • overhauled the generate_atlas() and load_atlas() functions,
  • shifted storage of precomputed pregrids/atlas(es) from scipy.io to hickle

dense_basis's People

Contributors

kartheikiyer avatar kmlgould avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dense_basis's Issues

Missing 'make_spec' in dense_basis

In Dense_Basis_Standalone.ipynb, I hit a traceback at
_, sfr_true, mstar_true = db.make_spec(rand_sfh_tuple, rand_Z, rand_Av, rand_z, return_ms = True)

module 'dense_basis' has no attribute 'make_spec'

Installation - python requiremement

Dependences page on rtd says that code is written in Python 3.7, but running the installation with that version of Python fails at scipy RuntimeError: Python version >= 3.8 required..

Running the installation in Python 3.8 works.

about AttributeError: 'NoneType' object has no attribute 'params'

Hi Kartheik,

Thank you very much for sharing this code. I am trying to learn how to use it follow the example here: https://dense-basis.readthedocs.io/en/latest/tutorials/getting_started.html, and got stuck in this step:

fname = 'test_atlas'
N_pregrid = 1000
priors.Nparam = 3
db.generate_atlas(N_pregrid = N_pregrid,priors = priors, fname = fname, store=True,filter_list = filter_list, filt_dir = filt_dir)

Here are the message I got. Could you help me about this issue?


AttributeError Traceback (most recent call last)
in ()
4
5 db.generate_atlas(N_pregrid = N_pregrid,priors = priors,fname = fname,
----> 6 store=True,filter_list = filter_list, filt_dir = filt_dir)
7

~/anaconda3/lib/python3.6/site-packages/dense_basis-0.1.4-py3.6.egg/dense_basis/pre_grid.py in generate_atlas(N_pregrid, priors, initial_seed, store, filter_list, filt_dir, norm_method, z_step, sp, cosmology, fname, path)
302 Nparam = priors.Nparam
303 rand_sfh_tuple, rand_Z, rand_Av, rand_z = priors.sample_all_params_safesSFR(random_seed = initial_seed)
--> 304 _, lam = make_spec(rand_sfh_tuple, rand_Z, rand_Av, rand_z, igmval = True, return_lam = True, sp = mocksp, cosmology = cosmo)
305
306 fc_zgrid = np.arange(priors.z_min-z_step, priors.z_max+z_step, z_step)

~/anaconda3/lib/python3.6/site-packages/dense_basis-0.1.4-py3.6.egg/dense_basis/pre_grid.py in make_spec(sfh_tuple, metval, dustval, zval, igmval, return_lam, return_ms, sp, cosmology)
66 """
67
---> 68 sp.params['add_igm_absorption'] = igmval
69 sp.params['zred'] = zval
70 sfh, timeax = tuple_to_sfh(sfh_tuple, zval = zval)

AttributeError: 'NoneType' object has no attribute 'params'

Versions of site-packages needed to install fsps + dense basis

Hi!

Just to make note of it here for future reference/others as of 11/17/22!

For a conda environment running python 3.8, I updated the following site-packages in order to run fsps and dense basis correctly:

  1. numpy -- 1.23.1
  2. scipy -- 1.9.1
  3. astropy -- 5.1

Insufficient requirements

requirements.txt file or install_requires statement in setup.py does not seem to include all packages that are called when importing dense_basis. This results in having to manually install dependent packages one by one when importing dense_basis in Python. Having complete requirements correctly documented/packaged on PyPI would greatly help users. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.