Closed LydiaMak closed 1 month ago
Hi @LydiaMak the commit referenced in the dev version number above (g0a5e85e) does not seem to exist in the propsector repo, so I'm not sure what version of the code you are working with, and I'm not sure what could have caused this new issue if the code did not change. Also v1.2, which appears to be the base version you have, is a bit older.
Given the demo(?) it looks like you are trying to run, I suggest installing the released v1.4.0 from PyPI, unless you have specific reasons not to.
python -m pip uninstall astro-prospector
python -m pip install astro-prospector==1.4
python -c "import prospect; print(prospect.__version__)"
Please let me know if issues persist after v1.4.0 is installed.
I also suggest switching from SedModel
to SpecModel
for the model object, as SedModel
is deprecated, and will be removed in v2.0
from prospect.models import SpecModel
model = SpecModel(model_params)
I changed both but still got the same values.
I believe that the issue is in this lines
current_parameters = ",".join([f"{p}={v}" for p, v in zip(model.free_params, model.theta)])
because probably of the five bins for the fraction but for some reason it's not assigned correctly now.
logzsol=-0.5,dust2=0.6,z_fraction=0.8333333333333334,total_mass=0.8,duste_umin=0.75,duste_qpah=0.6666666666666666,duste_gamma=0.5,fagn=10000000000.0,agn_tau=1.0,dust_ratio=4.0,dust_index=0.001
fagn cannot be that large this should be the mass I gave.
Am I right?
What's the proper way to do it?
Ah no. Actually I don't think this plays any role since this should be fine
spec, phot, mfrac = model.predict(model.theta, obs=obs, sps=sps)
An additional comment is that for continuity_sfh I get a good fit. Not sure what changed for alpha.
Hi @LydiaMak, have you compared the output of print(model)
for both continuity_sfh (which works) and alpha (which doesn't)? Assuming the rest of the code has not changed, I would guess there's some difference in the free or fixed parameters that is causing this issue.
I cannot really see a difference causing this issue
For alpha
<class 'prospect.models.sedmodel.SpecModel'>
Free Parameters: (name: prior)
-----------
logzsol: <class 'prospect.models.priors.TopHat'>(mini=-2,maxi=0.19)
dust2: <class 'prospect.models.priors.TopHat'>(mini=0.0,maxi=4.0)
z_fraction: <class 'prospect.models.priors.Beta'>(mini=0.0,maxi=1.0,alpha=[5 4 3 2 1],beta=[1 1 1 1 1])
total_mass: <class 'prospect.models.priors.LogUniform'>(mini=100000000.0,maxi=1000000000000.0)
duste_umin: <class 'prospect.models.priors.TopHat'>(mini=0.1,maxi=25)
duste_qpah: <class 'prospect.models.priors.TopHat'>(mini=0.5,maxi=7.0)
duste_gamma: <class 'prospect.models.priors.LogUniform'>(mini=0.001,maxi=0.15)
fagn: <class 'prospect.models.priors.LogUniform'>(mini=1e-05,maxi=3.0)
agn_tau: <class 'prospect.models.priors.LogUniform'>(mini=5.0,maxi=150.0)
dust_ratio: <class 'prospect.models.priors.ClippedNormal'>(mean=1.0,sigma=0.3,mini=0.0,maxi=2.0)
dust_index: <class 'prospect.models.priors.TopHat'>(mini=-2.0,maxi=0.5)
Fixed Parameters: (name: value [, depends_on])
-----------
zred: [0.0284]
mass: [1.] <function zfrac_to_masses at 0x177c02820>
sfh: [3]
imf_type: [2]
dust_type: [4]
agebins: [[ 0. 8. ]
[ 8. 8.47712125]
[ 8.47712125 9. ]
[ 9. 9.47712125]
[ 9.47712125 9.77815125]
[ 9.77815125 10.13353891]]
add_dust_emission: [ True]
add_neb_emission: [ True]
add_neb_continuum: [ True]
nebemlineinspec: [ True]
gas_logz: [0.] <function stellar_logzsol at 0x141ff3a60>
gas_logu: [-2.]
add_agn_dust: [False]
dust1: [0.] <function dustratio_to_dust1 at 0x177c023a0>
and for continuity_sfh
Free Parameters: (name: prior)
-----------
logzsol: <class 'prospect.models.priors.TopHat'>(mini=-2,maxi=0.19)
dust2: <class 'prospect.models.priors.TopHat'>(mini=0.0,maxi=2.0)
logmass: <class 'prospect.models.priors.TopHat'>(mini=7,maxi=12)
logsfr_ratios: <class 'prospect.models.priors.StudentT'>(mean=[0. 0. 0. 0. 0.],scale=[0.3 0.3 0.3 0.3 0.3],df=[2 2 2 2 2])
Fixed Parameters: (name: value [, depends_on])
-----------
zred: [0.0284]
mass: [1000000.] <function logsfr_ratios_to_masses at 0x17863db80>
sfh: [3]
imf_type: [2]
dust_type: [0]
agebins: [[ 0. 8.]
[ 8. 9.]
[ 9. 10.]]
Thanks for these details. The models are pretty different, with the latter model not including nenbular emission, etc.
Can you post a gist of the full code leading to the unexpected result? Also, can you let me know your fsps version (python -c "import fsps; print(fsps.__version__)"
)? Thanks!
The fsps version is this fsps: 0.4.3.dev7+g8ae9b1f (same used for continuity_sfh).
The code I run after building the obs and model as described in the initial post is:
current_parameters = ",".join([f"{p}={v}" for p, v in zip(model.free_params, model.theta)])
print(current_parameters)
spec, phot, mfrac = model.predict(model.theta, obs=obs, sps=sps)
print(phot / obs["maggies"])
which returns very small values for phot. Same happens when running dynesty properly.
Removing nebular emission fixed the issue.
ok, I'm a little surprised by that, but glad it's working. I suggest upgrading to fsps v0.4.7 when you get a chance.
Hi
I have an issue I didn't have before with the same version (I believe i.e. 1.2.1.dev17+g0a5e85e). I build the observations like that
Then I use the alpha model
and
Which eventually for
returns values of 1e-68.
I am not sure what happened. Any ideas?