ITADN

Support masking in `plot_intensities`

#446Openkbarros 创建于 2025-10-31
enhancement
K
kbarroscommented
To define masked regions, one can manually overwrite certain elements of the `Intensities` data with NaNs. Sunny should essentially ignore these NaNs when determining its color-range One idea for a NaN-safe color-range function was proposed by Daniel Pajerowski: <details> ```jl function _nan_safe_colorrange_powder(data; saturation=0.9, allpositive=true) # Compute per-column extrema ignoring NaNs maxs = Float64[] mins = Float64[] for col in eachcol(data) finite = col[isfinite.(col)] isempty(finite) && continue push!(maxs, maximum(finite)) push!(mins, minimum(finite)) end # If everything is NaN, return a tiny non-degenerate range if isempty(maxs) || isempty(mins) return allpositive ? (0.0, 1e-15) : (-1e-15, 1e-15) end cmax = quantile(maxs, saturation) cmin = quantile(mins, 1 - saturation) if allpositive # Clip below zero if cmax <= 0 return (0.0, 1e-15) else sensitivity = 0.0 return (sensitivity, 1.0) .* cmax end else cscale = max(abs(cmax), abs(cmin)) return iszero(cscale) ? (-1e-15, 1e-15) : (-cscale, cscale) end end ``` </details>
0 条评论