diff --git a/jdaviz/core/validunits.py b/jdaviz/core/validunits.py index 97b4c06059..b20b5825a3 100644 --- a/jdaviz/core/validunits.py +++ b/jdaviz/core/validunits.py @@ -1,9 +1,11 @@ from astropy import units as u import itertools -__all__ = ['units_to_strings', 'create_spectral_equivalencies_list', +__all__ = ['supported_sq_angle_units', 'units_to_strings', 'create_spectral_equivalencies_list', 'create_flux_equivalencies_list', 'check_if_unit_is_per_solid_angle'] +def supported_sq_angle_units(): + return [u.pix*u.pix, u.sr] def units_to_strings(unit_list): """Convert equivalencies into readable versions of the units. diff --git a/jdaviz/utils.py b/jdaviz/utils.py index 0546ff3213..ddd84f2265 100644 --- a/jdaviz/utils.py +++ b/jdaviz/utils.py @@ -471,8 +471,9 @@ def _indirect_conversion(values, orig_units, targ_units, eqv, # make these an input parameter since they're already determined # here for now until i make sure this function isn't called elsewhere - solid_angle_in_orig = check_if_unit_is_per_solid_angle(orig_units) - solid_angle_in_targ = check_if_unit_is_per_solid_angle(targ_units) + solid_angle_in_orig = check_if_unit_is_per_solid_angle(orig_units, return_unit=True) + solid_angle_in_targ = check_if_unit_is_per_solid_angle(targ_units, return_unit=True) + solid_angle_in_spec = check_if_unit_is_per_solid_angle(spec_unit, return_unit=True) # indirect units cannot be directly converted, and require # additional conversions to reach the desired end unit. @@ -480,6 +481,9 @@ def _indirect_conversion(values, orig_units, targ_units, eqv, and not check_if_unit_is_per_solid_angle(spec_unit)): if u.Unit(targ_units) in indirect_units(): temp_targ = targ_units * solid_angle_in_targ + print('temp_targ', temp_targ) + print('solid angle in targ', solid_angle_in_targ) + print('orig_units', orig_units) values = (values * orig_units).to_value(temp_targ, equivalencies=eqv) orig_units = u.Unit(temp_targ) return values, orig_units, 'orig' @@ -491,9 +495,9 @@ def _indirect_conversion(values, orig_units, targ_units, eqv, return values, targ_units, 'targ' - elif image_data or (spec_unit and check_if_unit_is_per_solid_angle(spec_unit)): + elif image_data or (spec_unit and solid_angle_in_spec): if not solid_angle_in_targ: - targ_units /= solid_angle_in_targ + targ_units /= solid_angle_in_spec if ((u.Unit(targ_units) in indirect_units()) or (u.Unit(orig_units) in indirect_units())): # SB -> Flux -> Flux -> SB