sbird/fake_spectra

Exception is raised for spectra containing highly absorbed systems

Closed this issue · 4 comments

if np.any(corrflux <= 0):

Hello,

I know you (Simeon) have set the line below to avoid having any 0 in the log in the conversion back to tau :

tau[np.where(tau > 700)] = 700

But, I am sure it still fails if we have any absorber with NHI > 10**19.0 . The absorber is just too large that even after smoothing with spec_res we still have some pixels with flux = 0 . Since the spectral resolution smoothing is only needed to be applied to the flux (observable), I suggest to remove this from get_tau(). People can call spec_utils.res_corr() if they need.

sbird commented

You mean just remove:
#Correct for the spectrograph resolution in flux space.
#We need to cap the optical depth to avoid divide-by-zero
if self.spec_res > 0:
tau[np.where(tau > 700)] = 700
corrflux = spec_utils.res_corr(np.exp(-tau), self.dvbin, self.spec_res)
flux = corrflux
if np.any(corrflux <= 0):
raise Exception
tau = - np.log(corrflux)

from get_tau? And then people can do it themselves? That is a good idea, can you send a PR?

Exactly! The whole spc_res convolution in this function. Then people will call spec_utils.res_corr() which works only with flux and is safe.

Sure, I'll send the PR.

sbird commented

That is very sensible, thanks!

Of course. This is the PR : #52