Skip to content

Commit

Permalink
table
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Jul 26, 2024
1 parent 7c098bb commit 8d23ea1
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ def calculate_photometry(self, dataset=None, aperture=None, background=None,
raw=False)

# convert y_data to display unit, if data units differ
if comp.units:
if self.display_flux_or_sb_unit != comp.units:
y_data_with_units = y_data * u.Unit(comp.units)
y_data_translated = y_data_with_units.to(u.Unit(self.display_flux_or_sb_unit))
y_data = y_data_translated.value # strip units for plotting
if self.config == 'cubeviz':
if comp.units:
if self.display_flux_or_sb_unit != comp.units:
y_data_with_units = y_data * u.Unit(comp.units)
y_data_translated = y_data_with_units.to(u.Unit(self.display_flux_or_sb_unit))
y_data = y_data_translated.value # strip units for plotting

print('plotting y data = ', y_data)
self.plot._update_data('profile', x=x_data, y=y_data, reset_lims=True)
self.plot.update_style('profile', line_visible=True, color='gray', size=32)

Expand All @@ -737,6 +737,14 @@ def calculate_photometry(self, dataset=None, aperture=None, background=None,
phot_aperstats.data_cutout, phot_aperstats.bbox, (xcenter, ycenter),
raw=True)

# convert y_data to display unit, if data units differ
if self.config == 'cubeviz':
if comp.units:
if self.display_flux_or_sb_unit != comp.units:
y_data_with_units = y_data * u.Unit(comp.units)
y_data_translated = y_data_with_units.to(u.Unit(self.display_flux_or_sb_unit))
y_data = y_data_translated.value # strip units for plotting

self.plot._update_data('profile', x=x_data, y=y_data, reset_lims=True)
self.plot.update_style('profile', line_visible=False, color='gray', size=10)

Expand Down Expand Up @@ -765,11 +773,12 @@ def calculate_photometry(self, dataset=None, aperture=None, background=None,
y_fit = fit_model(x_data)

# convert y_data to display unit, if data units differ
if comp.units:
if self.display_flux_or_sb_unit != comp.units:
y_data_with_units = y_fit * u.Unit(comp.units)
y_data_translated = y_data_with_units.to(u.Unit(self.display_flux_or_sb_unit))
y_fit = y_data_translated.value # strip units for plotting
if self.config == 'cubeviz':
if comp.units:
if self.display_flux_or_sb_unit != comp.units:
y_data_with_units = y_fit * u.Unit(comp.units)
y_data_translated = y_data_with_units.to(selected_dataset_display_unit)
y_fit = y_data_translated.value # strip units for plotting

self.app.fitted_models[self._fitted_model_name] = fit_model
self.plot._update_data('fit', x=x_data, y=y_fit, reset_lims=True)
Expand Down Expand Up @@ -818,8 +827,15 @@ def calculate_photometry(self, dataset=None, aperture=None, background=None,
if fit_model is not None and isinstance(fit_model, Gaussian1D):
for param in ('mean', 'fwhm', 'amplitude'):
p_val = getattr(fit_model, param)

if isinstance(p_val, Parameter):
p_val = p_val.value

# convert to display units
if self.config == "cubeviz" and comp.units:
p_val = p_val * img_unit
p_val = p_val.to(selected_dataset_display_unit).value

fit_tmp.append({'function': param, 'result': f'{p_val:.4e}'})

self.results = tmp
Expand Down

0 comments on commit 8d23ea1

Please # to comment.