Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ master_background

- Fix open files bug [#4995]

pathloss
--------
- fix bug in NIRSpec IFU data that causes valid pixel dq flags to set to
NON-SCIENCE in the region of an overlapping bounding box slice [#5047]


pipeline
--------

Expand All @@ -58,6 +64,11 @@ pipeline
- Fix open files bug in ``get_config_from_reference`` class method, and in
``Spec2Pipeline``, ``Spec3Pipeline`` and ``tso3``. [#4995]

photom
------
- fix bug in NIRSpec IFU data that causes valid pixel dq flags to set to
NON-SCIENCE in the region of an overlapping bounding box slice [#5047]

ramp_fitting
------------

Expand Down
9 changes: 4 additions & 5 deletions jwst/pathloss/pathloss.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,11 @@ def do_correction(input_model, pathloss_model):
for slice in NIRSPEC_IFU_SLICES:
slice_wcs = nirspec.nrs_wcs_set_input(input_model, slice)
x, y = wcstools.grid_from_bounding_box(slice_wcs.bounding_box)
xmin = int(x.min())
xmax = int(x.max())
ymin = int(y.min())
ymax = int(y.max())
ra, dec, wavelength = slice_wcs(x, y)
wavelength_array[ymin:ymax+1, xmin:xmax+1] = wavelength
valid = ~np.isnan(wavelength)
x = x[valid]
y = y[valid]
wavelength_array[y.astype(int), x.astype(int)] = wavelength[valid]

# Compute the pathloss 2D correction
if is_pointsource(input_model.meta.target.source_type):
Expand Down
31 changes: 12 additions & 19 deletions jwst/photom/photom.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def calc_nirspec(self, ftab, area_fname):

# Get the conversion factor from the PHOTMJ column
conv_factor = tabdata['photmj']

# Populate the photometry keywords
self.input.meta.photometry.conversion_megajanskys = \
conv_factor
Expand Down Expand Up @@ -234,13 +233,10 @@ def calc_nirspec(self, ftab, area_fname):
# Compute relative sensitivity for each pixel based
# on its wavelength
sens2d = np.interp(wave2d, waves, relresps)

# Include the scalar conversion factor
sens2d *= conv_factor

# Divide by pixel area
sens2d /= area2d

# Reset NON_SCIENCE pixels to 1 in sens2d array and flag
# them in the science data DQ array
where_dq = \
Expand Down Expand Up @@ -541,31 +537,28 @@ def calc_nrs_ifu_sens2d(self, area_data):

# Get the world coords for all pixels in this slice
coords = ifu_wcs(x, y)

# Pull out the wavelengths only
dq = dqmap[y.astype(int),x.astype(int)]
wl = coords[2]
nan_flag = np.isnan(wl)
good_flag = np.logical_not(nan_flag)
if wl[good_flag].max() < microns_100:
# pull out the valid wavelengths and reset other array to not include
# nan values
valid = ~np.isnan(wl)
wl = wl[valid]
dq = dq[valid]
x = x[valid]
y = y[valid]
dq[:] = 0

if wl.max() < microns_100:
log.info("Wavelengths in WCS table appear to be in meters")

# Set NaNs to a harmless value, but don't modify nan_flag.
wl[nan_flag] = 0.

# Mark pixels with no wavelength as non-science
dq = np.zeros_like(wl)
dq[nan_flag] = dqflags.pixel['NON_SCIENCE']
dqmap[y.astype(int), x.astype(int)] = dq

# Insert the wavelength values for this slice into the
# whole image array
wave2d[y.astype(int), x.astype(int)] = wl

# Insert the pixel area value for this slice into the
# whole image array
ar = np.ones_like(wl)
ar[:, :] = area_data[np.where(area_data['slice_id'] == k)]['pixarea'][0]
ar[nan_flag] = 1.
ar[:] = area_data[np.where(area_data['slice_id'] == k)]['pixarea'][0]
area2d[y.astype(int), x.astype(int)] = ar

return wave2d, area2d, dqmap
Expand Down