PyLops API#

The Application Programming Interface (API) of PyLops can be loosely seen as composed of a stack of three main layers:

  • Linear operators: building blocks for the setting up of inverse problems

  • Solvers: interfaces to a variety of solvers, providing an easy way to augment an inverse problem with additional regularization and/or preconditioning term

  • Applications: high-level interfaces allowing users to easily setup and solve specific problems (while hiding the non-needed details - i.e., creation and setup of linear operators and solvers).

Linear operators#

Templates#

LinearOperator([Op, dtype, shape, dims, ...])

Common interface for performing matrix-vector products.

FunctionOperator(f, *args, **kwargs)

Function Operator.

MemoizeOperator(Op[, max_neval])

Memoize Operator.

PyTensorOperator(LOp)

PyTensor Op which applies a PyLops Linear Operator, including gradient support.

TorchOperator(Op[, batch, flatten, device, ...])

Wrap a PyLops operator into a Torch function.

JaxOperator(Op)

Enable JAX backend for PyLops operator.

Basic operators#

MatrixMult(A[, otherdims, forceflat, dtype, ...])

Matrix multiplication.

Identity(N[, M, inplace, forceflat, dtype, name])

Identity operator.

Zero(N[, M, forceflat, dtype, name])

Zero operator.

Diagonal(diag[, dims, axis, dtype, name])

Diagonal operator.

Transpose(dims, axes[, dtype, name])

Transpose operator.

Flip(dims[, axis, dtype, name])

Flip along an axis.

Roll(dims[, axis, shift, dtype, name])

Roll along an axis.

Pad(dims, pad[, dtype, name])

Pad operator.

Sum(dims[, axis, forceflat, dtype, name])

Sum operator.

Symmetrize(dims[, axis, dtype, name])

Symmetrize along an axis.

Restriction(dims, iava[, axis, inplace, ...])

Restriction (or sampling) operator.

Regression(taxis, order[, dtype, name])

Polynomial regression.

LinearRegression(taxis[, dtype, name])

Linear regression.

CausalIntegration(dims[, axis, sampling, ...])

Causal integration.

Spread(dims, dimsd[, table, dtable, fh, ...])

Spread operator.

VStack(ops[, nproc, forceflat, inoutengine, ...])

Vertical stacking.

HStack(ops[, nproc, forceflat, inoutengine, ...])

Horizontal stacking.

Block(ops[, nproc, forceflat, dtype])

Block operator.

BlockDiag(ops[, nproc, forceflat, ...])

Block-diagonal operator.

Kronecker(Op1, Op2[, dtype, name])

Kronecker operator.

Real(dims[, dtype, name])

Real operator.

Imag(dims[, dtype, name])

Imag operator.

Conj(dims[, dtype, name])

Complex conjugate operator.

ToCupy(dims[, dtype, name])

Convert to CuPy.

Smoothing and derivatives#

Smoothing1D(nsmooth, dims[, axis, dtype, name])

1D Smoothing.

Smoothing2D(nsmooth, dims[, axes, dtype, name])

2D Smoothing.

FirstDerivative(dims[, axis, sampling, ...])

First derivative.

SecondDerivative(dims[, axis, sampling, ...])

Second derivative.

Laplacian(dims[, axes, weights, sampling, ...])

Laplacian.

Gradient(dims[, sampling, edge, kind, ...])

Gradient.

FirstDirectionalDerivative(dims, v[, ...])

First Directional derivative.

SecondDirectionalDerivative(dims, v[, ...])

Second Directional derivative.

Signal processing#

Convolve1D(dims, h[, offset, axis, method, ...])

1D convolution operator.

Convolve2D(dims, h[, offset, axes, method, ...])

2D convolution operator.

ConvolveND(dims, h[, offset, axes, method, ...])

ND convolution operator.

NonStationaryConvolve1D(dims, hs, ih[, ...])

1D non-stationary convolution operator.

NonStationaryConvolve2D(dims, hs, ihx, ihz)

