Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ include("common_options.jl")
const LEGEND_TYPE = Ref{legend_bag}(legend_bag())# To store Legends info
include("beziers.jl")
include("brokenaxes.jl")
include("choropleth_utils.jl")
include("circfit.jl")
include("crop.jl")
include("custom_symb_funs.jl")
Expand Down Expand Up @@ -327,7 +328,7 @@ include("trend2d.jl")
include("xyz2grd.jl")
include("utils.jl")
include("utils_project.jl")
include("choropleth_utils.jl")
#include("xkcd.jl")
include("drawing/Drawing.jl")
include("extras/anaglyph.jl")
include("extras/analemma.jl")
Expand Down Expand Up @@ -448,6 +449,7 @@ end
#Base.precompile(Tuple{Dict{Symbol, Any}, Vector{String}}) # Here it doesn't print anything.
#Base.precompile(Tuple{typeof(Base.vect), Array{String, 1}, Vararg{Array{String, 1}}})
Base.precompile(Tuple{typeof(GMT.axis), Base.Dict{Symbol, Any}, Bool, Bool, Bool, Bool, Base.Dict{Symbol, Any}})
Base.precompile(Tuple{typeof(GMT.axis), NamedTuple{(:axes, :annot, :grid), Tuple{Symbol, Symbol, Int64}}, Base.Dict{Symbol, Any}})

function __init__(test::Bool=false)
clear_sessions(3600)# Delete stray sessions dirs older than 1 hour
Expand Down
9 changes: 8 additions & 1 deletion src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ end
function _plot(arg1, first::Bool, d::Dict{Symbol, Any})
# Broken axis — intercept before anything else
is_in_dict(d, [:breakx :breaky :xranges :yranges]; del=false) !== nothing && return _brokenplot(mat2ds(arg1), first, d)
# xkcd style
#is_in_dict(d, [:xkcd]; del=false) !== nothing && return _xkcd_plot(arg1, first, d)
# First check if arg1 is a GMTds of a linear fit and if yes, call the plotlinefit() fun
if (isa(arg1, GDtype) && is_in_dict(d, [:linefit :regress]; del=false) !== nothing)
att = isa(arg1, GMTdataset) ? arg1.attrib : arg1[1].attrib
Expand Down Expand Up @@ -1532,7 +1534,12 @@ function helper_vhlines(arg1, vert::Bool, first::Bool, xymin, xymax, percent, d)
!isnan(xymin) && (xy[1] = !percent ? xymin : xy[1] + (xy[2]-xy[1]) * xymin)
!isnan(xymax) && (xy[2] = !percent ? xymax : xy[1] + (xy[2]-xy[1]) * xymax)
D::GMTdataset = mat2ds(mat, x=xy, multi=true, nanseg=true)[1]
vert && (d[:yx] = true) # Because we need to swapp x / y columns in the vlines case
#vert && (d[:yx] = true) # Because we need to swapp x / y columns in the vlines case
if (vert)
for k = 1:size(D,1)
D.data[k,1], D.data[k,2] = D.data[k,2], D.data[k,1]
end
end
delete!(d, [[:xmin], [:xmax], [:ymin], [:ymax]])

common_plot_xyz("", D, "lines", first, false, d)
Expand Down
1 change: 1 addition & 0 deletions src/pshistogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function histogram_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol,A
do_auto = ((val_auto = find_in_dict(d, [:auto :thresholds])[1]) !== nothing) ? true : false # Automatic bounds detetion
(val_auto == 1) && (val_auto = nothing) # If auto=true, we want to pass a nothing to the find_histo_limits() fun
do_getauto = ((val_getauto = find_in_dict(d, [:getauto :getthresholds])[1]) !== nothing) ? true : false
do_getauto && (val_getauto = nothing) # If getauto=true, we want to pass a nothing to the find_histo_limits() fun
do_zoom = ((find_in_dict(d, [:zoom])[1]) !== nothing) ? true : false # Automatic zoom to interesting region

function if_zoom(cmd, opt_R, limit_L, limit_R, hst)
Expand Down
16 changes: 8 additions & 8 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,10 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
elseif (isa(stretch, Tuple) || (isvector(stretch) && length(stretch) == 2))
_inputmin, _inputmax = stretch[1], stretch[2]
end
(isnan(inputmin)) && (mi::Float64 = (isa(A, GItype)) ? A.range[5] : minimum_nan(A))
(isnan(inputmax)) && (ma::Float64 = (isa(A, GItype)) ? A.range[6] : maximum_nan(A))
_inmin::Float64 = (isnan(inputmin)) ? mi : _inputmin
_inmax::Float64 = (isnan(inputmax)) ? ma : _inputmax
(isnan(_inputmin)) && (mi::Float64 = (isa(A, GItype)) ? A.range[5] : minimum_nan(A))
(isnan(_inputmax)) && (ma::Float64 = (isa(A, GItype)) ? A.range[6] : maximum_nan(A))
_inmin::Float64 = (isnan(_inputmin)) ? mi : _inputmin
_inmax::Float64 = (isnan(_inputmax)) ? ma : _inputmax
d1 = _inmax - _inmin
(d1 <= 0.0) && error("Stretch range has inputmin > inputmax.")
d2 = up - low
Expand All @@ -775,7 +775,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
sc *= _tmax
low *= _tmax
if (have_nans)
if (isnan(inputmin) && isnan(inputmax))
if (isnan(_inputmin) && isnan(_inputmax))
if (type == UInt8)
@inbounds for k = 1:numel(A) isnan(A[k]) && (o[k] = 0; continue); o[k] = round(UInt8, low + (A[k] -_inmin) * sc) end
else
Expand All @@ -789,7 +789,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
end
end
else
if (isnan(inputmin) && isnan(inputmax))
if (isnan(_inputmin) && isnan(_inputmax))
if (type == UInt8)
@inbounds for k = 1:numel(A) o[k] = round(UInt8, low + (A[k] -_inmin) * sc) end
else
Expand All @@ -807,7 +807,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
oType = (eltype(A) <: AbstractFloat) ? eltype(A) : Float64
o = Array{oType}(undef, size(A))
if (oType <: Integer && have_nans) # Shitty case
if (isnan(inputmin) && isnan(inputmax)) # Faster case.
if (isnan(_inputmin) && isnan(_inputmax)) # Faster case.
@inbounds for k = 1:numel(A) isnan(A[k]) && (o[k] = 0; continue); o[k] = low + (A[k] -_inmin) * sc end
else
@inbounds for k = 1:numel(A)
Expand All @@ -816,7 +816,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
end
end
else
if (isnan(inputmin) && isnan(inputmax)) # Faster case. No IFs in loop
if (isnan(_inputmin) && isnan(_inputmax)) # Faster case. No IFs in loop
@inbounds for k = 1:numel(A) o[k] = low + (A[k] -_inmin) * sc end
else
@inbounds for k = 1:numel(A)
Expand Down
2 changes: 1 addition & 1 deletion src/utils_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ function _mat2img_u16(@nospecialize(mat), x::Vector{Float64}, y::Vector{Float64}
# Use the keyword `noconv=true` to return GMTimage UInt16 type. I.e., no conversion to UInt8

if ((is_in_dict(d, [:noconv])) !== nothing) # No conversion to UInt8 is wished
return helper_mat2img(mat, x, y, v, hdr, proj4, wkt, GMTcpt(), false, d)
return helper_mat2img(mat, x, y, v, hdr, proj4, wkt, GMTcpt(), get(d, :is_transposed, false), d)
end

img = isempty(img8) ? Array{UInt8, ndims(mat)}(undef, size(mat)) : img8
Expand Down
Loading