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

Reproducing the best fit when nebular_marginalization is used #314

Open
themiyan opened this issue Jan 11, 2024 · 5 comments
Open

Reproducing the best fit when nebular_marginalization is used #314

themiyan opened this issue Jan 11, 2024 · 5 comments
Labels

Comments

@themiyan
Copy link

What is the best way to reproduce the best-fit spectrum when nebular_marginalization template is turned on?

As in the fig below, the stored best-fit does not have any fitted lines, even when a higher resolution model is regenerated using out_model.mean_model and removing all lsf effects.

Screenshot 2024-01-12 at 09 24 25
The model is :::::::
<class 'prospect.models.sedmodel.SedModel'>

Free Parameters: (name: prior) 
-----------
  logzsol: <class 'prospect.models.priors.TopHat'>(mini=-2.5,maxi=0.5)
  dust2: <class 'prospect.models.priors.TopHat'>(mini=0.0,maxi=4.0)
  logmass: <class 'prospect.models.priors.TopHat'>(mini=7,maxi=12)
  logsfr_ratios: <class 'prospect.models.priors.StudentT'>(mean=[0. 0. 0. 0. 0. 0.],scale=[0.3 0.3 0.3 0.3 0.3 0.3],df=[2. 2. 2. 2. 2. 2.])
  gas_logu: <class 'prospect.models.priors.TopHat'>(mini=-4,maxi=-1)
  eline_sigma: <class 'prospect.models.priors.TopHat'>(mini=100,maxi=3000)

Fixed Parameters: (name: value [, depends_on]) 
-----------
  zred: [3.80731707] 
  mass: [1000000.] <function logsfr_ratios_to_masses at 0x176072440>
  sfh: [0.] 
  imf_type: [2] 
  dust_type: [2.] 
  agebins: [[0.         7.4772    ]
 [7.4772     8.        ]
 [8.         8.28719685]
 [8.28719685 8.5743937 ]
 [8.5743937  8.86159054]
 [8.86159054 9.14878739]
 [9.14878739 9.21936847]] 
  add_neb_emission: [ True] 
  add_neb_continuum: [ True] 
  nebemlineinspec: [False] 
  gas_logz: [0.] <function stellar_logzsol at 0x13e52ba30>
  smoothtype: ['lsf'] 
  fftsmooth: [ True] 
  sigma_smooth: [None] 
  marginalize_elines: [ True] 
  use_eline_prior: [ True] 
  elines_to_fit: ['Ba-beta 4861' '[O III] 4959' '[O III] 5007' '[N II] 6548'
 'Ba-alpha 6563' '[N II] 6584'] 
  eline_prior_width: [0.2] 

I don't think the fitted lines are being accurate here, the eline_sigma comes out ~ 100km/s which is incorrect for the above spectrum, but even the high-R reconstruction doesn't show any reconstructed lines there.

@themiyan
Copy link
Author

Just to followup, if I use the nebular templates (no special line marginalisation template) then the emission lines are seen as expected (because nebemlineinspec==True). However, for strong AGN like sources here it is better to fit lines independently of the cloudy grids as Ben's paper suggests.

Screenshot 2024-01-12 at 09 30 01

It makes sense because thenebemlineinspec is turned off when fitting lines outside of the available grids, but then the best-fit should incoporate the gaussian fits right?

@iandroberts
Copy link

I am wondering the same thing as @themiyan , was this ever answered?

@bd-j
Copy link
Owner

bd-j commented Jul 5, 2024

Hi, it looks to me like the marginalization is not happening for some reason, or is not properly fitting the emission line amplitudes even when nebemlineinspec is False. I suggest setting use_eline_prior to False to avoid using the cloudy grid predictions at all. Also make sure you are using the most recent release of prospector (1.3.0)

@themiyan
Copy link
Author

Still no luck. Played around moving some params and not smoothing the spectrum to keep it simple.

Marginalisation is still happening over the lines I think, the attached corner plot shows this (however, the values are way off which is a separate problem).
uds_0_1720591893_mcmc_corner.pdf

Even with the narrower lines the best-fit should show the lines right? At the moment as you see the emission lines in the observed spectrum (in black) is not being reproduced in the saved best fit.

Screenshot 2024-07-10 at 17 00 24

params:

Free Parameters: (name: prior)
-----------
  logzsol: <class 'prospect.models.priors.TopHat'>(mini=-2.5,maxi=0.5)
  dust2: <class 'prospect.models.priors.TopHat'>(mini=0.0,maxi=4.0)
  logmass: <class 'prospect.models.priors.TopHat'>(mini=7,maxi=12)
  logsfr_ratios: <class 'prospect.models.priors.StudentT'>(mean=[0. 0. 0. 0. 0. 0.],scale=[0.3 0.3 0.3 0.3 0.3 0.3],df=[2. 2. 2. 2. 2. 2.])
  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)
  eline_sigma: <class 'prospect.models.priors.TopHat'>(mini=500,maxi=20000)

Fixed Parameters: (name: value [, depends_on])
-----------
  zred: [3.54991568]
  mass: [1000000.] <function logsfr_ratios_to_masses at 0x7f0f1222b6a0>
  sfh: [0.]
  imf_type: [2]
  dust_type: [2.]
  agebins: [[0.         7.4772    ]
 [7.4772     8.        ]
 [8.         8.29609945]
 [8.29609945 8.5921989 ]
 [8.5921989  8.88829835]
 [8.88829835 9.18439779]
 [9.18439779 9.25497887]]
  add_agn_dust: [ True]
  marginalize_elines: [ True]
  use_eline_prior: [False]
  nebemlineinspec: [False]
  elines_to_fit: ['Ba-beta 4861' '[O III] 4959' '[O III] 5007' '[N II] 6548'
 'Ba-alpha 6563' '[N II] 6584' '[S II] 6716' '[S II] 6731']
  eline_prior_width: [0.2]
The model is :::::::
<class 'prospect.models.sedmodel.SedModel'>

@themiyan
Copy link
Author

just to also confirm, v1.4 seems to be the most recent stable release, which I'm using here

In [2]: import prospect

In [3]: prospect.__version__
Out[3]: '1.4.0'

@bd-j bd-j added the bug label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants