Skip to content

Units when using CCD components (bandpass should support units) #36

@martinjohndyer

Description

@martinjohndyer

Hi there, I've come across these modules and I'm glad to see a new version of Synphot that integrates with Astropy. I wasn't quite sure where to post this but since it's instrument-related I hope here is the right place.

I think I've come across a major issue with how this module uses Astropy units. In short it assumes that every component file doesn’t have units associated with it (i.e. it's just throughput). But that's not true in every case, specifically if you include CCD component files (which contain a quantum efficiency curve in units of electrons/photon) or "DN" component files (which just contain a flat gain value in units of counts/electron).

For example, with the the following obsmode I'd expect the resulting Observation to be in electrons not photons because it includes a QE component (wfc3_uvis_ccd1_003_syn.fits).

import synphot as S
import stsynphot as STS
vega = STS.Vega()
bp = STS.band('wfc3,uvis1,f218w')
obs = S.Observation(v, bp)
obs.binflux ## shows units are PHOTLAM (photons/sec/cm2/AA), not e-/sec/cm2/AA

Likewise including the dn keyword in WFC3 obsmodes should result in the final units being in counts, because it includes the gain value given in fc3_uvis_dn_002_syn.fits.

A lot of the documentation reads as if this is being done correctly. http://stsynphot.readthedocs.io/en/latest/stsynphot/appendixb_inflight.html#wfc3 says

By default, stsynphot reports the raw count rate in electrons if the dn keyword is not specified, or data numbers otherwise.

That's now incorrect because the rates in both cases will be in photons as demonstrated above. The values are right (as far as I know), but the units are wrong. This wasn't such a problem with the previous versions because values were just numbers, and you could work out what units they should have. But now all the calculations use and return Astropy Quantitys, which means this is now an issue because you get results with the wrong units.

I think to fix this you'd need to be able to separate out the component files that require units from the unitless transmission functions like filter throughputs. Unfortunately from what I can see the CRDS files seem to just not include this information, all the columns are labelled as having units of THROUGHPUT. But if you could then it might be possible to add something into ObservationSpectralElement that accounts for changes in units?

@pllim Do you think this is worth investigating? I was working on some code for our telescope using Pysynphot when I came across this version and I do like what it does, but this problem makes it harder to make the argument for switching.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions