Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-3642: Fix aperture correction to variance arrays #8530

Merged
merged 5 commits into from
Jun 5, 2024
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ extract_1d
- Add propagation of uncertainty when annular backgrounds are subtracted
from source spectra during IFU spectral extraction. [#8515]

- Fix error in application of aperture correction to variance arrays. [#8530]

extract_2d
----------

Expand Down
32 changes: 19 additions & 13 deletions jwst/extract_1d/apply_apcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@
Table of aperture corrections values from apcorr reference file.

"""
cols_to_correct = ('flux', 'flux_error', 'flux_var_poisson', 'flux_var_rnoise',
'flux_var_flat', 'surf_bright', 'sb_error', 'sb_var_poisson',
'sb_var_rnoise', 'sb_var_flat')
flux_cols_to_correct = ('flux', 'flux_error', 'surf_bright', 'sb_error')
var_cols_to_correct = ('flux_var_poisson', 'flux_var_rnoise', 'flux_var_flat',

Check warning on line 157 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L156-L157

Added lines #L156 - L157 were not covered by tests
'sb_var_poisson', 'sb_var_rnoise', 'sb_var_flat')

for row in spec_table:
correction = self.apcorr_func(row['npixels'], row['wavelength'])

for col in cols_to_correct:
for col in flux_cols_to_correct:

Check warning on line 163 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L163

Added line #L163 was not covered by tests
row[col] *= correction.item()
for col in var_cols_to_correct:
row[col] *= correction.item() * correction.item()

Check warning on line 166 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L165-L166

Added lines #L165 - L166 were not covered by tests


class ApCorrPhase(ApCorrBase):
Expand Down Expand Up @@ -234,19 +236,21 @@
Table of aperture corrections values from apcorr reference file.

"""
cols_to_correct = ('flux', 'flux_error', 'flux_var_poisson', 'flux_var_rnoise',
'flux_var_flat', 'surf_bright', 'sb_error', 'sb_var_poisson',
'sb_var_rnoise', 'sb_var_flat')
flux_cols_to_correct = ('flux', 'flux_error', 'surf_bright', 'sb_error')
var_cols_to_correct = ('flux_var_poisson', 'flux_var_rnoise', 'flux_var_flat',

Check warning on line 240 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L239-L240

Added lines #L239 - L240 were not covered by tests
'sb_var_poisson', 'sb_var_rnoise', 'sb_var_flat')

for row in spec_table:
try:
correction = self.apcorr_func(row['wavelength'], row['npixels'], self.phase)
except ValueError:
correction = None # Some input wavelengths might not be supported (especially at the ends of the range)

for col in cols_to_correct:
if correction:
if correction:
for col in flux_cols_to_correct:

Check warning on line 250 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L249-L250

Added lines #L249 - L250 were not covered by tests
row[col] *= correction.item()
for col in var_cols_to_correct:
row[col] *= correction.item() * correction.item()

Check warning on line 253 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L252-L253

Added lines #L252 - L253 were not covered by tests


class ApCorrRadial(ApCorrBase):
Expand Down Expand Up @@ -293,14 +297,16 @@
Table of aperture corrections values from apcorr reference file.

"""
cols_to_correct = ('flux', 'flux_error', 'flux_var_poisson', 'flux_var_rnoise',
'flux_var_flat', 'surf_bright', 'sb_error', 'sb_var_poisson',
'sb_var_rnoise', 'sb_var_flat')
flux_cols_to_correct = ('flux', 'flux_error', 'surf_bright', 'sb_error')
var_cols_to_correct = ('flux_var_poisson', 'flux_var_rnoise', 'flux_var_flat',

Check warning on line 301 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L300-L301

Added lines #L300 - L301 were not covered by tests
'sb_var_poisson', 'sb_var_rnoise', 'sb_var_flat')

for i, row in enumerate(spec_table):
correction = self.apcorr_correction[i]
for col in cols_to_correct:
for col in flux_cols_to_correct:

Check warning on line 306 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L306

Added line #L306 was not covered by tests
row[col] *= correction
for col in var_cols_to_correct:
row[col] *= correction * correction

Check warning on line 309 in jwst/extract_1d/apply_apcorr.py

View check run for this annotation

Codecov / codecov/patch

jwst/extract_1d/apply_apcorr.py#L308-L309

Added lines #L308 - L309 were not covered by tests

def match_wavelengths(self, wavelength_ifu):
# given the ifu wavelength value - redefine the apcor func and radius to this wavelength
Expand Down