Skip to content

Commit

Permalink
Merge pull request #1883 from pypeit/hotfix_cubevar
Browse files Browse the repository at this point in the history
HOTFIX :: Datacube variance should be squared, not cubed
  • Loading branch information
jhennawi authored Dec 19, 2024
2 parents 0cf0265 + 7dd9394 commit 016fc30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/releases/1.17.2dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Bug Fixes
in both spatial dimensions equal to half the field of view.
- Fix the code for the extraction of the 1D flat spectrum, so that
the spectrum is extracted even when `pixelflat_model` does not exist.

- The variance cube previously had a cubic term, and this has been changed
to a quadratic term. This has been cross-checked with simple subpixel calculations.
2 changes: 1 addition & 1 deletion pypeit/core/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ def subpixellate(output_wcs, bins, sciImg, ivarImg, waveImg, slitid_img_gpm, wgh
vox_coord = vox_coord.reshape(numpix * num_all_subpixels, 3)
# Use the "fast histogram" algorithm, that assumes regular bin spacing
flxcube += histogramdd(vox_coord, bins=outshape, range=binrng, weights=np.repeat(this_sci[this_sl] * this_wght_subpix[this_sl], num_all_subpixels) * subpix_wght)
varcube += histogramdd(vox_coord, bins=outshape, range=binrng, weights=np.repeat(this_var[this_sl] * this_wght_subpix[this_sl]**2, num_all_subpixels) * subpix_wght**3)
varcube += histogramdd(vox_coord, bins=outshape, range=binrng, weights=np.repeat(this_var[this_sl] * this_wght_subpix[this_sl]**2, num_all_subpixels) * subpix_wght**2) # NOTE :: This was changed from subpix_wght**3 to subpix_wght**2 by RJC on 2024-12-18
normcube += histogramdd(vox_coord, bins=outshape, range=binrng, weights=np.repeat(this_wght_subpix[this_sl], num_all_subpixels) * subpix_wght)

# Normalise the datacube and variance cube
Expand Down

0 comments on commit 016fc30

Please sign in to comment.