openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Color attribute for materials/cells/universes

Open pshriwise opened this issue 2 years ago • 6 comments

Similar to #2503, I have a plotting query for the community.

The assignment of material/cell colors in a dictionary when creating a plotting object has always felt a little clunky to me. Serpent allows users to associate a color with a cell or material that will be applied in any plots or visualization. At first, it felt odd to me to mix something non-physical into the object description, but having the color assigned to the object would make it straightforward to keep colors consistent in plots generated by the Python API, the openmc executable, and the plotting utility.

Thoughts @paulromano @kkiesling @gridley?

pshriwise avatar Apr 28 '23 16:04 pshriwise

I agree this would be a very useful feature. I assume this would be added as an attribute on the material or cell object that could be read across these different utilities.

kkiesling avatar Apr 28 '23 16:04 kkiesling

Yes, I've recently discovered there was the Python API plotting, it's a bit confusing having 3 diff. ways to plot, but I guess each has it's merit. It'd be nice to keep things more constant/consistent across the three methods.

yrrepy avatar Apr 28 '23 16:04 yrrepy

Sounds nice, but I think rather than putting a color attribute on the cell or material class, it would be better to keep two hashmaps somewhere that map cell/material IDs into color values. That way we're not inflating the memory consumption of large models at all.

In the python API, it should appear as an attribute of cell/material/whatever though.

gridley avatar Apr 28 '23 16:04 gridley

@gridley We should definitely keep large models in mind for cell/material attributes 👍🏻 I'll keep that in mind should I find some time to submit a PR for this soon.

pshriwise avatar May 01 '23 18:05 pshriwise

This would be a nice feature! I've been guilty of trying to set Material.color more than once.

tjlaboss avatar May 03 '23 20:05 tjlaboss

Partly addressed by PR #2826 (Material and Cell only, not Universe)

tjlaboss avatar Jan 10 '24 07:01 tjlaboss