-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversion between wavelength and frequency giving discrepant results #159
Comments
Interesting. This could be affecting my NIRCam flux calibration values (although for my purposes 2.5% uncertainty is probably fine). I'll be following this to see what comes of it. And I'll try something similar for NIRCam tomorrow to see if I find any differences. |
In IRAF SYNPHOT, it only allowed calculation in PHOTLAM or FLAM. I vaguely remember encountering this problem of applying |
Like Tyler and I discussed offline, the formula for |
To add to the excitement, if you convert >>> sflux.to(u.Jy, u.spectral_density(svega_obs.effective_wavelength()))
<Quantity 3209.37237987 Jy> |
That I'm not too surprised about because it's probably having to assume something about the spectral shape when it does that, rather than directly measuring it from the spectrum. Detail about the input spectrum has been lost. |
So, after some attempts at calculus, I arrived at this formula for calculating
Hence, the following attempt at calculating >>> from synphot import units
>>> nu = svega_obs.binset.to(u.Hz, u.spectral())
>>> fac = -1 * units.C * units.C / (nu * nu * nu)
>>> fac
<Quantity [-3.33564095e-10, -3.34565789e-10, -3.35569485e-10, ...,
-4.43731687e-07, -4.43852738e-07, -4.43973811e-07] Angstrom2 / (Hz3 s2)>
>>> influx = svega_obs(nu, flux_unit=u.Jy) # F_nu * P_nu
>>> num = np.trapz(influx * fac, x=nu)
>>> den = np.trapz(fac * sband(nu), x=nu)
>>> effstim_jy = num / den # Theoretical effstim calculated in freq space
>>> effstim_jy
<Quantity 3251.4387289 Jy>
>>> effstim_jy - sflux_jy # yay?
<Quantity -0.00152408 Jy> Based on this, I would like to say that |
More thoughts here: https://gist.github.com/pllim/ddbe9f0c4bdeb920b0501215fb583c72 Would be interested to hear what you think of this, @tddesjardins and @bhilbert4 . |
What you say in the gist makes sense to me. Somewhere in |
I think this was a nice check and indicates that |
Maybe it's time to give pysynphot a gold watch and congratulate it on its retirement? :) |
And just for completeness, |
So... Should we close this issue? |
If we're confident that |
Done at spacetelescope/pysynphot#96 |
After further investigation by @tddesjardins and Susana Deustua, it turns out the bug is in >>> import pysynphot as S
>>> sp_pysyn = S.Vega
>>> bp_pysyn = S.ObsBandpass('acs,wfc1,f555w')
>>> obs_pysyn = S.Observation(sp_pysyn, bp_pysyn)
>>> obs_pysyn.effstim('flam')
3.786643843663875e-09
>>> obs_pysyn.effstim('fnu')
3.630073134871726e-20 >>> from astropy import constants as const
>>> import synphot
>>> import stsynphot
>>> sp_stsyn = stsynphot.Vega
>>> bp_stsyn = stsynphot.band('acs,wfc1,f555w')
>>> obs_stsyn = synphot.Observation(sp_stsyn, bp_stsyn, binset=bp_stsyn.binset)
>>> obs_stsyn.effstim('flam')
<Quantity 3.78664384e-09 FLAM>
>>> obs_stsyn.effstim('fnu') # Wrong
<Quantity 3.60801141e-20 FNU>
>>> w = bp_stsyn.pivot()
>>> # According to Susana, this one is the correct way and agree with Pysynphot
>>> (obs_stsyn.effstim('flam') * w * w / const.c.cgs).to(synphot.units.FNU)
<Quantity 3.63007313e-20 FNU> |
Might also have discrepancies with p.s. I'll post a Gist of my findings once I can understand more. |
See #166 (the promised Gist is also linked over there). |
I now think there are bugs on both sides... 🤣 😭 spacetelescope/pysynphot#103 |
Conclusion: Susana derived effstim and a few other properties from the first principles. From discussions with @deustua and @tddesjardins today, the following is the correct way to fix this:
When Susana publishes her work, it will be mentioned in the doc of this package as a reference. |
Testing some synthetic photometry on Vega, I'm getting different results between
pysynphot
andsynphot
. I've verified that bothpysynphot
andsynphot
are using the same Vega spectrum and the bandpass ("acs,wfc1,f606w") is using the same files and plotting the filter throughput curves they look identical.I've done this several different ways now, and find the following differences compared to the
pysynphot
result:Changing the obsmode (trying ACS/WFC1 F435W, F606W, F814W, and WFC3/UVIS1 F218W, F814W) gives varying results but the frequency-based values are seemingly always off by ~1-2.5% (except ABmag, which has jumped between 2–28%).
Unless I'm doing something wrong with the my commands for calculating the flux in each unit (do I need to do an extra step when using frequency-based units?), then it seems like there's something wrong with the conversion between wavelength and frequency in one of the two packages, but it's not clear which one. @pllim suggested opening this issue on the
synphot
repo so that it can be investigated (and also suggested @bhilbert4 might be interested).The text was updated successfully, but these errors were encountered: