GithubHelp home page GithubHelp logo

slimgroup / timeprobeseismic.jl Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 2.0 2.14 MB

Memory efficient seismic inversion via trace estimation

License: MIT License

Julia 100.00%
seismic-inversion unbiased fwi devito judi

timeprobeseismic.jl's Introduction

DOI

TimeProbeSeismic

Wave-equation based inversion with random trace estimation based gradient computation. THis method drastically reduces the memory imprint of adjont-state while managing the loss of accuracy via carefully chosing the probing vector in the range of the wavefield.

Examples

This repository contains a set of example scripts illustrating time probing for seismic inversion and reproduces the results presented in our SEG abstract.

  • layers_probing.jl is a simple example that computes the gradient for a two layer model for varying number of probing vectors and comapres it against the true gradient.
  • overthrust_probing.jl is a similar example computing single source gradients for a more realistic model, the overthrust model.
  • seam_probing.jl is a similar example on the 2D seam model for an OBN setup and higher frequency to highlight or method in imaging settings. Due to the very long recording time, this example requires more probing vectors and a lot of memory to compute the reference true gradient.
  • fwi_2D_overthrust.jl contains an FWI example on the overthrust model comparing FWI with the true gradient to FWI with 32 probing vectors. You can change the number of probing vectors with the variable ps in the script.
  • fwi_2D_overthrust_all.jl is the main iversion script for the SEG abstract result. This script runs standard FWI, probed fwi with 2,4,8,16,32,64,128,256 probing vector and FWI with on the fly Fourier with 2,4,8,16,32,64,128,256 fourier mode. THis is a total of 17 FWI runs and may take a long time to run.
  • splsrtm_seam.jl this script is untested and in developement. It is intended to run sparsity promoting least square migration on the 2D long-offset sparse OBN seam model with probing for memory effiientcy.

Author

This software is develloped as Georgia Institute of Technology as part of the ML4Seismic consortium. For questions or issues, please open an issue on github or contact the author:

Acknowledgment

The developement of this software and its GPU portability was made possible by the NVIDIA Academic Hardware Grant.

Cite us

Please use the following citation if you use our software:

