Files
leonarski_f aecd48b9d3
Build Packages / Build documentation (push) Successful in 48s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 15m47s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 23m19s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 18m47s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m27s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 26m59s
Build Packages / Unit tests (push) Successful in 1h50m25s
Build Packages / Validation Battery (push) Successful in 46m38s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 32m52s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 32m32s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 28m34s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 29m19s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 30m11s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m58s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 31m26s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 34m4s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 32m17s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Create release (push) Successful in 9s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 31m50s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 19m38s
v1.0.0-rc.186 (#97)
* jfjoch_broker (experimental): Live Rugnux covers serial collections from DECTRIS detectors; a rotation collection too large for the image buffer falls back to standard per-image processing with a warning, and a stream that ends without its end message finishes the collection instead of hanging it.
* jfjoch_broker (experimental): Live Rugnux settings to build the solvent during refinement and to process a rotation collection as stills, a Clear action for the last result, a `_report.txt` for live rotation runs, R-free reported for the refined model, and ice-ring detection on by default for rotation as in the command line.
* jfjoch_broker (experimental): More complete and reproducible live serial merges, analysed for twinning, pseudo-translation and anisotropy, with merging statistics by resolution shell in the live status.
* jfjoch_writer: Live results with large models are written reliably; update jfjoch_writer together with jfjoch_broker.
* Rugnux: Several masters can be processed together with `--force-still`, including grid scans; more robust and faster merging of several sweeps; improved twinning, pseudo-translation, anisotropy, anomalous-signal and space-group decisions.
* Rugnux: Molecular replacement places the copies of a multi-copy solution together; the pseudo-translation warning quotes the Patterson peak and is not raised once a model is placed; the report advises on extending the rotation or reorienting the crystal where the coverage would gain from it.
* Web frontend: Light and dark modes, a phone layout, a hideable page list, a redesigned Rugnux live page with step-through of the Fo-Fc peaks in the structure view.
* jfjoch_viewer: A broker URL given on the command line follows the running collection.

Reviewed-on: #97
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-11-13 20:13:43 +01:00

99 lines
2.8 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <vector>
#include <cstdint>
#include <algorithm>
#include <stdexcept>
struct rgb {
uint8_t r;
uint8_t g;
uint8_t b;
};
float luminance(rgb input);
enum class ColorScaleEnum : int {
Indigo = 0,
Viridis = 1,
Magma = 2,
Inferno = 3,
Heat = 4,
BW = 5,
WB = 6,
Green = 7
};
enum class ColorScaleSpecial {
Gap,
BadPixel,
BeamStop
};
class ColorScale {
// Viridis, Magma and Inferno are Matplotlib's colormaps, sampled. Following Hunter (2007) Comput. Sci. Eng. 9, 90-95
const std::vector<rgb> viridis_colormap = {
{68, 1, 84}, {71, 44, 123}, {59, 81, 139}, {44, 113, 142}, {33, 144, 141},
{39, 173, 129}, {92, 200, 99}, {170, 220, 50}, {253, 231, 37}
};
const std::vector<rgb> heat_colormap = {
{0, 0, 0}, {128, 0, 0}, {255, 0, 0}, {255, 128, 0}, {255, 255, 0}, {255, 255, 128}, {255, 255, 255}
};
const std::vector<rgb> white_to_indigo_colormap = {
{255, 255, 255}, {216, 209, 255}, {177, 162, 255}, {138, 114, 255}, {99, 67, 255}, {60, 19, 255}, {0, 0, 128}
};
const std::vector<rgb> white_to_black_colormap = {
{255, 255, 255}, {0, 0, 0}
};
const std::vector<rgb> black_to_white_colormap = {
{0, 0, 0}, {255, 255, 255}
};
const std::vector<rgb> green_colormap = {
{0, 0, 0}, {0, 255, 0}
};
const std::vector<rgb> magma_colormap = {
{0, 0, 4}, {28, 16, 68}, {79, 18, 123}, {129, 37, 129},
{181, 54, 122}, {229, 80, 100}, {251, 135, 97}, {252, 191, 125}, {252, 253, 191}
};
const std::vector<rgb> inferno_colormap = {
{0, 0, 4}, {31, 12, 72}, {85, 15, 109}, {136, 34, 106},
{186, 54, 85}, {227, 89, 51}, {249, 140, 10}, {252, 195, 63}, {252, 255, 164}
};
ColorScaleEnum current = ColorScaleEnum::Indigo;
rgb gap = {.r = 190, .g = 190, .b = 190}; // Gray
rgb bad = {.r = 255, .g = 0, .b = 255}; // Magenta
// Coral: distinct from the gray gap and the magenta bad pixel, and from every colormap
rgb beam_stop = {.r = 255, .g = 127, .b = 80};
static rgb Apply(float input, const std::vector<rgb> &map);
static constexpr size_t kLutSize = 512;
mutable std::vector<rgb> lut_;
void CalcLUT() const;
public:
ColorScale();
void Select(ColorScaleEnum val);
[[nodiscard]] rgb Apply(float input, float min = 0.0, float max = 1.0) const;
[[nodiscard]] rgb Apply(ColorScaleSpecial input) const;
const std::vector<rgb> &LUTData() const;
[[nodiscard]] rgb ApplyLUTIndex(size_t idx) const;
ColorScale &Gap(rgb input);
ColorScale &BadPixel(rgb input);
};