bd-j / prospector

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

Reproducing the best fit when `nebular_marginalization` is used #314

Open themiyan opened 5 months ago

themiyan commented 5 months ago

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 commented 5 months ago

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 commented 1 month ago

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

bd-j commented 2 days ago

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)