Background
For many of my datasets the data are highly skewed and strictly positive. It is helpful to allow data transforms for display. This was fairly easy to implement but surfaced an issue with fragile NaN generation in the current code.
Two related issues came up in visualization:
- Some environmental variables are much easier to interpret on a logarithmic scale than a linear scale.
- Shader code that generates NaN via expressions like
sqrt(-1.0) can be driver-dependent and unreliable (black globe while the histogram showed values)
Shader safety
Replaced sqrt(-1.0)-style NaN generation with a helper based on uintBitsToFloat(0x7FC00000u).
Example code sketch
function applyDisplayTransformToData(data: Float32Array, mode: "linear" | "log10") {
if (mode === "linear") return data;
for (let i = 0; i < data.length; i++) {
const v = data[i];
data[i] = Number.isFinite(v) && v > 0 ? Math.log10(v) : Number.NaN;
}
return data;
}
float makeNaN() {
return uintBitsToFloat(0x7FC00000u);
}
How this was solved in my fork
In my fork, I:
- added
linear and log10 transform modes to shared types/store state,
- added a transform control in the colormap UI,
- applied the transform across all grid renderers before computing final bounds/histograms,
- normalized HEALPix missing/fill handling so transforms do not mis-handle sentinel values,
- replaced shader NaN generation with a quiet-NaN helper.
Related PR
- Fork PR:
https://github.com/eeholmes/gridlook/pull/23
Untransformed
Transformed

Background
For many of my datasets the data are highly skewed and strictly positive. It is helpful to allow data transforms for display. This was fairly easy to implement but surfaced an issue with fragile NaN generation in the current code.
Two related issues came up in visualization:
sqrt(-1.0)can be driver-dependent and unreliable (black globe while the histogram showed values)Shader safety
Replaced
sqrt(-1.0)-style NaN generation with a helper based onuintBitsToFloat(0x7FC00000u).Example code sketch
How this was solved in my fork
In my fork, I:
linearandlog10transform modes to shared types/store state,Related PR
https://github.com/eeholmes/gridlook/pull/23Untransformed
Transformed