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

get_data(use_display_units=True) to respect flux or sb selection #3129

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
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
Next Next commit
get_data(use_display_units) to respect flux or sb selection
kecnry committed Aug 2, 2024
commit 3b77edb4c8dc8be991af1ba4e88cdd4ec7625952
16 changes: 8 additions & 8 deletions jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
@@ -470,7 +470,7 @@ def _handle_display_units(self, data, use_display_units=True):
spectral_unit = self.app._get_display_unit('spectral')
if not spectral_unit:
return data
flux_unit = self.app._get_display_unit('flux')
y_unit = self.app._get_display_unit('spectral_y')
# TODO: any other attributes (meta, wcs, etc)?
# TODO: implement uncertainty.to upstream
uncertainty = data.uncertainty
@@ -488,26 +488,26 @@ def _handle_display_units(self, data, use_display_units=True):
new_uncert = uncertainty
if ('_pixel_scale_factor' in data.meta):
new_uncert_converted = flux_conversion(data, new_uncert.quantity.value,
new_uncert.unit, flux_unit)
new_uncert = StdDevUncertainty(new_uncert_converted, unit=flux_unit)
new_uncert.unit, y_unit)
new_uncert = StdDevUncertainty(new_uncert_converted, unit=y_unit)
else:
new_uncert = StdDevUncertainty(new_uncert, unit=data.flux.unit)

else:
new_uncert = None
if ('_pixel_scale_factor' in data.meta):
new_flux = flux_conversion(data, data.flux.value, data.flux.unit,
flux_unit) * u.Unit(flux_unit)
new_y = flux_conversion(data, data.flux.value, data.flux.unit,
y_unit) * u.Unit(y_unit)
else:
new_flux = flux_conversion(data, data.flux.value, data.flux.unit,
data.flux.unit) * u.Unit(data.flux.unit)
new_y = flux_conversion(data, data.flux.value, data.flux.unit,
data.flux.unit) * u.Unit(data.flux.unit)
new_spec = (spectral_axis_conversion(data.spectral_axis.value,
data.spectral_axis.unit,
spectral_unit)
* u.Unit(spectral_unit))

data = Spectrum1D(spectral_axis=new_spec,
flux=new_flux,
flux=new_y,
uncertainty=new_uncert,
mask=data.mask)
else: # pragma: nocover
11 changes: 0 additions & 11 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
@@ -2955,17 +2955,6 @@ def _get_continuum(self, dataset, spectral_subset, update_marks=False, per_pixel
raise ValueError("per-pixel only supported for cubeviz")
full_spectrum = self.app._jdaviz_helper.get_data(self.dataset.selected,
use_display_units=True)
# TODO: Something like the following code may be needed to get continuum
# with display units working
# temp_spec = self.app._jdaviz_helper.get_data(self.dataset.selected,
# use_display_units=True)
# flux_values = np.sum(np.ones_like(temp_spec.flux.value), axis=(0, 1))
# pix_scale = self.dataset.selected_dc_item.meta.get('PIXAR_SR', 1.0)
# pix_scale_factor = (flux_values * pix_scale)
# temp_spec.meta['_pixel_scale_factor'] = pix_scale_factor
# full_spectrum = self._specviz_helper._handle_display_units(temp_spec,
# use_display_units=True)

else:
full_spectrum = dataset.get_selected_spectrum(use_display_units=True)