2D non-stationary convolution operator.

NonStationaryConvolve3D(dims, hs, ihx, ihy, ihz)

3D non-stationary convolution operator.

NonStationaryFilters1D(inp, hsize, ih[, ...])

1D non-stationary filter estimation operator.

NonStationaryFilters2D(inp, hshape, ihx, ihz)

2D non-stationary filter estimation operator.

Interp(dims, iava[, axis, kind, dtype, name])

Interpolation operator.

Bilinear(iava, dims[, forceflat, dtype, name])

Bilinear interpolation operator.

FFT(dims[, axis, nfft, sampling, norm, ...])

One dimensional Fast-Fourier Transform.

FFT2D(dims[, axes, nffts, sampling, norm, ...])

Two dimensional Fast-Fourier Transform.

FFTND(dims[, axes, nffts, sampling, norm, ...])

N-dimensional Fast-Fourier Transform.

Shift(dims, shift[, axis, nfft, sampling, ...])

Shift operator

DWT(dims[, axis, wavelet, level, dtype, name])

One dimensional Wavelet operator.

DWT2D(dims[, axes, wavelet, level, dtype, name])

Two dimensional Wavelet operator.

DWTND(dims[, axes, wavelet, level, dtype, name])

N-dimensional Wavelet operator.

DCT(dims[, type, axes, dtype, workers, name])

Discrete Cosine Transform.

DTCWT(dims[, biort, qshift, level, ...])

Dual-Tree Complex Wavelet Transform

Seislet(slopes[, sampling, level, kind, ...])

Two dimensional Seislet operator.

Radon2D(taxis, haxis, pxaxis[, kind, ...])

Two dimensional Radon transform.

Radon3D(taxis, hyaxis, hxaxis, pyaxis, pxaxis)

Three dimensional Radon transform.

FourierRadon2D(taxis, haxis, pxaxis, nfft[, ...])

2D Fourier Radon transform

FourierRadon3D(taxis, hyaxis, hxaxis, ...[, ...])

3D Fourier Radon transform

ChirpRadon2D(taxis, haxis, pmax[, dtype, name])

2D Chirp Radon transform

ChirpRadon3D(taxis, hyaxis, hxaxis, pmax[, ...])

3D Chirp Radon transform

Sliding1D(Op, dim, dimd, nwin, nover[, ...])

1D Sliding transform operator.

Sliding2D(Op, dims, dimsd, nwin, nover[, ...])

2D Sliding transform operator.

Sliding3D(Op, dims, dimsd, nwin, nover, nop)

3D Sliding transform operator.w

Patch2D(Op, dims, dimsd, nwin, nover, nop[, ...])

2D Patch transform operator.

Patch3D(Op, dims, dimsd, nwin, nover, nop[, ...])

3D Patch transform operator.

Fredholm1(G[, nz, saveGt, usematmul, dtype, ...])

Fredholm integral of first kind.

Wave-Equation processing#

PressureToVelocity(nt, nr, dt, dr, rho, vel)

Pressure to Vertical velocity conversion.

UpDownComposition2D(nt, nr, dt, dr, rho, vel)

2D Up-down wavefield composition.

UpDownComposition3D(nt, nr, dt, dr, rho, vel)

3D Up-down wavefield composition.

BlendingContinuous(nt, nr, ns, dt, times[, ...])

Continuous blending operator

BlendingGroup(nt, nr, ns, dt, times, ...[, ...])

Group blending operator

BlendingHalf(nt, nr, ns, dt, times, ...[, ...])

Half blending operator

MDC(G, nt, nv[, dt, dr, twosided, ...])

Multi-dimensional convolution.

PhaseShift(vel, dz, nt, freq, kx[, ky, ...])

Phase shift operator

Kirchhoff(z, x, t, srcs, recs, vel, wav, ...)

Kirchhoff demigration operator.

AcousticWave2D(shape, origin, spacing, vp, ...)

Devito Acoustic propagator.

Geophysical subsurface characterization#

avo.AVOLinearModelling(theta[, vsvp, nt0, ...])

AVO Linearized modelling.

poststack.PoststackLinearModelling(wav, nt0)

Post-stack linearized seismic modelling operator.

prestack.PrestackLinearModelling(wav, theta)

Pre-stack linearized seismic modelling operator.

prestack.PrestackWaveletModelling(m, theta, nwav)

Pre-stack linearized seismic modelling operator for wavelet.

Solvers#

Template#

Solver(Op[, callbacks])

This is a template class which a user must subclass when implementing a new solver.

Basic#

CG(Op[, callbacks])

Conjugate gradient

CGLS(Op[, callbacks])

Conjugate gradient least squares

LSQR(Op)

Solve an overdetermined system of equations given an operator Op and data y using LSQR iterations.

cg(Op, y[, x0, niter, tol, show, itershow, ...])

Conjugate gradient

cgls(Op, y[, x0, niter, damp, tol, show, ...])

Conjugate gradient least squares

lsqr(Op, y[, x0, damp, atol, btol, conlim, ...])

LSQR

Least-squares#

NormalEquationsInversion(Op[, callbacks])

Inversion of normal equations.

RegularizedInversion(Op[, callbacks])

Regularized inversion.

PreconditionedInversion(Op[, callbacks])

Preconditioned inversion.

normal_equations_inversion(Op, y, Regs[, ...])

Inversion of normal equations.

regularized_inversion(Op, y, Regs[, x0, ...])

Regularized inversion.

preconditioned_inversion(Op, y, P[, x0, ...])

Preconditioned inversion.

Sparsity#

IRLS(Op[, callbacks])

Iteratively reweighted least squares.

OMP(Op[, callbacks])

Orthogonal Matching Pursuit (OMP).

ISTA(Op[, callbacks])

Iterative Shrinkage-Thresholding Algorithm (ISTA).

FISTA(Op[, callbacks])

Fast Iterative Shrinkage-Thresholding Algorithm (FISTA).

SPGL1(Op[, callbacks])

Spectral Projected-Gradient for L1 norm.

SplitBregman(Op[, callbacks])

Split Bregman for mixed L2-L1 norms.

irls(Op, y[, x0, nouter, threshR, epsR, ...])

Iteratively reweighted least squares.

omp(Op, y[, niter_outer, niter_inner, ...])

Orthogonal Matching Pursuit (OMP).

ista(Op, y[, x0, niter, SOp, eps, alpha, ...])

Iterative Shrinkage-Thresholding Algorithm (ISTA).

fista(Op, y[, x0, niter, SOp, eps, alpha, ...])

Fast Iterative Shrinkage-Thresholding Algorithm (FISTA).

spgl1(Op, y[, x0, SOp, tau, sigma, show])

Spectral Projected-Gradient for L1 norm.

splitbregman(Op, y, RegsL1[, x0, ...])

Split Bregman for mixed L2-L1 norms.

Callbacks#

Callbacks()

This is a template class which a user must subclass when implementing callbacks for a solver.

MetricsCallback(xtrue[, Op, which])

Metrics callback

Applications#

Wave-Equation processing#

SeismicInterpolation(data, nrec, iava[, ...])

Seismic interpolation (or regularization).

Deghosting(p, nt, nr, dt, dr, vel, zrec[, ...])

Wavefield deghosting.

WavefieldDecomposition(p, vz, nt, nr, dt, ...)

Up-down wavefield decomposition.

MDD(G, d[, dt, dr, nfmax, wav, twosided, ...])

Multi-dimensional deconvolution.

Marchenko(R[, dt, nt, dr, nfmax, wav, toff, ...])

Marchenko redatuming

LSM(z, x, t, srcs, recs, vel, wav, wavcenter)

Least-squares Migration (LSM).

Geophysical subsurface characterization#

poststack.PoststackInversion(data, wav[, ...])

Post-stack linearized seismic inversion.

prestack.PrestackInversion(data, theta, wav)

Pre-stack linearized seismic inversion.