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
2 changes: 1 addition & 1 deletion src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ using GMT.Laszip
#include("ImageFeatures/ImageFeatures.jl")
#using GMT.ImageFeatures

@compile_workload let
@compile_workload begin
G_API[1] = GMT_Create_Session("GMT", 2, GMT_SESSION_BITFLAGS)
#GMT.parse_B(Dict{Symbol, Any}(:frame => (annot=10, title="Ai Ai"), :grid => (pen=2, x=10, y=20)), "", " -Baf -BWSen");
#GMT.parse_R(Dict{Symbol, Any}(:xlim => (1,2), :ylim => (3,4), :zlim => (5,6)), "");
Expand Down
14 changes: 13 additions & 1 deletion src/common_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2802,6 +2802,18 @@ function get_cpt_set_R(d::Dict, cmd0::String, cmd::String, opt_R::String, got_fn
return cmd, N_used, arg1, arg2, arg3
end

# This function is a mini makecpt. Put it here so that we can call it from a future GMTcore module that will split from "modules"
function makecpt_raw(cmd::String, arg1=nothing)::GMTcpt
# Raw version that already knows what the command is and has no input data.
(IamModern[1] && !contains(cmd, " -H")) && (cmd *= " -H")
!startswith(cmd, "makecpt ") && (cmd = "makecpt " * cmd)
_r = gmt_GMTcpt(cmd, arg1)
r::GMTcpt = (_r !== nothing) ? _r : GMTcpt() # _r === nothing when we save CPT on disk.
(contains(cmd, " -N") && !isempty(r)) && (r.bfn = ones(3,3)) # Cannot remove the bfn like in plain GMT so make it all whites
CURRENT_CPT[1] = r
return r
end

#=
function get_colorbar_pos(anchor)
hack_modern_session(GMT.CTRL.pocket_R[1], GMT.CTRL.pocket_J[1] * GMT.CTRL.pocket_J[3], " -Baf -Bza", fullremove=true) # Start a modern session
Expand Down Expand Up @@ -4191,7 +4203,7 @@ function showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_
if (haskey(d, :show) && d[:show] != 0)
if ((isdefined(Main, :IJulia) && Main.IJulia.inited) || (isdefined(Main, :VSCodeServer) && get(ENV, "DISPLAY_IN_VSC", "") != "no"))
#https://stackoverflow.com/questions/70620607/how-can-i-programmatically-check-that-i-am-running-code-in-a-notebook-in-julia
(fname == "") ? display(MIME"image/png"(), read(out)) : @warn("In Jupyter you can only visualize png files. File $fname was saved in disk though.")
(fname == "" || endswith(fname, ".png")) ? display(MIME"image/png"(), read(out)) : @warn("In Jupyter you can only visualize png files. File $fname was saved in disk though.")
elseif (isPluto)
retPluto = true
elseif (!isFranklin[1]) # !isFranklin is true when building the docs and there we don't want displays.
Expand Down
15 changes: 4 additions & 11 deletions src/makecpt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ Make static color palette tables (CPTs). The second form accepts a name of one o
- **A** | **alpha** | **transparency** :: [Type => Str]

Sets a constant level of transparency (0-100) for all color slices.
- $(opt_C)
- **C** | **color** | **colormap** | **cmap** | **colorscale** :: [Type => Str]

Give a CPT name or specify -Ccolor1,color2[,color3,...] to build a linear continuous CPT from those
colors automatically.
- **D** | **bg** | **background** :: [Type => Str | []] `Arg = [i|o]`

Select the back- and foreground colors to match the colors for lowest and highest
Expand Down Expand Up @@ -85,16 +88,6 @@ function makecpt(cmd0::String, arg1, d::Dict)::Union{String, GMTcpt}
return r
end

function makecpt_raw(cmd::String, arg1=nothing)::GMTcpt
# Raw version that already knows what the command is and has no input data.
(IamModern[1] && !contains(cmd, " -H")) && (cmd *= " -H")
!startswith(cmd, "makecpt ") && (cmd = "makecpt " * cmd)
_r = gmt_GMTcpt(cmd, arg1)
r::GMTcpt = (_r !== nothing) ? _r : GMTcpt() # _r === nothing when we save CPT on disk.
(contains(cmd, " -N") && !isempty(r)) && (r.bfn = ones(3,3)) # Cannot remove the bfn like in plain GMT so make it all whites
CURRENT_CPT[1] = r
return r
end

function makecpt(G::GMTgrid; equalize=false, kw...) # A version that works on grids.
# equalize = true uses default grd2cpt. equalize=n uses grd2cpt -Tn
Expand Down
22 changes: 14 additions & 8 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ function bar(f::Function, range_x=nothing; first=true, kw...)
end
bar!(f::Function, rang=nothing; kw...) = bar(f, rang; first=false, kw...)

bar(arg1, arg2; first=true, kw...) = common_plot_xyz("", cat_2_arg2(arg1, arg2, true), "bar", first, false; kw...)
bar!(arg1, arg2; kw...) = common_plot_xyz("", cat_2_arg2(arg1, arg2, true), "bar", false, false; kw...)
bar(arg1, arg2; first=true, kw...) = common_plot_xyz("", cat_2_arg2(arg1, Float64.(arg2), true), "bar", first, false; kw...)
bar!(arg1, arg2; kw...) = common_plot_xyz("", cat_2_arg2(arg1, Float64.(arg2), true), "bar", false, false; kw...)
bar(arg; kw...) = bar("", arg; kw...)
bar!(arg; kw...) = common_plot_xyz("", cat_1_arg(arg, true), "bar", false, false; kw...)
# ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2251,38 +2251,44 @@ Plot a stereonet map in either Schmidt or Wulff projection.
and line & marker settings (see ``plots`` manual for details on them).

In case the produced figure is still not satisfactory, you can make one by yourself.
For that use the `Dv, Dp = _stereonet(mat)` function to get the fault planes and poles. A good place
For that use the `Dv, Dp = stereonet_data(mat)` function to get the fault planes and poles. A good place
to start is the `stereonet` function itself. Type ``@edit GMT.stereonet([0 0])`` to see the code.

### Example
```julia
stereonet([90 30; 180 45; 270 60; 0 15; 30 45; 120 48; 225 27; 350 80])
stereonet([90 30; 180 45; 270 60; 0 15; 30 45; 120 48; 225 27; 350 80], show=true)
```
"""
function stereonet(mat::AbstractArray{T,2}; first=true, schmidt=true, wulff=false, kw...) where T<:Real
d = KW(kw)
show = (find_in_dict(d, [:show])[1] !== nothing) ? false : true # DEfault is 'true'.
_stereonet(mat, first, schmidt, wulff, d)
end
function _stereonet(mat::AbstractArray{T,2}, first::Bool, schmidt::Bool, wulff::Bool, d) where T<:Real
show = ((val = find_in_dict(d, [:show])[1]) !== nothing && val != 0)
savefig = find_in_dict(d, [:savefig :figname :name])[1];
Vd = get(d, :Vd, 0)
wulff && (schmidt = false) # Wulff stereonet

Dv, Dp = _stereonet(mat)
Dv, Dp = stereonet_data(mat)
prj = schmidt ? :laea : (name=:stereo, center=[0,0])# "S0/0/15c"
(is_in_dict(d, [:lc :linecolor]) === nothing) && (d[:lc] = "red")
(is_in_dict(d, [:lt :linethickness]) === nothing) && (d[:lt] = 0.5)
d[:par] = (MAP_GRID_PEN_PRIMARY="0.25,gray", MAP_GRID_PEN_SECONDARY="0.25,black")
d[:B], d[:R], d[:J] = "pg5 sg20", :d, prj
common_plot_xyz("", Dv, "plot", first, false, d) # Plot the fault planes
(Vd != 0) && (d[:Vd] = Vd)

(is_in_dict(d, [:marker :Marker :shape]) === nothing) && (d[:marker] = "circ")
(is_in_dict(d, [:mec :markeredgecolor :MarkerEdgeColor]) === nothing) && (d[:mec] = "0.0p,black")
(is_in_dict(d, [:mc :markercolor]) === nothing) && (d[:mc] = "blue")
(is_in_dict(d, [:ms :markersize :MarkerSize :size]) === nothing) && (d[:ms] = "3p")
common_plot_xyz("", Dp, "stereonet", false, false, d) # Plot the poles
basemap!(J="P" * CTRL.pocket_J[2] * "+a", B="a15", show=show)
basemap!(J="P" * CTRL.pocket_J[2] * "+a", B="a15", show=show, savefig=savefig)
end
stereonet!(mat::AbstractArray{T,2}; schmidt=true, wulff=false, kw...) where T<:Real =
stereonet(mat; first=false, schmidt=schmidt, wulff=wulff, kw...)

function _stereonet(mat::AbstractArray{T,2}) where T<:Real
function stereonet_data(mat::AbstractArray{T,2}) where T<:Real
# This function computes the fault planes and the poles. Returns a vector of GMTdataset
# with the fault planes and a GMTdataset with the poles.
@assert size(mat,2) >= 2 "Input matrix must have at least two columns: azimuth and plunge"
Expand Down
Loading