-
Notifications
You must be signed in to change notification settings - Fork 73
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
Odd mean_model() and sps behavior #223
Comments
Oh, that's usettling! My guess is that there's a FSPS model parameter in |
That could be it....does the fact that dust_type changes between models impact anything (I assumed that loading the different models would keep that from being an issue?). Here's the model params:
|
It looks like the only difference in the names of the parameters being supplied is the extra So this is something more insidious, probably still something with improperly caching or updating parameter state. What versions of prospector and python-fsps are you using? Also, can you check |
Prospector is a pretty old version (commit ac89a74) as well as python-fsps (commit 6cb5769). It doesn't appear to just be the first ratio that's problematic, but rather all of them. Setting Looking through And after kcm: And then after calm: One noticeable thing is that |
The unchanged import numpy as np
from sedpy.observate import load_filters
import prospect
from prospect.models.templates import TemplateLibrary
from prospect.utils.obsutils import fix_obs
def build_sps(zcontinuous=1, compute_vega_mags=False, **extras):
from prospect.sources import FastStepBasis
sps = FastStepBasis(zcontinuous=zcontinuous,
compute_vega_mags=compute_vega_mags)
return sps
def build_model(dust_type=2):
from prospect.models import SpecModel, templates
model_params = templates.TemplateLibrary["continuity_sfh"]
model_params["dust_type"] = dict(init=dust_type, isfree=False, N=1)
return SpecModel(model_params)
if __name__ == "__main__":
# dummy obs dictionary
filters = load_filters([f"sdss_{b}0" for b in "ugriz"])
nf = len(filters)
obs = dict(filters=filters, maggies=np.ones(nf), maggies_unc=np.ones(nf)*0.1,
spec=None, wavelength=None)
obs = fix_obs(obs)
# build the SPS
sps = build_sps()
print(sps.ssp.params["dust_type"])
# predict with dust_type=2
m2 = build_model(dust_type=2)
assert m2.params["dust_type"] == 2
p2 = m2.predict(m2.theta, obs=obs, sps=sps)
assert m2.params["dust_type"] == 2
assert sps.ssp.params["dust_type"] == 2
# predict with dust_type=4
m4 = build_model(dust_type=4)
assert m4.params["dust_type"] == 4
p4 = m4.predict(m4.theta, obs=obs, sps=sps)
assert m4.params["dust_type"] == 4
assert sps.ssp.params["dust_type"] == 4
# check m2 didn't change and the predictions were different
assert m2.params["dust_type"] == 2
assert np.all(p4[1] != p2[1]) |
Yeah, none of these asserts fail for the simple test. And I actually can't reproduce the above |
Sorry, so the issue still persists when iterating over the entire sample? Does it make sense to add asserts inside the loop and see when exactly they fail? |
Sorry for the delay -- I was banging up against trying to reproduce the first instance of the dust_type issue with |
ok, thanks. I'm not sure there's a good way to guard against this in general, since resetting |
In generating 'best-fit' SEDs for 3 different prospector models, I have discovered odd behavior when doing several mean_model() calls. In short, I am using 3 different attenuation curve models and generating the model SEDs for ~500 galaxies, and when the sps() object is loaded once, the model SEDs generated are much different than if the sps() object is loaded between each model call (even though the 3 models are using the same sps/SFH object). In testing, I've found that I can only recreate this behavior if generating SEDs for ~200-300 galaxies, i.e., I don't see the same behavior for 1 galaxy or a test fsps sp fit. I'll attach some (incomplete) code snippets showing the main jist of how I get the model SEDs:
The plots below show the median SED residuals for each model (the first model above corresponds to the purple line in the plots and the second model the orange). Reloading the sps object the second time produces the second plot whereas loading it the first time only produces the first plot. Any ideas about why this occurs?
The text was updated successfully, but these errors were encountered: