bd-j / prospector

Python code for Stellar Population Inference from Spectra and SEDs
http://prospect.readthedocs.io
MIT License
159 stars 75 forks source link

Fit looks good but parameters are odd. #271

Closed LydiaMak closed 5 months ago

LydiaMak commented 1 year ago

I am fitting an SED and although my fit looks good the parameters are oddly distributed (especially tage) and MCMC results look odd. I keep in general the initial parameters and priors as default except

    model_params["lumdist"] = {"N": 1, "isfree": False, "init": ldist, "units":"Mpc"}
    # Let's make some changes to initial values appropriate for our objects and data
    #model_params["zred"]["init"] = 0.0
    #model_params["dust2"]["init"] = 0.05
    #model_params["logzsol"]["init"] = -0.5
    model_params["tage"]["init"] = 13.
    model_params["mass"]["init"] = 1e9

    # These are dwarf galaxies, so lets also adjust the metallicity prior,
    # the tau parameter upward, and the mass prior downward
    #model_params["dust2"]["prior"] = priors.TopHat(mini=0.0, maxi=2.0)
    #model_params["tau"]["prior"] = priors.LogUniform(mini=1e-1, maxi=1e2)
    model_params["mass"]["prior"] = priors.LogUniform(mini=1e8, maxi=1e12)

corner tracers

bd-j commented 1 year ago

That chain does not look converged. You could try running it for longer, or try the dynesty sampler.

LydiaMak commented 1 year ago

corner tracers The example before was also setting both ldist and redshift in run_params. If I set only the ldist and also give the prior of mass like that

model_params["mass"]["prior"] = priors.LogUniform(mini=1e8, maxi=1e12)

I got the attached results. Is it wrong to set both?

However, what really bothers me is the tage which doesn't make sense at all. Is it necessary to give a

model_params["tage"]["disp_floor"]?

LydiaMak commented 1 year ago

There is something odd happening with the initial parameters after running optimization or emcee and instead of initial tage = 13 the initial tage is 1.1 for example. Not sure why this is happening.

bd-j commented 1 year ago

The chain for mass does not look converged, and is taking a long time to diffuse in the parameter space. I suspect this is to do with the initial width of the set of walkers in this parameter. I suggest increasing disp_floor dramatically, and/or cross-checking using dynesty.

Re lumdist and zred, if you set both then the distance modulus will come from lumdit but the spectrum will be shifted in wavelength by 1+zred before projecting the filters. Sometimes this is the right thing to do (e.g. if you have narrow filters and the object is decoupled from the hubble flow, such that the luminosity distance is not directly related to the redshift)

Why do you think the tage value does not make sense? Is this a very red, quiescent galaxy? For parametric (tau, delay tau) SFHs the value of tage need not actually have anything to do with the actual age of the universe, it just describes the last significant SF event. See e.g. Leja et al 2019 or Carnall et al 2019

LydiaMak commented 1 year ago

Ok, I will try the thing about mass.

The galaxy is probably a post-starburst galaxy from spectrum. g-r ~ 0.68. From the interactive demo notebook I thought tage is the age of the galaxy but I guess it's more in the sense of stellar populations?

LydiaMak commented 1 year ago

For dynesty using these

model_params = TemplateLibrary["parametric_sfh"]

model_params["dust2"]["init"] = 0.1
model_params["logzsol"]["init"] = -0.3
model_params["tage"]["init"] = 13.
model_params["mass"]["init"] = 1e8

model_params["dust2"]["prior"] = priors.TopHat(mini=0.0, maxi=2.0)
model_params["tau"]["prior"] = priors.LogUniform(mini=1e-1, maxi=10)
model_params["mass"]["prior"] = priors.LogUniform(mini=1e6, maxi=1e10)

I get the attached. dynesty_corner dynesty_tracers

bd-j commented 1 year ago

That seems largely consistent with the emcee results (though I still suggest increasing disp_floor for stellar mass). Noticing that dust2 is hitting the upper prior edge, do you expect this to be a very dusty galaxy?

bd-j commented 1 year ago

oh wait, if it's a post-starburst I'm not sure you're going to get good/believable fits with a parametric SFH.....

LydiaMak commented 1 year ago

It has been used before in such cases but I have seen non-parametric used as well. Should I try a non-parametric one better (but there are many options)?

Also, no, I don't think it should be that dusty. And metallicity result seems strange.

LydiaMak commented 1 year ago

Ok. I think I figured the main issue. It was on the photometry I was using mostly for SDSS where I was not using the CModel photometry as I should. I will get back with the results once I confirm that everything is correct for 2MASS and WISE.

LydiaMak commented 1 year ago

Ok, I think the results make much more sense now. corner tracers

bd-j commented 1 year ago

great, though it does seem like you are bmping up against an upper prior limit for stellar mass, you may want to increase the prior range.

LydiaMak commented 1 year ago

Yes, I will close the issue for now and if something comes up I will re-open it! Thank you for all your help!

LydiaMak commented 1 year ago

Reopening the issue as something strange is happening. Just by changing the prior limits for the mass from 10^6-10^10 to 10^6-10^11 gives me this very strange result

tracers_^11

Same happens for Dynesty.

bd-j commented 1 year ago

you have a few stuck walkers, you can reinitialize with starting parameters closer the bulk of the walkers, or you can run longer till they become unstuck. It's stochastic though, so it might not always happen. You can also try dynesty again.