Skip to content

Commit

Permalink
Cube Build fix if no valid data on array (#8001)
Browse files Browse the repository at this point in the history
Co-authored-by: Howard Bushouse <[email protected]>
  • Loading branch information
jemorrison and hbushouse committed Nov 21, 2023
1 parent feb13d6 commit 7611a4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ background
- Ensure that WFSS background mask does not leave only
pixels with DO_NOT_USE flagged. [#8070]

cube_build
----------

- Fix bug that was causing cube_build to crash when no valid data is found
on the detector in the input image(s). [#8001]

documentation
-------------

Expand Down
10 changes: 6 additions & 4 deletions jwst/cube_build/ifu_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,8 @@ def map_detector_to_outputframe(self, this_par1,
weight_det = None
softrad_det = None
scalerad_det = None
x_det = None
y_det = None

if self.instrument == 'MIRI':
sky_result = self.map_miri_pixel_to_sky(input_model, this_par1, subtract_background)
Expand Down Expand Up @@ -1576,7 +1578,7 @@ def map_detector_to_outputframe(self, this_par1,

return coord1, coord2, corner_coord, wave, dwave, flux, err, \
slice_no, rois_det, roiw_det, weight_det, \
softrad_det, scalerad_det
softrad_det, scalerad_det, x_det, y_det

# good data holds the location of pixels we want to map to cube
# define variables as numpy arrays (numba needs this defined)
Expand All @@ -1593,8 +1595,8 @@ def map_detector_to_outputframe(self, this_par1,
err[:] = err_all[good_data]
wave[:] = wave_all[good_data]
slice_no[:] = slice_no_all[good_data]
x_all = x_all[good_data]
y_all = y_all[good_data]
x_det = x_all[good_data]
y_det = y_all[good_data]

log.debug(f'After removing pixels based on criteria min and max wave: {np.min(wave)}, {np.max(wave)}')

Expand Down Expand Up @@ -1680,7 +1682,7 @@ def map_detector_to_outputframe(self, this_par1,
corner_coord = [xi1, eta1, xi2, eta2, xi3, eta3, xi4, eta4]
return coord1, coord2, corner_coord, wave, dwave, flux, err, \
slice_no, rois_det, roiw_det, weight_det, \
softrad_det, scalerad_det, x_all, y_all
softrad_det, scalerad_det, x_det, y_det
# ______________________________________________________________________

def map_miri_pixel_to_sky(self, input_model, this_par1, subtract_background):
Expand Down

0 comments on commit 7611a4c

Please sign in to comment.