ACCarnall / bagpipes

Bagpipes is a state of the art code for generating realistic model galaxy spectra and fitting these to spectroscopic and photometric observations. Users should install with pip, not by cloning the repository.
http://bagpipes.readthedocs.io
GNU General Public License v3.0
78 stars 41 forks source link

Iyer (2019) non-parametric SFH prior #91

Open AinaSo opened 6 days ago

AinaSo commented 6 days ago

Hi. I'm trying to use iyer sfh but I have issues to do this. I have put the prior distribution as follows:

iyer = {}                          
iyer["sfr"] = (1 ,10)            
iyer["bins"] = 5            
iyer["bins_prior"] = "dirichlet" 
iyer["alpha"] = 1
iyer["massformed"] =  (1., 15.)  
iyer["metallicity"] = (0., 2.5)     

fit_instructions = {} 
fit_instructions["redshift"] = 0 
fit_instructions["iyer"] = iyer

The fitting process is completed, but it does not provide us with any useful output.

Is the prior distribution placed wrong?

Thank you.

ACCarnall commented 6 days ago

Hi there,

I believe the issue here is probably specifying redshift = 0. This causes the output models to be generated in different units, which probably are not compatible with your data. See this section of the documentation: https://bagpipes.readthedocs.io/en/latest/model_galaxies.html#note-on-units-at-redshift-zero

Cheers, Adam

AinaSo commented 6 days ago

Thank you for your swift response. Then I put fit_instructions["redshift"] = 2, but it didn't work well...

The error message is as follows (excerpt):

packages/bagpipes/models/star_formation_history.py:125): RuntimeWarning: divide by zero encountered in log10
  self.stellar_mass = np.log10(np.sum(self.live_frac_grid*self.ceh.grid))
packages/bagpipes/models/star_formation_history.py:126): RuntimeWarning: divide by zero encountered in log10
  self.formed_mass = np.log10(np.sum(self.ceh.grid))

ValueError: zero-size array to reduction operation minimum which has no identity

Posterior percentiles are shown. However, a figure is not plotted.

ACCarnall commented 6 days ago

Hmm, is this the same error you were getting at redshift zero? I don't see anything obviously wrong with what you're doing from the information you've given me. Please could you tell me what version of bagpipes and what version of dense_basis you're using? The bagpipes routine hasn't been updated for a long time, so it's possible that it's not compatible with the most recent version of dense_basis. Any more information you can provide about your specific circumstances would be useful, e.g., what data are you trying to fit, what else have you tried, what else is in your fit_instructions dictionary, what do your standard bagpipes output plots look like.

AinaSo commented 5 days ago

This is the same error as redshift zero. The version of bagpipes is 1.1.1. But what is dense_basis? That's the first I've heard of it. Is this (https://dense-basis.readthedocs.io/en/latest/usage/installation.html)? Is this necessary? 

Now, it works well with parametric SFH models. I get the above error when I change the SFH model to Iyer (2019).

ACCarnall commented 5 days ago

Yes, this SFH model requires Kartheik Iyer's dense basis code. Hopefully this is the issue, though I'd have expected to see a more informative error message. I'd also recommend updating to bagpipes 1.2.0.

AinaSo commented 4 days ago

I got it. Thank you very much.

Though I installed “dense_basis”, I’m unsure where I should change to use the iyer non-parametric model in the code with bagpipes…

ACCarnall commented 9 hours ago

You shouldn't need to change anything, bagpipes should load up dense_basis and use it automatically, as long as import dense_basis works for you in a python terminal.