Skip to content

Commit

Permalink
Merge branch 'master' into pip_list_after_override
Browse files Browse the repository at this point in the history
  • Loading branch information
hbushouse authored Jun 13, 2023
2 parents da3288a + 3899fb7 commit baad926
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ flat_field

- Refactored NIRSpec 1D flat interpolation for improved performance. [#7550]

- Added log messages for reporting flat reference file(s) used. [#7592]

cube_build
----------

Expand All @@ -71,6 +73,8 @@ other

- Override package dependencies with requirements file when requested [#7557]

- Close files left open in test suite [#7599]

pathloss
--------

Expand Down
1 change: 1 addition & 0 deletions jwst/assign_wcs/nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ def get_open_msa_slits(msa_file, msa_metadata_id, dither_position,
log.warning(message)
message = ("MSA configuration file has more than 1 shutter with primary source")
log.warning(message)
msa_file.close()
raise MSAFileError(message)

# subtract 1 because shutter numbers in the MSA reference file are 1-based.
Expand Down
18 changes: 9 additions & 9 deletions jwst/assign_wcs/tests/test_nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ def test_nirspec_ifu_against_esa(wcs_ifu_grating):
"""
Test Nirspec IFU mode using CV3 reference files.
"""
ref = fits.open(get_file_path('Trace_IFU_Slice_00_SMOS-MOD-G1M-17-5344175105_30192_JLAB88.fits'))
with fits.open(get_file_path('Trace_IFU_Slice_00_SMOS-MOD-G1M-17-5344175105_30192_JLAB88.fits')) as ref:
# Test NRS1
pyw = astwcs.WCS(ref['SLITY1'].header)
# Test evaluating the WCS (slice 0)
im, refs = wcs_ifu_grating("G140M", "OPAQUE")
w0 = nirspec.nrs_wcs_set_input(im, 0)

# Test NRS1
pyw = astwcs.WCS(ref['SLITY1'].header)
# Test evaluating the WCS (slice 0)
im, refs = wcs_ifu_grating("G140M", "OPAQUE")
w0 = nirspec.nrs_wcs_set_input(im, 0)
# get positions within the slit and the corresponding lambda
slit1 = ref['SLITY1'].data # y offset on the slit
lam = ref['LAMBDA1'].data

# get positions within the slit and the corresponding lambda
slit1 = ref['SLITY1'].data # y offset on the slit
lam = ref['LAMBDA1'].data
# filter out locations outside the slit
cond = np.logical_and(slit1 < .5, slit1 > -.5)
y, x = cond.nonzero() # 0-based
Expand Down
9 changes: 5 additions & 4 deletions jwst/associations/tests/test_mkpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@


def test_hdu(exposures):
hdus = [
fits.open(exposure)[0]
for exposure in exposures
]
hdus = []
for exposure in exposures:
with fits.open(exposure) as hdulist:
hdus.append(hdulist[0])
pool = mkpool(hdus)
assert isinstance(pool, AssociationPool)
assert REQUIRED_PARAMS.issubset(pool.colnames)
Expand All @@ -41,6 +41,7 @@ def test_hdulist(exposures):
assert isinstance(pool, AssociationPool)
assert REQUIRED_PARAMS.issubset(pool.colnames)
assert len(pool) == len(exposures)
[h.close() for h in hduls]


def test_mkpool(exposures):
Expand Down
10 changes: 5 additions & 5 deletions jwst/flatfield/flat_field_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def process(self, input):

# Record the user-supplied flat as the FLAT reference type for recording
# in the result header.
self._reference_files_used.append(
('flat', reference_file_models['user_supplied_flat'].meta.filename)
)
flat_ref_file = reference_file_models['user_supplied_flat'].meta.filename
self._reference_files_used.append(('flat', flat_ref_file))
self.log.info('Using flat field reference file: ', flat_ref_file)
elif self.use_correction_pars:
self.log.info(f'Using flat field from correction pars {self.correction_pars["flat"]}')
reference_file_models = {
Expand Down Expand Up @@ -197,9 +197,9 @@ def _get_references(self, data, exposure_type):
for reftype, reffile in reference_file_names.items():
if reffile is not None:
reference_file_models[reftype] = model_type[reftype](reffile)
self.log.debug('Using %s reference file: %s', reftype.upper(), reffile)
self.log.info('Using %s reference file: %s', reftype.upper(), reffile)
else:
self.log.debug('No reference found for type %s', reftype.upper())
self.log.info('No reference found for type %s', reftype.upper())
reference_file_models[reftype] = None

return reference_file_models
3 changes: 3 additions & 0 deletions jwst/outlier_detection/tests/test_outlier_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def test_outlier_step_square_source_no_outliers(we_three_sci, _jail):
np.testing.assert_allclose(image.data, corrected.data)
np.testing.assert_allclose(image.dq, corrected.dq)

container.close()
pristine.close()


@pytest.mark.parametrize("exptype", IMAGE_MODES)
def test_outlier_step_image_weak_CR_dither(exptype, _jail):
Expand Down
16 changes: 8 additions & 8 deletions jwst/residual_fringe/tests/test_background_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def read_fit_column(file):
file_dir = Path(__file__).parent.resolve()
file_path = str(file_dir / file)

hdu = fits.open(file_path)
col_data = hdu[1].data
col_weight = hdu[2].data
col_wnum = hdu[3].data
bg_fit = hdu[4].data
store_freq = hdu[0].header['FFREQ']

return col_data, col_weight, col_wnum, bg_fit, store_freq
with fits.open(file_path) as hdu:
col_data = hdu[1].data
col_weight = hdu[2].data
col_wnum = hdu[3].data
bg_fit = hdu[4].data
store_freq = hdu[0].header['FFREQ']

return col_data, col_weight, col_wnum, bg_fit, store_freq


@pytest.mark.parametrize("file", ['good_col.fits', 'edge_col.fits'])
Expand Down

0 comments on commit baad926

Please sign in to comment.