spacetelescope / synphot_refactor

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

Does the effstim method take into account filter bandwidth? #369

Open dan-adi opened 9 months ago

dan-adi commented 9 months ago

Description

I am computing the counts from an extended source and the general equation includes the filter bandwidth. I don't know if the effstim method in Observation Class already includes the filter bandwidth when computing flux. Need to know so I don't apply the same operation twice.

Here is a test example:

# get zero point for V filter and peakLambda for V filter
def zeroPoint_V():
    vegaSpectra = SourceSpectrum.from_vega()
    Vfilter = SpectralElement.from_filter('johnson_v')
    peakLambda = Vfilter.wpeak()
    obs = Observation(vegaSpectra, Vfilter)
    zero_point_flux_V = obs.effstim(flux_unit='flam')

    return zero_point_flux_V, peakLambda

# get flux from mag
def starflux(mag, zeroPointFlux):

    f = zeroPointFlux * 10 ** (-.4 * mag)

    return f.to(u.W / (u.m**2 * u.nm))

# get photon energy at peakLambda
def photonEnergy(peakLambda):
    h = const.h
    c = const.c
    E = (h * c) / peakLambda.to(u.meter)
    E_convert = E.to(u.watt * u.s)

    return E_convert

# counts for extended object
def counts(flux, photonE, filterBandwidth,aperture,pixelSurface, QE):

    targetPhotons = QE * flux/photonE * filterBandwidth * aperture * pixelSurface
    return targetPhotons

parameters

zp = zeroPoint_V()[0]
flux = starflux(22.9, zp)
pe = photonEnergy(zeroPoint_V()[1])
filterBandwidth = 80.7 * u.nm
QE = 0.8
aperture = 2 * u.m**2
pixelSurface =  0.3 # is image scale**2, where image scale = 0.15 arcsec/pixel
c = counts(flux, pe, filterBandwidth,aperture,pixelSurface, QE)
print(np.round(c,0))

Thank you

System Details (optional)

pllim commented 9 months ago

I think so? You can look at the actual implementation here:

https://github.com/spacetelescope/synphot_refactor/blob/fa521a909785cb47ffcef4cbc661c00224bd3638/synphot/observation.py#L424

Not sure what all your code is doing there. Theoretically, you can normalize your source first if you want, pass that and the bandpass into Observation, and it should give you count rate, so all that extra conversion seems unnecessary.

Hopefully these help: