diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b9001da..b7ca303 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest env: - PYTHON: "" + JULIA_NUM_THREADS: 1 steps: - uses: actions/checkout@v2 diff --git a/deps/build.jl b/deps/build.jl new file mode 100644 index 0000000..88bfa56 --- /dev/null +++ b/deps/build.jl @@ -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 \ No newline at end of file diff --git a/docs/Project.toml b/docs/Project.toml index 6b7d759..ff71bab 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -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" diff --git a/src/SlimPlotting.jl b/src/SlimPlotting.jl index 017533e..5bfe065 100644 --- a/src/SlimPlotting.jl +++ b/src/SlimPlotting.jl @@ -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 @@ -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,