BDNYC / sedkit

Spectral energy distribution construction and analysis tools
MIT License
16 stars 13 forks source link

Jy Conversions #75

Closed graceparkk closed 1 year ago

graceparkk commented 2 years ago

Hi! I've downloaded the new SEDkit and used Jy as the units for flux; however, I found that it has wrong conversions. With u.Jy, I get this plot. bokeh_plot (10)

Without using u.Jy and using this conversion, the SED plot seems to be right.

unit_flux1 = flux1*u.Jy.to(u.erg/u.s/u.cm**2/u.AA, equivalencies=u.spectral_density(wl1*u.micron))
unit_unc1 = eflux1*u.Jy.to(u.erg/u.s/u.cm**2/u.AA, equivalencies=u.spectral_density(wl1*u.micron))
sed.add_spectrum(spectrum=[wl1*u.micron, unit_flux1*u.erg/u.s/u.cm**2/u.AA, unit_unc1*u.erg/u.s/u.cm**2/u.AA])

bokeh_plot (11)

I think that it's the problem with converting Jy wrong.

hover2pi commented 2 years ago

Thanks for the issue @graceparkk ! I think I know what the problem is. I'll fix it ASAP.

hover2pi commented 2 years ago

It's hard to debug this without the data. Your figures aren't comparing apples to apples here. The first plot has no WISE photometry and shows the potential problem for sure. However, your second plot does have WISE mags so the code is normalizing the spectrum to that. Can you make the second plot again but don't add the WISE photometry?

I'm going to incorporate astropy.units to do the conversion and then write some explicit verification tests to make sure the conversion is right in the next release. Thanks!

graceparkk commented 2 years ago

bokeh_plot (2) bokeh_plot (3) I've added the WISE photometries for both plots, but I still get a difference in the SED plots. The upper one is using u.Jy and the lower one is the one I've manually converted using the code I mentioned above. Before the new release, I will continue using the manual conversions. Thank you for your help!