-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use synphot
package to perform bandpass integration
#21
Comments
I noticed that |
Hello and I apologize for any inconvenience. Yes, synphot dropped support for Python 3.9 but only recently via spacetelescope/synphot_refactor#387 . You should still be able to get |
Would be happy to discuss more if you are interested. Integration is nothing too fancy. |
Thanks it should work with Yeah that would be nice! I want to use |
Generally speaking, this would give you a blackbody spectrum (before passing through the bandpass): from astropy import units as u
from synphot import SourceSpectrum
from synphot.models import BlackBodyNorm1D
bb_temp = 5777 * u.K
bb = SourceSpectrum(BlackBodyNorm1D, temperature=bb_temp)
# Sampling frequencies. This samples most of the flux but feel free to extend as needed.
freq = bb.waveset.to(u.Hz, u.spectral())
# Sampled flux
flux_unit = u.MJy
flux = bb(freq, flux_unit=flux_unit) But to put it through bandpass first before sampling, you have to construct an Often times, you might also want to renormalize the source spectrum first to some standard you want before passing it through the bandpass using https://synphot.readthedocs.io/en/latest/api/synphot.spectrum.BaseSourceSpectrum.html#synphot.spectrum.BaseSourceSpectrum.normalize . So a more complete example would be more like this: from astropy import units as u
from synphot import SourceSpectrum, SpectralElement, Observation, units as syn_units
from synphot.models import BlackBodyNorm1D, Box1D
bb_temp = 5777 * u.K
bb = SourceSpectrum(BlackBodyNorm1D, temperature=bb_temp)
# Say, you know it is 17 VEGAMAG in Johnson V filter
vega = SourceSpectrum.from_vega() # For unit conversion
johnson_v = SpectralElement.from_filter('johnson_v')
bb_norm = bb.normalize(17 * syn_units.VEGAMAG, johnson_v, vegaspec=vega)
# Now pass the normalized blackbody into your bandpass. Using box here but there are many available.
bandpass = SpectralElement(Box1D, amplitude=1, x_0=5000 * u.AA, width=10 * u.AA)
obs = Observation(bb_norm, bandpass)
# https://synphot.readthedocs.io/en/latest/synphot/formulae.html#synphot-formula-effstim
effstim = obs.effstim(flux_unit=u.MJy) When it comes to an Observation, usually people want the effective stimulus instead of integration under the curve. Hope this helps! |
Thanks you, that helps! I am still having some trouble... Is this the way to go if I want to bandpass integrate for a range of different blackbodies: bandpass = SpectralElement(Empirical1D, points=frequencies, lookup_table=weights)
for temp in temperatures:
bb = SourceSpectrum(BlackBody1D(temp))
obs = Observation(bb, bandpass)
bp_integrated_emission = obs.integrate() I am also interested in getting the emission in spectral flux density units, so for instance MJy/sr. |
@MetinSa , is that a real bandpass or you are using it to represent something else? If you have a minimal example with just numbers and expected answers, I can see what in |
@pllim yes the Thank you for being so quick and nice to respond:) |
Ahh, I had forgotton to flip the |
Right, for this particular bandpass, but it should be able to handle arbitrary frequency/wavelength ranges and temperatures between ~50-500K |
I don't grok the bandpass normalization, but that doesn't matter. I tried re-constructing what I think you are doing with However, Also, in tracing your calculation, I think you need to get rid of the per-micron in the integrated flux unit (because you already integrated over a range of Hz/micron), so the answer I think should be I hope this helps and thanks for considering |
Also, in numpy 2.0, |
I had the feeling that
Thats a good catch, thanks @pllim! |
Yes, the blackbody model might work too. Good luck! |
from pyOpenSci/software-submission#161:
Instead of manually performing bandpass integrations with the custom
Bandpass
type, we should use the Astropy affiliatedsynphot
package. This would also provide better integration with Astropy.The text was updated successfully, but these errors were encountered: