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: 2 additions & 2 deletions src/segy/segy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Plot a SEGY file as a seismic data image.
"""
segy!(cmd0::String; kwargs...) = segy_helper(cmd0; first=false, kwargs...)
segy!(cmd0::String; kwargs...) = segy(cmd0; first=false, kwargs...)
function segy(cmd0::String; first=true, kw...)
#(cmd0 === "") && error("Missing input segY file name to run this module.")
d, K, O = init_module(first==1, kw...) # Also checks if the user wants ONLY the HELP mode
Expand Down Expand Up @@ -49,7 +49,7 @@ end

Plot a SEGY file in 3-D as a seismic data image.
"""
segyz!(cmd0::String; kwargs...) = segyz_helper(cmd0; first=false, kwargs...)
segyz!(cmd0::String; kwargs...) = segyz(cmd0; first=false, kwargs...)
function segyz(cmd0::String; first=true, kw...)
d, K, O = init_module(first==1, kw...) # Also checks if the user wants ONLY the HELP mode
segyz_helper(cmd0, O, K, d)
Expand Down
28 changes: 28 additions & 0 deletions src/subplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function subplot(fim::String, stop::Bool, d::Dict{Symbol, Any})
gmt("gmtset MAP_FRAME_TYPE fancy")
catch; resetGMT()
end
remove_map_origin() # Remove MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file (see comments in function)
IamSubplot[], IamModern[] = true, true
elseif (do_set)
(!IamSubplot[]) && error("Cannot call subplot(set, ...) before setting dimensions")
Expand Down Expand Up @@ -216,4 +217,31 @@ function mura_arg(arg)::Dict
else d = (isa(arg, NamedTuple)) ? nt2dict(arg) : arg
end
d
end

# --------------------------------------------------------------------------
function remove_map_origin()
# Remove MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file
# The problem: GMT CLI when it creates the gmt.conf.0.subplot file, does not set MAP_ORIGIN_X and MAP_ORIGIN_Y
# but because we fiddle a lot with themes and make the classic mode behave like modern, we end up setting them
# and that has a drastic effect of burning permanently in the GMT_keyword_updated[] internal variable, AND THERE
# IS NO WAY TO UNSET things inside GMT_keyword_updated[] from externals. When gmt_begin() is called, the
# gmt.conf.0.subplot file is created and the MAP_ORIGIN_X and MAP_ORIGIN_Y are set. But this SCREWS the location
# of the colorbars when we have subplots because they all overlap each other. The only solution found is to remove
# the MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file.
# WARNING: If we ever implement the 'figure' case, this function will need to be modified to account for the
# figure number. As it is, the "0" in gmt.conf.0.subplot stands for figure 0.
API = unsafe_load(convert(Ptr{GMTAPI_CTRL}, G_API[]))
session_dir = unsafe_string(API.gwf_dir)
fname = session_dir * filesep * "gmt.conf.0.subplot"
!isfile(fname) && return
lines = readlines(fname)
filtered = filter(l -> !startswith(l, "MAP_ORIGIN_"), lines)
length(filtered) == length(lines) && return nothing # Nothing to remove
open(fname, "w") do io
for l in filtered
println(io, l)
end
end
return nothing
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ using InteractiveUtils

println(" SEGY")
segy("", R="-35/6/0/30", J="x0.15i/-0.15i", D=0.35, C=8.0, F=:green, Q=(b=-1.2, x=0.1, y=0.1), S=:c, W=true, Vd=2);
segy!("", D=0.35, C=8.0, F=:green, Q=(b=-1.2, x=0.1, y=0.1), S=:c, W=true, Vd=2);
segyz("", R="-35/6/0/30/0/30", J="x0.15i/-0.15i", Jz="-0.15i", p=(175,5), D=0.35, C=8.0, F=:green, Q=(b=-1.2,), S="c/5", W=true, Vd=2);
segyz!("", Jz="-0.15i", p=(175,5), D=0.35, C=8.0, F=:green, Q=(b=-1.2,), S="c/5", W=true, Vd=2);
segy2grd("", R="-35/6/0/30", I=0.1, Vd=2);

#G = gmt("grdmath -R-15/15/-15/15 -I1 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL =");
Expand Down
Loading