Skip to content

Commit

Permalink
matplotlib
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Aug 31, 2023
1 parent 943a296 commit 49107d3
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 87 deletions.
29 changes: 18 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ plpath = dirname(pathof(SlimPlotting))
ex_path = "$(plpath)/../examples"
doc_path = "$(plpath)/../docs"

weave("$(ex_path)/plot_example.jl"; out_path="$(doc_path)/src/examples.md", doctype="github")
weave(

This comment has been minimized.

Copy link
@mloubout

mloubout Aug 31, 2023

Author Member
"$(ex_path)/plot_example.jl";
out_path = "$(doc_path)/src/examples.md",
doctype = "github",
)

makedocs(sitename="Slim Plotting toolbox",
doctest=false, clean=true,
authors="Mathias Louboutin",
pages = Any[
"Home" => "index.md",
"About" => "README.md",
"Examples" => "examples.md",
"API reference" => "API.md",
])
makedocs(
sitename = "Slim Plotting toolbox",
doctest = false,
clean = true,
authors = "Mathias Louboutin",
pages = Any[
"Home"=>"index.md",
"About"=>"README.md",
"Examples"=>"examples.md",
"API reference"=>"API.md",
],
)

deploydocs(repo="github.com/slimgroup/SlimPlotting.jl")
deploydocs(repo = "github.com/slimgroup/SlimPlotting.jl")
92 changes: 55 additions & 37 deletions examples/plot_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ using SlimPlotting, SegyIO, JLD2
SlimPlotting.PyPlot.close(:all)

#' Path to the files and data used for these examples
data_path = dirname(pathof(SlimPlotting))*"/../data/";
data_path = dirname(pathof(SlimPlotting)) * "/../data/";

#' Read the data
# Pure array
vp = Float32.(segy_read("$(data_path)2dVP.sgy").data);
dm = diff(vp, dims=1);
dm = diff(vp, dims = 1);
shot = Float32.(segy_read("$(data_path)2dshot.segy").data);
xloc = get_header(segy_read("$(data_path)2dshot.segy"), "GroupX")
fslice = JLD2.load("$(data_path)2dfslice.jld");
Expand All @@ -32,18 +32,18 @@ fslice = JLD2.load("$(data_path)2dfslice.jld");

# Dummy structures to check plot with metadata
struct geometry
xloc
xloc::Any
end

struct shotrec
data
dt
geometry
data::Any
dt::Any
geometry::Any
end

struct Phys
data
d
data::Any
d::Any
end

## Make physical objects
Expand All @@ -58,14 +58,15 @@ shotp = shotrec([shot], 0.008, geometry([xloc]));
#' - The standard matplotlib `Greys` colormap
#' - The perceptually accurate `Greys` colormap from colorcet

figure(figsize=(10, 10))
figure(figsize = (10, 10))
subplot(311)
plot_simage(dmp; new_fig=false, name="Seismic")
plot_simage(dmp; new_fig = false, name = "Seismic")
subplot(312)
plot_simage(dm, (10, 20); cmap="Greys", new_fig=false, name="Greys")
plot_simage(dm, (10, 20); cmap = "Greys", new_fig = false, name = "Greys")
subplot(313)
plot_simage(dm, (10, 20); cmap=:cet_CET_L1, new_fig=false, name="Colorcet Greys")
tight_layout();display(gcf())
plot_simage(dm, (10, 20); cmap = :cet_CET_L1, new_fig = false, name = "Colorcet Greys")
tight_layout();
display(gcf());


#' # Velocity
Expand All @@ -74,14 +75,15 @@ tight_layout();display(gcf())
#' - The ColorSchemes `vik` colormap
#' - The perceptually accurate `jet` colormap from colorcet named `cet_rainbow4`

figure(figsize=(10, 10))
figure(figsize = (10, 10))
subplot(311)
plot_velocity(vpp; new_fig=false, name="colorcet jet", cmap="cet_rainbow4")
plot_velocity(vpp; new_fig = false, name = "colorcet jet", cmap = "cet_rainbow4")
subplot(312)
plot_velocity(vp, (10, 20); cmap=:vik, new_fig=false, name="ColorSchemes's vik")
plot_velocity(vp, (10, 20); cmap = :vik, new_fig = false, name = "ColorSchemes's vik")
subplot(313)
plot_velocity(vp, (10, 20); cmap=seiscm(:frequency), new_fig=false, name="Seiscm")
tight_layout();display(gcf())
plot_velocity(vp, (10, 20); cmap = seiscm(:frequency), new_fig = false, name = "Seiscm")
tight_layout();
display(gcf());


