-
Notifications
You must be signed in to change notification settings - Fork 73
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
Debug Cubeviz batch photometry #3163
Changes from all commits
1c2baab
547d831
37087c4
b847c24
bad39c0
c8fe010
b641728
c8f07ef
4556ff7
9328fdb
e0223c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,8 @@ | |
acceptable_types = ['spectral flux density wav', | ||
'photon flux density wav', | ||
'spectral flux density', | ||
'photon flux density'] | ||
'photon flux density', | ||
'surface brightness'] | ||
return ((data.ndim in (2, 3)) and | ||
((img_unit == (u.MJy / u.sr)) or | ||
(img_unit.physical_type in acceptable_types))) | ||
|
@@ -145,10 +146,19 @@ | |
if self.config != "cubeviz": | ||
return | ||
# self.dataset might not exist when app is setting itself up. | ||
if hasattr(self, "dataset") and self.dataset.selected_dc_item.ndim > 2: | ||
self.is_cube = True | ||
else: | ||
if hasattr(self, "dataset"): | ||
if isinstance(self.dataset.selected_dc_item, list): | ||
datasets = self.dataset.selected_dc_item | ||
else: | ||
datasets = [self.dataset.selected_dc_item] | ||
|
||
self.is_cube = False | ||
for dataset in datasets: | ||
# This assumes all cubes, or no cubes. If we allow photometry on collapsed cubes | ||
# or images this will need to change. | ||
if dataset.ndim > 2: | ||
self.is_cube = True | ||
break | ||
kecnry marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def _on_display_units_changed(self, event={}): | ||
|
||
|
@@ -208,6 +218,8 @@ | |
return | ||
|
||
data = self.dataset.selected_dc_item | ||
if isinstance(data, list): | ||
data = data[0] | ||
Comment on lines
+221
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't love this, but this whole method will probably go away with #3156, and I can't think of a better way to do it with the current setup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @cshanahan1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will go away at some point (im trying to consolidate everything that listens to unit changes to one method in that PR), but it also seems like its necessary here for now |
||
comp = data.get_component(data.main_components[0]) | ||
if comp.units: | ||
# if data is something-per-solid-angle, its a SB unit and we should | ||
|
@@ -557,7 +569,7 @@ | |
|
||
# cubeviz: background_value set in plugin is in display units | ||
# convert temporarily to image units for calculations | ||
if (self.config == 'cubeviz') and (img_unit is not None): | ||
if (self.config == 'cubeviz') and (img_unit is not None) and display_unit != '': | ||
background_value = (background_value * display_unit).to_value( | ||
img_unit, u.spectral_density(self._cube_wave)) | ||
|
||
|
@@ -568,7 +580,7 @@ | |
|
||
# cubeviz: background_value set in plugin is in display units | ||
# convert temporarily to image units for calculations | ||
if (self.config == 'cubeviz') and (img_unit is not None): | ||
if (self.config == 'cubeviz') and (img_unit is not None) and display_unit != '': | ||
background_value = (background_value * display_unit).to_value( | ||
img_unit, u.spectral_density(self._cube_wave)) | ||
else: | ||
|
@@ -578,7 +590,7 @@ | |
|
||
# cubeviz: computed background median will be in display units, | ||
# convert temporarily back to image units for calculations | ||
if (self.config == 'cubeviz') and (img_unit is not None): | ||
if (self.config == 'cubeviz') and (img_unit is not None) and display_unit != '': | ||
background_value = (background_value * display_unit).to_value( | ||
img_unit, u.spectral_density(self._cube_wave)) | ||
try: | ||
|
@@ -726,25 +738,26 @@ | |
# convert units of certain columns in aperture phot. output table | ||
# to reflect display units (i.e if data units are MJy / sr, but | ||
# Jy / sr is selected in Unit Conversion plugin) | ||
phot_table['background'] = phot_table['background'].to( | ||
display_unit, u.spectral_density(self._cube_wave)) | ||
|
||
if include_pixarea_fac: | ||
phot_table['sum'] = phot_table['sum'].to( | ||
(display_unit * pixarea_fac).unit, u.spectral_density(self._cube_wave)) | ||
else: | ||
phot_table['sum'] = phot_table['sum'].to( | ||
if display_unit != '': | ||
phot_table['background'] = phot_table['background'].to( | ||
display_unit, u.spectral_density(self._cube_wave)) | ||
for key in ['min', 'max', 'mean', 'median', 'mode', 'std', | ||
'mad_std', 'biweight_location']: | ||
phot_table[key] = phot_table[key].to( | ||
display_unit, u.spectral_density(self._cube_wave)) | ||
for key in ['var', 'biweight_midvariance']: | ||
try: | ||
phot_table[key] = phot_table[key].to(display_unit**2) | ||
# FIXME: Can fail going between per-wave and per-freq | ||
except u.UnitConversionError: | ||
pass | ||
|
||
if include_pixarea_fac: | ||
phot_table['sum'] = phot_table['sum'].to( | ||
(display_unit * pixarea_fac).unit, u.spectral_density(self._cube_wave)) | ||
else: | ||
phot_table['sum'] = phot_table['sum'].to( | ||
display_unit, u.spectral_density(self._cube_wave)) | ||
for key in ['min', 'max', 'mean', 'median', 'mode', 'std', | ||
'mad_std', 'biweight_location']: | ||
phot_table[key] = phot_table[key].to( | ||
display_unit, u.spectral_density(self._cube_wave)) | ||
for key in ['var', 'biweight_midvariance']: | ||
try: | ||
phot_table[key] = phot_table[key].to(display_unit**2) | ||
# FIXME: Can fail going between per-wave and per-freq | ||
except u.UnitConversionError: | ||
pass | ||
|
||
if add_to_table: | ||
try: | ||
|
@@ -1060,6 +1073,7 @@ | |
option.setdefault('pixel_area', defaults.get('pixel_area', 0)) | ||
if self.flux_scaling_multi_auto: | ||
option.setdefault('flux_scaling', defaults.get('flux_scaling', 0)) | ||
|
||
try: | ||
self.calculate_photometry(add_to_table=add_to_table, | ||
update_plots=this_update_plots, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this file are mainly changing things that @cshanahan1 added earlier, so I would prefer she review as well.