Repository navigation
Conversation
cophus
requested changes
Dec 4, 2026
cophus
left a comment
Contributor
There was a problem hiding this comment.
Thanks Ian. The move and the re-export look good. With the default arguments the output is identical to the old DDF color_wheel, and from quantem.diffraction.digital_dark_field import color_wheel still works. A few requests before we merge:
- Perceptual mode. Now that this is the core color wheel for DPC and phase directions, it should be able to match how quantEM already colors angles.
show_2dfor complex arrays,add_arg_cbar_to_axand the ACOM-FFT angle maps (_angle_rgbinsystematic_row.py) all usearray_to_rgba, which works in CIECAM02 JCh at constant lightness across hue. Around the rim of the HSV wheel the lightness J runs from 20 (blue) to 89 (yellow), while a JCh wheel stays at 58 to 59. An option that callsarray_to_rgba(np.clip(r, 0, 1) ** gamma, np.arctan2(y, x))would make the wheel an exact legend forshow_2dcomplex images. Please keep HSV as the default socomposite_ddfstill matches its legend. - Rename
colorslisttocolor_list, since quantEM arguments are snake_case and this is public API. - The 0-255 check runs per color, so
(1, 1, 1)in a list of 0-255 colors is read as white rather than near-black. Please decide the scale once for the whole list. - A list with fewer than two colors fails with an
IndexError(empty) or a matplotlibValueError(one color). A clearValueErrorwould help. - Minor: export
color_wheelfromquantem.core.visualizationnext toturbo_black. In the test,repeat=1and thegamma=1.0case repeat the defaults and can be dropped.
color_wheel is useful beyond digital dark field, for example to label DPC or phase gradient directions, so it now lives in quantem.core.visualization.visualization_utils; digital_dark_field re-exports it, so existing imports keep working. It can also take a list of colors to place evenly around the wheel, joined back to the first color so the wheel has no seam, a repeat count for the hues, and a gamma for how the brightness grows with radius. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
mode="perceptual" colors the wheel with array_to_rgba, the CIECAM02 JCh coloring that show_2d uses for complex arrays, add_arg_cbar_to_ax and the ACOM angle maps, so the wheel is an exact legend for those images. Its rim keeps a lightness J of about 58 all the way round, where the HSV rim runs from 19 (blue) to 91 (yellow). saturation sets chroma_boost, and repeat and gamma work as in the HSV mode. HSV stays the default, so composite_ddf still matches its legend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
The 0-255 check ran per color, so (1, 1, 1) in a list of 0-255 colors was read as white rather than near black. The scale is now decided once for the whole list: if any tuple has a value above 1, all of them are read as 0-255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
color_wheel and composite_ddf now color with array_to_rgba (CIECAM02 hue at constant lightness) by default, as show_2d does for complex arrays, add_arg_cbar_to_ax and the ACOM angle maps. mode="hsv" gives the HSV hues instead. Both take mode=None by default, which means perceptual unless the caller passes its own colors (color_list, or colors for composite_ddf); giving both a mode and colors is an error. In both modes composite_ddf colors image k with the wheel's hue at angle 2 pi k / K and its scaled intensity as the radius, so color_wheel(gamma=gamma, mode=mode) is an exact legend of the composite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
An empty list failed with an IndexError and a single color with a matplotlib ValueError; both now raise a ValueError that says the list needs at least two colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
Also drop test arguments that repeated the defaults (repeat=1 and the gamma=1.0 case). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
maclariz
force-pushed
the
color-wheel-to-core
branch
from
December 6, 2026 17:48
661c49c to
97cea6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
color_wheel is useful beyond digital dark field, for example to label DPC or phase gradient directions, so it now lives in quantem.core.visualization.visualization_utils; digital_dark_field re-exports it, so existing imports keep working.
It also gains:
With the defaults the output is unchanged.
Claude-Session: https://claude.ai/code/session_01TKw4bfi2sFksBeLfpxq732
What problem this PR addreseses
color_wheel is of likely wider applicability than just Digital Dark Field imaging, so is worth making into a core visualization function that digital_dark_field calls when needed
What should the reviewer(s) do