From da430a1af8f43dcbb267d35dc7df55f2f6689e91 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Thu, 26 Feb 2026 01:02:38 +0000 Subject: [PATCH 1/3] Simploify and always call makecpt either with equalize or not. --- src/blendimg.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/blendimg.jl b/src/blendimg.jl index 89aff88eb..94a97e662 100644 --- a/src/blendimg.jl +++ b/src/blendimg.jl @@ -343,10 +343,8 @@ function lelandshade(G::GMTgrid; detail=1.0, contrast=2.0, uint16=false, intensi if (cmap != "") cpt = cmap isa(cpt, GMTcpt) && (CURRENT_CPT[] = cpt) - elseif (equalize == 0) - cpt = makecpt(G; C=_cpt, Vd=-1, kw...) # The 'nothing' branch will pick G's cpt else - cpt = (equalize == 1) ? grd2cpt(G, C=_cpt, kw...) : grd2cpt(G, T="$equalize", C=_cpt, Vd=-1, kw...) + cpt = (equalize == 0) ? makecpt(G, C=_cpt, kw...) : makecpt(G, C=_cpt, equalize=equalize, kw...) end color = gdaldem(G, "color-relief"; color=cpt, kw...) blendimg!(I1, Ihill, transparency=transparency) From cc2cf4c4cafc8f5e037062674b33e906986c88b6 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Thu, 26 Feb 2026 01:04:15 +0000 Subject: [PATCH 2/3] Test also with 1.12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82eb70cb8..e8269f320 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: #- '1.7' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia. - '~1.10.0-0' #- '~1.11.0-0' - #- '~1.12.0-0' + - '~1.12.0-0' #- '~1.13.0-0' - 'nightly' os: From 0b24e2d4770a6a0a3e977a624cb07e54654f6e02 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Thu, 26 Feb 2026 01:05:29 +0000 Subject: [PATCH 3/3] Rework a bit the makecpt method that uses grids in input. (shelter it from multi-recompiles) --- src/makecpt.jl | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/makecpt.jl b/src/makecpt.jl index 8857f41c0..744bc8cc0 100644 --- a/src/makecpt.jl +++ b/src/makecpt.jl @@ -89,25 +89,28 @@ function makecpt(w::wrapDatasets, d::Dict)::Union{String, GMTcpt} return r end +function makecpt(G::GMTgrid; kw...) # A version that works on grids. + d = KW(kw...) + have_equalize = (is_in_kwargs(kw, [:equalize]) && d[:equalize] == 1) # Because equalize=true escapes detection in parse_opt_range + opt_T = parse_opt_range(d, "")[1] + !isempty(opt_T) && (d[:T] = opt_T) + makecpt(G::GMTgrid, have_equalize || !isempty(opt_T), d) +end -function makecpt(G::GMTgrid; equalize=false, kw...) # A version that works on grids. +function makecpt(G::GMTgrid, have_equalize, d) # A version that works on grids. # equalize = true uses default grd2cpt. equalize=n uses grd2cpt -Tn # The kw... are those of makecpt or grd2cpt depending on 'equalize'. - val, symb = find_in_kwargs(kw, CPTaliases) + val = find_in_dict(d, CPTaliases)[1] cpt = (val === nothing) ? ((G.cpt != "") ? G.cpt : :turbo) : nothing - d = Dict{Symbol, Any}() - if (equalize == 0 && symb != Symbol() && val === nothing && cpt !== nothing) - # It means kw have a -C, but it can be a C=nothing. Remove the duplicate that was in kw. - d = KW(kw...); delete!(d, symb) # This confusion is due to the crazziness possible in lelandshade() - end - if (equalize == 0) - t = isempty(d) ? kw : d + d[:C] = cpt + if (!have_equalize) range::Vector{Float64} = G.range loc_eps = 0.0004 - makecpt(; T=@sprintf("%.12g/%.12g/256+n", range[5] - loc_eps*abs(range[5]), range[6] + loc_eps*abs(range[6])), C=cpt, t...) + d[:T] = @sprintf("%.12g/%.12g/256+n", range[5] - loc_eps*abs(range[5]), range[6] + loc_eps*abs(range[6])) + makecpt(wrapDatasets("", nothing), d) else - (equalize == 1) ? grd2cpt(G, C=cpt, kw...) : grd2cpt(G, T="$equalize", C=cpt, kw...) + grd2cpt_helper(wrapGrids("", G), d) end end @@ -138,7 +141,7 @@ end # ------------------------------------------------------------------------------------------- function parse_opt_range(d::Dict, cmd::String, opt::String="")::Tuple{String, Vector{Float64}} - symbs = [:T :range :inc :bin] + symbs = [:T :range :inc :bin :equalize] (SHOW_KWARGS[]) && return print_kwarg_opts(symbs, "Tuple | Array | String | Number"), Float64[] # Just print the options Tvec::Vector{Float64} = Float64[] if ((val = find_in_dict(d, symbs)[1]) !== nothing)