@inbook{doi:10.1190/segam2021-3584072.1,
	author = {Mathias Louboutin and Felix J. Herrmann},
	title = {Ultra-low memory seismic inversion with randomized trace estimation},
	booktitle = {First International Meeting for Applied Geoscience \& Energy Expanded Abstracts},
	chapter = {},
	pages = {787-791},
	year = {2021},
	doi = {10.1190/segam2021-3584072.1},
	URL = {https://library.seg.org/doi/abs/10.1190/segam2021-3584072.1},
	eprint = {https://library.seg.org/doi/pdf/10.1190/segam2021-3584072.1},
}

@article{louboutineage22rte,
   author = "Louboutin, M. and Herrmann, F.",
   title = "Enabling Wave-Based Inversion on Gpus with Randomized Trace Estimation", 
   journal= "",
   year = "2022",
   volume = "2022",
   number = "1",
   pages = "1-5",
   doi = "https://doi.org/10.3997/2214-4609.202210531",
   url = "https://www.earthdoc.org/content/papers/10.3997/2214-4609.202210531",
   publisher = "European Association of Geoscientists & Engineers",
   issn = "2214-4609",
   type = "",
}

timeprobeseismic.jl's People

Contributors

mloubout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

timeprobeseismic.jl's Issues

Compilation issue

(base) francisyin@ipsec-172-16-85-30 scripts % julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.0 (2020-08-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> pwd()
"/Users/francisyin/.julia/dev/TimeProbeSeismic/scripts"

julia> using Pkg

julia> Pkg.activate("/Users/francisyin/.julia/dev/TimeProbeSeismic")
 Activating environment at `~/.julia/dev/TimeProbeSeismic/Project.toml`

julia> Pkg.instantiate()
   Updating registry at `~/.julia/registries/General`
   Updating registry at `~/.julia/registries/SLIMregistryJL`
   Updating git-repo `https://github.com/slimgroup/SLIMregistryJL.git`
    Cloning git-repo `https://GitHub.com/slimgroup/JUDI.jl.git`
ERROR: TypeError: in typeassert, expected VersionNumber, got a value of type Pkg.Types.VersionSpec
Stacktrace:
 [1] load_urls(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:503
 [2] #download_source#54 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:679 [inlined]
 [3] download_source at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:678 [inlined]
 [4] instantiate(::Pkg.Types.Context; manifest::Nothing, update_registry::Bool, verbose::Bool, platform::Pkg.BinaryPlatforms.MacOS, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:868
 [5] instantiate(::Pkg.Types.Context) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:796
 [6] #instantiate#169 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:792 [inlined]
 [7] instantiate() at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:792
 [8] top-level scope at REPL[4]:1

Add seed as an optional input to the operators

Maybe for future reference, we can add seed as an input to lsrtm_objective, fwi_objective, judiJacobian, etc so that we have more control of randomization of probing vectors. Now seed is only in qr_data and not included by any operator.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Probing judiJacobian only does single source

MFE is attached. adjoint(judiJacobian(F0,q,ps,dD))*dD seems only to do RTM probing on the first source (while F0,q include multiple sources). lsrtm_objective works well!

using Pkg
Pkg.activate("TimeProbeSeismic")
Pkg.add(url="https://github.com/slimgroup/JUDI.jl.git",rev="pyload")
Pkg.update()
Pkg.instantiate()
using DrWatson
@quickactivate :TimeProbeSeismic
using JLD2, FFTW, DSP

# Set up model structure
n = (1200, 200)   # (x,y,z) or (x,z)
d = (10., 10.)
o = (0., 0.)

# Velocity [km/s]
v = ones(Float32,n) .+ 0.5f0
v[:,30:end] .= 3.5f0

# Slowness squared [s^2/km^2]
m = (1f0 ./ v).^2
m0 = convert(Array{Float32,2},imfilter(m, Kernel.gaussian(3)))
dm = vec(m - m0)

# Setup info and model structure
nsrc = 2	# number of sources
model = Model(n, d, o, m)
model0 = Model(n, d, o, m0)

# Set up receiver geometry
nxrec = 480
xrec = range(3000f0, stop=9000f0, length=nxrec)
yrec = 0f0
zrec = range(50f0, stop=50f0, length=nxrec)

# receiver sampling and recording time
timeR = 1000f0   # receiver recording time [ms]
dtR = 2f0    # receiver sampling interval [ms]

# Set up receiver structure
recGeometry = Geometry(xrec, yrec, zrec; dt=dtR, t=timeR, nsrc=nsrc)

# Set up source geometry (cell array with source locations for each shot)
xsrc = convertToCell(range(5000f0, stop=7000f0, length=nsrc))
ysrc = convertToCell(range(0f0, stop=0f0, length=nsrc))
zsrc = convertToCell(range(200f0, stop=200f0, length=nsrc))

# source sampling and number of time steps
timeS = 1000f0  # ms
dtS = 2f0   # ms

# Set up source structure
srcGeometry = Geometry(xsrc, ysrc, zsrc; dt=dtS, t=timeS)

# setup wavelet
f0 = 0.015f0     # kHz
wavelet = ricker_wavelet(timeS, dtS, f0)
q = judiVector(srcGeometry, wavelet)

# Set up info structure for linear operators
ntComp = get_computational_nt(srcGeometry, recGeometry, model)
info = Info(prod(n), nsrc, ntComp)

###################################################################################################

# Write shots as segy files to disk
opt = Options(isic=true)

# Setup operators
Pr = judiProjection(info, recGeometry)
F0 = judiModeling(info, model0; options=opt)
Ps = judiProjection(info, srcGeometry)
F0 = Pr*F0*adjoint(Ps)
J = judiJacobian(F0, q)

# Linearized modeling
dD = J*dm
# Adjoint jacobian
println("conventional RTM")
@time rtm = adjoint(J)*dD
# probing RTM

println("32 probing vectors")
@time rtm_32 = adjoint(judiJacobian(F0,q,32,dD))*dD

figure();imshow(rtm.data',aspect=3,cmap="Greys",vmin=-0.1*norm(rtm.data,Inf),vmax=0.1*norm(rtm.data,Inf));title("conventional RTM")
figure();imshow(rtm_32.data',aspect=3,cmap="Greys",vmin=-0.1*norm(rtm.data,Inf),vmax=0.1*norm(rtm.data,Inf));title("RTM w/ 32 probing vectors")

f, g = JUDI.lsrtm_objective(model0, q, dD, 0f0 .* dm; nlind=false, options=opt)
f_32, g_32 = JUDI.lsrtm_objective(model0, q, dD, 0f0 .* dm, 32; nlind=false, options=opt)

figure();imshow(-g',aspect=3,cmap="Greys",vmin=-0.1*norm(rtm.data,Inf),vmax=0.1*norm(rtm.data,Inf));title("conventional RTM (by lsrtm_objective)")
figure();imshow(-g_32',aspect=3,cmap="Greys",vmin=-0.1*norm(rtm.data,Inf),vmax=0.1*norm(rtm.data,Inf));title("RTM w/ 32 probing vectors (by lsrtm_objective)")

MFErtmprob
MFErtm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.