Skip to content

Commit

Permalink
More debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Jan 21, 2025
1 parent f2030e4 commit 8ea20d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def calculate_moment(self, add_data=True):
# before calculating
else:
slab_sa = slab.spectral_axis.to(self.app._get_display_unit('spectral'))
slab = Spectrum(slab.flux, slab_sa, uncertainty=slab.uncertainty)
slab = Spectrum(slab.flux, slab_sa, uncertainty=slab.uncertainty,
spectral_axis_index=cube.spectral_axis_index)

# Finally actually calculate the moment
self.moment = analysis.moment(slab, order=n_moment).T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def _valid_glue_display_unit(unit_str, sv, axis='x'):
unit_u = u.Unit(unit_str)
choices_str = getattr(sv.state.__class__, f'{axis}_display_unit').get_choices(sv.state)
choices_str = [choice for choice in choices_str if choice is not None]
if choices_str == []:
return unit_str
choices_u = [u.Unit(choice) for choice in choices_str]
if unit_u not in choices_u:
raise ValueError(f"{unit_str} could not find match in valid {axis} display units {choices_str}") # noqa
Expand Down
8 changes: 4 additions & 4 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3272,11 +3272,11 @@ def fit_continuum(continuum_y_spaxel):

# spectrum.spectral_axis is an array, but we need our continuum to have the same
# shape as the fluxes in the cube, so let's just duplicate to the correct shape
print(spectrum.flux.shape)
spectral_axis_cube = np.zeros(spectrum.flux.shape)
spectral_axis_cube[:, :] = spectrum.spectral_axis.value

continuum = slopes[:, :, np.newaxis] * (spectral_axis_cube-min_x) + intercepts[:, :, np.newaxis] # noqa
reshape_inds = [1, 1, 1]
reshape_inds[spectral_axis_index] = -1
spectral_axis_cube[:, :, :] = spectrum.spectral_axis.value.reshape(reshape_inds)
continuum = np.expand_dims(slopes, spectral_axis_index) * (spectral_axis_cube-min_x) + np.expand_dims(intercepts, spectral_axis_index) # noqa
else:
continuum_y = full_spectrum.flux[continuum_mask].value
slope, intercept = np.polyfit(continuum_x-min_x, continuum_y, deg=1)
Expand Down

0 comments on commit 8ea20d0

Please sign in to comment.