fix formatting of unit after appending angle #3198
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a traceback when changing flux units via API. When changing between Jy and erg/c/cm2/A, the traceback said the unit was not in the list of available options for the y axis because the strings differed. This happens when handing contours. To reproduce:
from jdaviz.conftest import _create_spectrum1d_cube_with_fluxunit
from jdaviz import Cubeviz
import astropy.units as u
cube = _create_spectrum1d_cube_with_fluxunit(shape=(25, 25, 4), fluxunit=u.Jy / u.sr, with_uncerts=True)
cubeviz_helper = Cubeviz()
cubeviz_helper.load_data(cube, data_label="test")
uc = cubeviz_helper.plugins['Unit Conversion']._obj
uc.flux_unit.selected='erg / (Angstrom s cm2)'
In the unit conversion plugin, the '_append_angle_correctly' method to combine chosen flux and angle units sometimes produces unit strings that aren't in the required order for setting the spectral axis. These options are hard coded in UnitConverterWithSpectral (app.py). Additionally, this method was setting the sb_unit_selected read-only attribute twice in a row, so this redundancy was removed.
There is a remaining traceback coming from contours when changing flux unit, which is described in JDAT-4785.