spacetelescope / synphot_refactor

Synthetic photometry using Astropy
http://synphot.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
39 stars 25 forks source link

Have synphot Observation be able to work directly on specutils.Spectrum1D #244

Closed eteq closed 4 years ago

eteq commented 4 years ago

This would be a follow-on to #243 . Since one of the core work-flows of synphot is to be able to do synthetic photometry on spectra, it seems to me like it would make sense to tie Observation closer together with the bridge in #243. More specifically, The following is what I'm suggesting be made to work:

spec1d = specutils.Spectrum1d.load('/some/file')

Vbp = SourceSpectrum('johnson_v')
obs = Observation(spec1d, Vbp)
obs.countrate(u.ABmag)

The idea would be that this be implemented pretty transparently by just having the Observation recognize Spectrum1D and call the method from the #243. But we don't want to have this force a specutils dependency where one isn't necessary. So we could use duck-typing - E.g., something like this could go in Observation:

def __init__(self, spec, ...):
    if hasattr(spec, 'flux') and hasattr(spec, 'spectral_axis'):
        spec = SourceSpectrum.from_spectrum1D(spec)
...

that would allow the work flow I said above without requiring an explicit specutils dependency.

pllim commented 4 years ago

Do you only need this for the SourceSpectrum component or do you also want this for the bandpass?