Fix bug in error propagation in exposure differences that results in inflated uncertainties #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a bug in the way that
make_diff_image
propagated the variances when combing the "positive" and "negative" sets of exposures.msaexp/msaexp/slit_combine.py
Lines 872 to 882 in ef48256
The first line
pos = ...
is an average across the science arrays, and thevpos = ...
is supposed to be the propagated variance of this. The denominator of these lines summing over the mask arrays is the numberN
of valid pixels across exposures that are combined together. However, the denominator invpos = ...
andvneg = ...
should beN**2
, where it isN
above!With this bug, the computed variance was then just the "average variance", not the "variance of the average" reduced by a factor
N
from the combination. The result is that the final reported uncertainties of the output spectra are too large by a factorNexp**(1/4)
, whereNexp
is the number of exposures in a group that were combined together (not necessarily the total number of exposures in a particular grating across all groups from, e.g., multiple masks). The extra factor of 2 in this correction relative tosqrt(Nexp)
comes from the fact that one power of N was already included—if thevpos = ...
variances had just been summed without the denominator, the uncertainties would beNexp**(1/2)
too large.For a standard 3-shutter nod pattern with
Nexp=3
, the uncertainties under this bug will be of order3**1/4 ~ 1.3
too high, but it can be larger for larger groups of combined exposures in the deeper programs. For the UNCOVER program, for example,Nexp = 18
in most cases for the groups of exposures for a particular mask, so the uncertainties are too large by a factor18**1/4 ~ 2
.This bug affects all of the public
v2
MSAEXP extractions before the date of this fix (22-Feb-2024), though to some extent, it doesn't directly affect the parameters derived from the spectra since the uncertainties are rescaled anyway in the redshift and line fits.