3D models with side walls

These examples show a GMT.jl version of a PyGMT post in the GMT forum and that can be found at the original author’s, JiahongLuo, Github site

The function let us easily plot images on the sides of a cube. That function can also be used to create those side figures directly from a 3D cube grid.

using GMT

# Download data from:
model = gmtread("https://github.com/ShouchengHan/USTClitho2.0/blob/main/USTClitho2.0.wrst.sea_level.txt");

# Create two data cubes (grids) with the Vp and Vs velocities
Cvp = xyzw2cube(model);
Cvs = xyzw2cube(model, zcol=5);

# Add names to the cube layers to be used as titles in next figure
Cvp.names = ["Depth = $(Int(i)) km" for i in Cvp.v];
Cvs.names = ["Depth = $(Int(i)) km" for i in Cvs.v];
gmtread [WARNING]: Long input record (4647 bytes) was truncated to first 4094 bytes!

gmtread [WARNING]: Long input record (4498 bytes) was truncated to first 4094 bytes!

Warning:  file "https://github.com/ShouchengHan/USTClitho2.0/blob/main/USTClitho2.0.wrst.sea_level.txt" is empty or has no data after the header.

@ GMT C:\Users\j\.julia\dev\GMT\src\gmtreadwrite.jl:242
The dataset must contain at least 4 columns (x,y,z,w)

Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] xyzw2cube(D::GMTdataset{Float64, 2}; zcol::Int64, datatype::DataType, tit::String, names::Vector{String}, varnames::Vector{String})
   @ GMT C:\Users\j\.julia\dev\GMT\src\utils_types.jl:1818
 [3] xyzw2cube(D::GMTdataset{Float64, 2})
   @ GMT C:\Users\j\.julia\dev\GMT\src\utils_types.jl:1815
 [4] top-level scope
   @ In[2]:4

Show all 12 layers of the P-waves velocity in a figure. We use a diffent colormap for each layer to avoid that layers become too monochromatic.

viz(Cvp, colorbar=true, cmap=:same, title="Vp model")

Show the P and S velocities with a slight variation of the top layer. For the P-velocity we plot the topography on top and for the S-velocity we show the superficial S velocity but apply a shading effect calculated from the topography grid.

using GMT   # Hide
cubeplot(Cvp, top="@earth_relief_05m", colorbar=("xlabel=P-wave velocity", "ylabel=km/s"), zdown=true, title="Vp model")
cubeplot!(Cvs, top="@earth_relief_05m", topshade=true, zdown=true, colorbar=("xlabel=S-wave velocity", "ylabel=km/s"), xshift=18, title="Vs model", show=true)
UndefVarError: `Cvp` not defined

Stacktrace:
 [1] top-level scope
   @ In[3]:2

To finish we show how to make an inset view in the 3D model.

using GMT   # Hide
cubeplot(Cvp, top="@earth_relief", inset=(lon=100, lat=35), topshade=true, zdown=true,
         colorbar=("xlabel=P-wave velocity", "ylabel=km/s"), show=true)
UndefVarError: `Cvp` not defined

Stacktrace:
 [1] top-level scope
   @ In[4]:2