Skip to content
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

Reverse gist_rainbow colors to match order of manual presets #2731

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Bug Fixes

- Fix redshifted line lists that were displaying at rest wavelengths, by assuming a global redshift. [#2726]

- Order of RGB preset colors now matches for less than and greater than 5 layers. [#2731]

Cubeviz
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,10 @@ def apply_RGB_presets(self):
# Sample along a colormap if we have too many layers
if n_visible > len(preset_colors):
cmap = matplotlib.colormaps['gist_rainbow'].resampled(n_visible)
# Have to reverse the order of the cmap to make physical sense with
# assumed wavelength order of layers.
preset_colors = [matplotlib.colors.to_hex(cmap(i), keep_alpha=True) for
i in range(n_visible)]
i in range(n_visible - 1, -1, -1)]
elif n_visible >= 2 and n_visible < len(preset_colors):
preset_colors = [preset_colors[i] for i in preset_inds[n_visible]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,16 @@ def test_apply_presets(imviz_helper):
po.apply_RGB_presets()

assert po.layer.selected == "array_3"
assert po.stretch_function.value == "arcsinh"
po.layer = "array_5"
# Make sure this one didn't change
assert po.stretch_function.value == "linear"

# Turn layer 5 back on
po.image_visible = True
po.apply_RGB_presets()

colorbar_colors = matplotlib.colormaps['gist_rainbow'].resampled(7)
colorbar_colors = matplotlib.colormaps['gist_rainbow'].resampled(8)
color_ind = 0

def _rgb_to_hex(rgb):
Expand All @@ -298,15 +306,11 @@ def _rgb_to_hex(rgb):

for i in range(8):
po.layer = f"array_{i}"
if i == 5:
# Make sure this one didn't change
assert po.stretch_function.value == "linear"
else:
assert po.stretch_function.value == "arcsinh"
assert po.stretch_preset.value == 99
assert po.image_color.value == matplotlib.colors.to_hex(colorbar_colors(color_ind),
keep_alpha=True)
color_ind += 1
assert po.stretch_function.value == "arcsinh"
assert po.stretch_preset.value == 99
assert po.image_color.value == matplotlib.colors.to_hex(colorbar_colors(7-color_ind),
keep_alpha=True)
color_ind += 1


def test_track_mixed_states(imviz_helper):
Expand Down