Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emcee sampling in Prospector #322

Open
elmiio opened this issue Feb 26, 2024 · 8 comments
Open

Emcee sampling in Prospector #322

elmiio opened this issue Feb 26, 2024 · 8 comments

Comments

@elmiio
Copy link

elmiio commented Feb 26, 2024

Hello,

I am trying to fit a model to some spectroscopic data using emcee optimization. I have defined my model with the 'ssp' and 'optimize_speccal' templates, and have four free parameters: redshift (zred), mass, metallicity (logzsol) and age. The minimization (least-squares) fitting executes nicely for all four parameters that I've set to free, as expected. However, when I run emcee, it seems that the redshift parameter gets left out. The sampling occurs only for the mass, metallicity and age parameters, and thus produces a theta vector array that is 3 entries long rather than 4. To confirm that redshift is excluded, the 'chain' key in my emcee results dictionary has a free parameters dimension of 3 (when I believe it should be 4):

Is there a way to fix this? Thanks in advance

@elmiio elmiio changed the title Emcee fitting in Prospector Emcee sampling in Prospector Feb 27, 2024
@bd-j
Copy link
Owner

bd-j commented Mar 12, 2024

can you try dispalying the model before you run your fit? E.g. in your parameter file have the following in the main block.

obs, model, sps, noise = build_all(**run_params)
print(model)
sys.exit()

@elmiio
Copy link
Author

elmiio commented Mar 12, 2024

I can. I get a list of the free parameters in my model (which includes zred), as well as a list of the fixed parameters.

@bd-j
Copy link
Owner

bd-j commented Mar 12, 2024

I don't offhand know of anyway that the free parameters would be turned off in the call to fit_model just after that, and have not encountered that before. Are you doing optimization and sampling in the same run? Can you try just doing --emcee and not optimization to see if the problem persists?

@elmiio
Copy link
Author

elmiio commented Mar 12, 2024

I just ran emcee without optimization and it appears that the problem is persisting. I tried running print(model) immediately after the emcee sampling is finished, and zred still shows up as a free parameter in my model. So, I am not sure exactly where things are going wrong.

@bd-j
Copy link
Owner

bd-j commented Mar 14, 2024

That's really strange, I don't know how that could happen. Have you tried a run with dynesty instead of emcee?

@elmiio
Copy link
Author

elmiio commented Mar 19, 2024

I just did a run with dynesty instead of emcee, and it appears I am having the same issue.

@bd-j
Copy link
Owner

bd-j commented Mar 19, 2024

If you can put together a minimum working example of your parameter file and post it somewhere that might help.

@elmiio
Copy link
Author

elmiio commented Mar 21, 2024

Hello,

Here is a txt file which includes all my code up to the point where I begin having issues (after optimization and emcee sampling):

Modelling_Sandbox.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants