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 bb9ca94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
PYTHON: ""
JULIA_NUM_THREADS: 1

steps:
- uses: actions/checkout@v2
Expand Down
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
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
SegyIO = "157a0f19-4d44-4de5-a0d0-07e2f0ac4dfa"
Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"

Expand Down
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 bb9ca94

Please sign in to comment.