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 606eee5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 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
33 changes: 6 additions & 27 deletions src/SlimPlotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,13 @@ 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()

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, PythonPlot.pyimport("colorcet"))
# Import SeisCM
PythonPlot.PythonCall.pycopy!(scm, PythonPlot.pyimport("seiscm"))
end

export plot_fslice, plot_velocity, plot_simage, plot_sdata, wiggle_plot, compare_shots
Expand All @@ -49,8 +28,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) = seiscm(to_string(s))
seiscm(s::String) = PythonPlot.pygetattr(scm, s)()

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

0 comments on commit 606eee5

Please sign in to comment.