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/CondaPkg.toml b/CondaPkg.toml new file mode 100644 index 0000000..27874ab --- /dev/null +++ b/CondaPkg.toml @@ -0,0 +1,8 @@ +[deps] +python = "" +colorcet = "" +tkinter = "" + +[pip.deps] +# Conda package names and versions +seiscm = "" diff --git a/Project.toml b/Project.toml index 0d72277..e66972c 100644 --- a/Project.toml +++ b/Project.toml @@ -5,12 +5,14 @@ version = "1.0.0" [deps] ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" +CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab" PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] ColorSchemes = "3" -PythonPlot = "1.0.5" +CondaPkg = "0.2" +PythonPlot = "1.0" Reexport = "1" julia = "1" diff --git a/deps/build.jl b/deps/build.jl new file mode 100644 index 0000000..5b25dfa --- /dev/null +++ b/deps/build.jl @@ -0,0 +1,14 @@ +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)`)) + 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/examples/plot_example.jl b/examples/plot_example.jl index 28cd66b..d80402d 100644 --- a/examples/plot_example.jl +++ b/examples/plot_example.jl @@ -173,7 +173,8 @@ display(gcf()); # Wiggle plot -# figure(figsize=(5, 5)) -# subplot(111) -# wiggle_plot(shot[1:5:end, 1:10:end], xloc[1:10:end], 0:0.02:4.6; new_fig=false) -# tight_layout();display(gcf()) +figure(figsize=(5, 5)) +subplot(111) +wiggle_plot(shot[1:5:end, 1:10:end], xloc[1:10:end], 0:0.02:4.6; new_fig=false) +tight_layout(); +display(gcf()) diff --git a/src/SlimPlotting.jl b/src/SlimPlotting.jl index 017533e..eb01099 100644 --- a/src/SlimPlotting.jl +++ b/src/SlimPlotting.jl @@ -4,34 +4,14 @@ 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() + ccall(:jl_generating_output, Cint, ()) == 1 && return nothing # 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 +29,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,