Skip to content

Commit

Permalink
add build
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Oct 25, 2024
1 parent d03b8ff commit 093d748
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
16 changes: 16 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using PythonPlot

deps = ("colorcet", "seiscm")

function install_pkg(pkg)
if get(ENV, "JULIA_CONDAPKG_BACKEND", "conda") == "Null"
pyexe = PythonPlot.PythonCall.python_executable_path()
run(Cmd(`$(pyexe) -m pip install --user $(pkg)`))
else
PythonPlot.PythonCall.C.CondaPkg.add_pip(pkg)
end
end

for pkg in deps
install_pkg(pkg)
end
38 changes: 12 additions & 26 deletions src/SlimPlotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,20 @@ using Statistics, ColorSchemes, Reexport
@reexport using PythonPlot

const cc = PythonPlot.PythonCall.pynew()
scm = Dict()


function tryimport(pkg::String)
pyi = try
PythonPlot.pyimport(pkg)
catch e
if get(ENV, "JULIA_CONDAPKG_BACKEND", "conda") == "Null"
pyexe = PythonPlot.python_executable_path()
run(Cmd(`$(pyexe) -m pip install --user $(pkg)`))
else
PythonPlot.PythonCall.C.CondaPkg.add_pip(pkg)
end
PythonPlot.pyimport(pkg)
end
return pyi
end
const scm = PythonPlot.PythonCall.pynew()

scmp = Dict(
"seismic" => scm.seismic,
"bwr" => scm.bwr,
"phase" => scm.phase,
"frequency" => scm.frequency,
)

function __init__()
# import seiscm
scmp = tryimport("seiscm")
global scm["seismic"] = scmp.seismic()
global scm["bwr"] = scmp.bwr()
global scm["phase"] = scmp.phase()
global scm["frequency"] = scmp.frequency()
# Import colorcet
PythonPlot.PythonCall.pycopy!(cc, tryimport("colorcet"))
PythonPlot.PythonCall.pycopy!(cc, pyimport("colorcet"))
# Import SeisCM
PythonPlot.PythonCall.pycopy!(scm, pyimport("seiscm"))
end

export plot_fslice, plot_velocity, plot_simage, plot_sdata, wiggle_plot, compare_shots
Expand All @@ -49,8 +35,8 @@ to_symbol(x) = x
Return the colormap `name` for seiscm. These colormap are preimported as a dictionnary
"""
seiscm(s::Symbol) = scm[to_string(s)]
seiscm(s::String) = scm[s]
seiscm(s::Symbol) = scmp[to_string(s)]()
seiscm(s::String) = scmp[s]()

"""
_plot_with_units(image, spacing; perc=95, cmap=:cet_CET_L1,
Expand Down

0 comments on commit 093d748

Please sign in to comment.