#' # Frequency slice
Expand All @@ -91,14 +93,15 @@ tight_layout();display(gcf())
#' - The perceptually accurate `bwr` colormap from colorcet named `cet_CET_D1A`

# Frequency slice
figure(figsize=(10, 5))
figure(figsize = (10, 5))
subplot(131)
plot_fslice(fslice["Freq"][1, :, :], (12.5, 12.5); new_fig=false, name="colorcet bwr")
plot_fslice(fslice["Freq"][1, :, :], (12.5, 12.5); new_fig = false, name = "colorcet bwr")
subplot(132)
plot_fslice(fslicep; cmap=:bwr, new_fig=false, name="bwr")
plot_fslice(fslicep; cmap = :bwr, new_fig = false, name = "bwr")
subplot(133)
plot_fslice(fslicep; cmap=seiscm(:bwr), new_fig=false, name="Seiscm bwr")
tight_layout();display(gcf())
plot_fslice(fslicep; cmap = seiscm(:bwr), new_fig = false, name = "Seiscm bwr")
tight_layout();
display(gcf());



Expand All @@ -111,14 +114,15 @@ tight_layout();display(gcf())
#' - The perceptually accurate `bwr` colormap from colorcet named `cet_CET_D1A`

# Shot record
figure(figsize=(10, 5))
figure(figsize = (10, 5))
subplot(131)
plot_sdata(shotp; new_fig=false, name="matplotlib seismic", cmap="bwr")
plot_sdata(shotp; new_fig = false, name = "matplotlib seismic", cmap = "bwr")
subplot(132)
plot_sdata(shot, (12.5, 0.008); cmap=:cet_CET_D1A, new_fig=false, name="Colorcet bwr")
plot_sdata(shot, (12.5, 0.008); cmap = :cet_CET_D1A, new_fig = false, name = "Colorcet bwr")
subplot(133)
plot_sdata(shot, (12.5, 0.008); cmap=seiscm(:bwr), new_fig=false, name="Seismic bwr")
tight_layout();display(gcf())
plot_sdata(shot, (12.5, 0.008); cmap = seiscm(:bwr), new_fig = false, name = "Seismic bwr")
tight_layout();
display(gcf());


#' ## Seismic greys
Expand All @@ -127,27 +131,41 @@ tight_layout();display(gcf())
#' - The perceptually accurate `greys` colormap from colorcet named `cet_CET_L1`

# Shot record
figure(figsize=(10, 5))
figure(figsize = (10, 5))
subplot(121)
plot_sdata(shotp; new_fig=false, name="colorcet gray", cmap="cet_CET_L1")
plot_sdata(shotp; new_fig = false, name = "colorcet gray", cmap = "cet_CET_L1")
subplot(122)
plot_sdata(shot, (12.5, 0.008); cmap="gray", new_fig=false, name="Greys")
tight_layout();display(gcf())
plot_sdata(shot, (12.5, 0.008); cmap = "gray", new_fig = false, name = "Greys")
tight_layout();
display(gcf());

#' # Compare shot records
#' One of the main visual representation of FWI inversion is to compare the true shot record with the synthetic data from
#' the current velocity model. A good way to visualize this difference is to overlay the two shot records alternating the traces
#' between each shots with a different colormap to check the alignment of the events. We show below how to do this with the
#' `compare_shots` function

figure(figsize=(10, 5))
figure(figsize = (10, 5))
subplot(131)
compare_shots(shotp, shotp; new_fig=false, name="Overlap compare")
compare_shots(shotp, shotp; new_fig = false, name = "Overlap compare")
subplot(132)
compare_shots(shotp, shotp; new_fig=false, cmap=("bwr", "RdBu"), name="Overlap compare custom cmap")
compare_shots(
shotp,
shotp;
new_fig = false,
cmap = ("bwr", "RdBu"),
name = "Overlap compare custom cmap",
)
subplot(133)
compare_shots(shotp, shotp; side_by_side=true, new_fig=false, name="Side by side compare")
tight_layout();display(gcf())
compare_shots(
shotp,
shotp;
side_by_side = true,
new_fig = false,
name = "Side by side compare",
)
tight_layout();
display(gcf());


#' # Wiggle traces
Expand Down
Loading

1 comment on commit 49107d3

@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 created: JuliaRegistries/General/90597

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 v0.1.6 -m "<description of version>" 49107d39b9be7e7087e8edfda41b055fa554c808
git push origin v0.1.6

Please sign in to comment.