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

Update model fit result units after toggling flux/surface brightness #3113

Merged
merged 6 commits into from
Jul 29, 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: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ New Features
------------

- Added flux/surface brightness translation and surface brightness
unit conversion in Cubeviz and Specviz. [#2781, #2940, #3088]
unit conversion in Cubeviz and Specviz. [#2781, #2940, #3088, #3113]

- Plugin tray is now open by default. [#2892]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def extract(self, return_bg=False, add_data=True, **kwargs):
spec = spec - bg_spec

# per https://jwst-docs.stsci.edu/jwst-near-infrared-camera/nircam-performance/nircam-absolute-flux-calibration-and-zeropoints # noqa
pix_scale_factor = self.aperture_area_along_spectral * self.spectral_cube.meta.get('PIXAR_SR', 1.0) # noqa
pix_scale_factor = self.spectral_cube.meta.get('PIXAR_SR', 1.0)
spec.meta['_pixel_scale_factor'] = pix_scale_factor

# inform the user if scale factor keyword not in metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
# during initial init, this can trigger before the component is initialized
return

selected_spec = self.dataset.selected_spectrum
selected_spec = self.dataset.selected_obj
if selected_spec is None:
return

Expand Down Expand Up @@ -842,6 +842,10 @@
self.hub.broadcast(msg)
return

selected_spec = self.dataset.selected_obj
if '_pixel_scale_factor' in selected_spec.meta:
fitted_spectrum.meta['_pixel_scale_factor'] = selected_spec.meta['_pixel_scale_factor']

Check warning on line 847 in jdaviz/configs/default/plugins/model_fitting/model_fitting.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/default/plugins/model_fitting/model_fitting.py#L847

Added line #L847 was not covered by tests

self._fitted_model = fitted_model
self._fitted_spectrum = fitted_spectrum

Expand Down Expand Up @@ -933,6 +937,10 @@

output_cube = Spectrum1D(flux=fitted_spectrum.flux, wcs=fitted_spectrum.wcs)

selected_spec = self.dataset.selected_obj
if '_pixel_scale_factor' in selected_spec.meta:
output_cube.meta['_pixel_scale_factor'] = selected_spec.meta['_pixel_scale_factor']

Check warning on line 942 in jdaviz/configs/default/plugins/model_fitting/model_fitting.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/default/plugins/model_fitting/model_fitting.py#L942

Added line #L942 was not covered by tests

# Create new data entry for glue
if add_data:
self.add_results.add_results_from_plugin(output_cube)
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_to_unit(cubeviz_helper):

# will be a uniform array since not wavelength dependent
# so test first value in array
assert np.allclose(value[0], 4.800000041882413e-08)
assert np.allclose(value[0], 8e-11)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, is this change expected? Is this because of the change to remove aperture_area_along_spectral? (cc @bmorris3)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so, it looked like this value comes from code that would have been affected by that change.


# Change from Fnu to Flam (with values shape matching spectral axis)

Expand Down