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

Fix cube fit toggle with spectral subset selected #3123

Merged
merged 3 commits into from
Jul 31, 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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ Other Changes and Additions
Bug Fixes
---------

- Fixed the data menu in Model Fitting not being populated if Cube Fit was toggled
while a spectral subset was selected. [#3123]

Cubeviz
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ def test_fit_cube_no_wcs(cubeviz_helper):
assert fitted_data.shape == output_cube.shape


def test_toggle_cube_fit_subset(cubeviz_helper):
sp = Spectrum1D(flux=np.ones((7, 8, 9)) * u.nJy) # ny, nx, nz
cubeviz_helper.load_data(sp, data_label="test_cube")
mf = cubeviz_helper.plugins['Model Fitting']

sv = cubeviz_helper.app.get_viewer('spectrum-viewer')
sv.apply_roi(XRangeROI(7.5, 8))

mf.spectral_subset = 'Subset 1'
mf.cube_fit = True


def test_refit_plot_options(specviz_helper, spectrum1d):
specviz_helper.load_data(spectrum1d)
modelfit_plugin = specviz_helper.plugins['Model Fitting']
Expand Down Expand Up @@ -284,6 +296,7 @@ def test_reestimate_parameters(specviz_helper, spectrum1d):
sv.apply_roi(XRangeROI(7500, 8000))

mf.spectral_subset = 'Subset 1'

mf.reestimate_model_parameters()
mc = mf.get_model_component('G')

Expand Down
2 changes: 1 addition & 1 deletion jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,7 @@ class DatasetSpectralSubsetValidMixin(VuetifyTemplate, HubListener):

@observe("dataset_selected", "spectral_subset_selected")
def _check_dataset_spectral_subset_valid(self, event={}, return_ranges=False):
if not hasattr(self, 'dataset'):
if not hasattr(self, 'dataset') or self.dataset.selected_obj is None:
# plugin not fully initialized
return
if self.spectral_subset_selected == "Entire Spectrum":
Expand Down
Loading