Skip to content

Commit

Permalink
add build
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Oct 28, 2024
1 parent d03b8ff commit be534a2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 34 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
10 changes: 10 additions & 0 deletions CondaPkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
channels = ["conda-forge", "anaconda"]

[deps]
python = ""
colorcet = ""
tk = ""

[pip.deps]
# Conda package names and versions
seiscm = ""
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 14 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -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
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
9 changes: 5 additions & 4 deletions examples/plot_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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())
34 changes: 7 additions & 27 deletions src/SlimPlotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

2 comments on commit be534a2

@mloubout
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/117989

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" be534a2dc229f0ceeb10af2111798d8d4130c1cc
git push origin v1.0.0

Please sign in to comment.