fiasco icon indicating copy to clipboard operation
fiasco copied to clipboard

Use `astropy.units.equivalencies.spectral` to compute wavelengths to energies.

Open wtbarnes opened this issue 1 year ago • 1 comments

Many places throughout the package, I convert wavelengths to energies through the formula $hc/\lambda$. Instead, we should be using the spectral equivalency provided by astropy units: https://docs.astropy.org/en/stable/units/equivalencies.html#equivalencies.

The easiest way to do this is probably to search on const.h or const.c and find places where this product is divided by a length.

wtbarnes avatar Sep 30 '24 18:09 wtbarnes

Might need to be careful if this is used for any spectral emissions. The intensity of some emission process $I(\lambda) \neq I(E)$. Instead, $I(\lambda) d\lambda = - I(E) dE$, so there's an extra factor $\frac{dE}{d\lambda} = - \frac{hc}{\lambda^2}$.

This gets me every single time I convert spectra between wavelength and energy space (X-rays). Can / Does astropy deal with this automatically?

jwreep avatar Oct 02 '24 02:10 jwreep