Skip to content

Commit

Permalink
remove magnitude units from display units list
Browse files Browse the repository at this point in the history
  • Loading branch information
gibsongreen committed Aug 8, 2024
1 parent f8cd410 commit 69bab4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ def equivalent_units(self, data, cid, units):
'erg / (s cm2 Angstrom)', 'erg / (s cm2 Angstrom)',
'erg / (s cm2 Hz)', 'erg / (Hz s cm2)',
'ph / (Angstrom s cm2)',
'ph / (Hz s cm2)', 'ph / (Hz s cm2)', 'bol', 'AB', 'ST'
'ph / (Hz s cm2)', 'ph / (Hz s cm2)'
]
+ [
'Jy / sr', 'mJy / sr', 'uJy / sr', 'MJy / sr',
'W / (Hz sr m2)',
'eV / (Hz s sr m2)',
'erg / (s sr cm2)',
'AB / sr'
])
else: # spectral axis
# prefer Hz over Bq and um over micron
Expand Down
7 changes: 5 additions & 2 deletions jdaviz/core/validunits.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def create_flux_equivalencies_list(flux_unit, spectral_axis_unit):
except u.core.UnitConversionError:
return []

mag_units = ['bol', 'AB', 'ST']
# remove magnitude units from list
curr_flux_unit_equivalencies = [unit for unit in curr_flux_unit_equivalencies if not any(mag in unit.name for mag in mag_units)] # noqa

# Get local flux units.
locally_defined_flux_units = ['Jy', 'mJy', 'uJy', 'MJy',
'W / (Hz m2)',
Expand All @@ -75,13 +79,12 @@ def create_flux_equivalencies_list(flux_unit, spectral_axis_unit):
'erg / (s cm2 Angstrom)',
'ph / (Angstrom s cm2)',
'ph / (Hz s cm2)',
'bol', 'AB', 'ST'
]
local_units = [u.Unit(unit) for unit in locally_defined_flux_units]

# Remove overlap units.
curr_flux_unit_equivalencies = list(set(curr_flux_unit_equivalencies)
- set(local_units))
- set(local_units) - set(mag_units))

# Convert equivalencies into readable versions of the units and sort them alphabetically.
flux_unit_equivalencies_titles = sorted(units_to_strings(curr_flux_unit_equivalencies))
Expand Down

0 comments on commit 69bab4c

Please sign in to comment.