Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge for v2.2.0 #543

Merged
merged 93 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
e1e3675
fix: modify solvers to use matvec/rmatvec instead of @/.H @
mrava87 Mar 26, 2023
777eac2
feature: added forceflat to operators with ambiguous rmatvec
mrava87 Mar 26, 2023
acba1c5
minor: add check for forceflat based on len(dims)
mrava87 Mar 27, 2023
e7045d0
minor: fix typo in LinearOperator
mrava87 Mar 27, 2023
3e9ead4
feature: added forceflat on HStack and VStack
mrava87 Mar 27, 2023
6626213
feature: added forceflat to HStack and VStack
mrava87 Mar 27, 2023
ee3ec0c
Merge branch 'patch-flatten' of https://github.com/mrava87/pylops int…
mrava87 Mar 27, 2023
f156ac4
feature: set forceflat=True for HStack/VStack if Ops have different d…
mrava87 Mar 28, 2023
b523377
feature: added forceflat to BlockDiag
mrava87 Mar 28, 2023
bd59748
doc: fixes https://github.com/PyLops/pylops/issues/503
mrava87 Apr 1, 2023
c47352f
Merge pull request #504 from mrava87/doc-tutorial3
mrava87 Apr 1, 2023
169bd8d
feature: Added forceflat to BlockDiag and MatrixMult
mrava87 Apr 7, 2023
0ed9bff
feature: changed ISTA and FISTA to use matvec/rmatvec (or *mat)
mrava87 Apr 8, 2023
b3be22c
minor: fixed flake8
mrava87 Apr 8, 2023
6180b5a
feature: added ndarray capabilities to Identity
mrava87 Apr 8, 2023
d37d3a4
minor: fix flake8 in Identity
mrava87 Apr 8, 2023
a9afeb3
feature: added forceflat to Block
mrava87 Apr 15, 2023
200973f
feature: allow NDarray for Zero
mrava87 Apr 15, 2023
114be11
minor: reduced redundant code in Zero init
mrava87 Apr 16, 2023
cfcdb55
minor: added forceflat to docstring of Zero
mrava87 Apr 16, 2023
89e55d3
minor: remove unwanted print from BlockDiag
mrava87 Apr 16, 2023
c180024
feature: added conv with long filters
mrava87 May 2, 2023
b410a9f
minor: converted Convolve1d into a class
mrava87 May 2, 2023
a0fdd06
test: shorten wavelet to have nt>ntwav
mrava87 May 2, 2023
6478d56
doc: added example with convolution with large filter
mrava87 May 7, 2023
33e72ec
feat: forceflat test for Sum
cako May 8, 2023
5ee83c4
fix: use matvec everywhere
cako May 8, 2023
7b97451
refactor: simplify forceflat logic
cako May 8, 2023
cbd4260
feat: forceflat test for Bilinear
mrava87 May 8, 2023
01bfce7
fix: fix forceflat test for Bilinear
mrava87 May 8, 2023
9baac3b
Merge pull request #502 from mrava87/patch-flatten
mrava87 May 9, 2023
f2c9194
minor: fix a typo in Torch description in docs
hongyx11 May 16, 2023
07dc52e
Merge pull request #505 from hongyx11/dev
mrava87 May 18, 2023
30b5764
feature: added nonstatconvolve3d operator
May 22, 2023
3f65b02
bug: fix size of wavelet in plot_ista to be smaller than that of input
mrava87 May 26, 2023
7c34a7b
patch: allow psnr to use range instead of max
mrava87 Jun 1, 2023
7601072
Merge pull request #509 from mrava87/patch-psnr
mrava87 Jun 1, 2023
4d0399e
minor: simplify if else statements for offset/pad
mrava87 Jun 2, 2023
cdb00e5
Merge pull request #507 from mrava87/feature-longconv
mrava87 Jun 2, 2023
b5eefc7
bug: change jit into jit_message in checks
mrava87 Jul 2, 2023
99bcc64
Merge pull request #511 from mrava87/patch-kirchjit
mrava87 Jul 2, 2023
8aba0a6
bug: fixed skfmm check in kirchhoff
mrava87 Jul 6, 2023
040a8b9
Merge pull request #512 from mrava87/patch-kirchskfmm
mrava87 Jul 6, 2023
5d2f600
minor: added tests for NonStationaryConvolve3D and finalized cleaning…
mrava87 Jul 19, 2023
65dcd9c
minor: fixed flake8 issues
mrava87 Jul 20, 2023
53e727c
minor: fixed flake8 issues in test
mrava87 Jul 20, 2023
2219a71
Merge pull request #506 from ZhangWeiGeo/feature-nonstatconv3
mrava87 Jul 20, 2023
adfd208
bug: fix wrong import in nonstatconvolve3d.py
mrava87 Jul 20, 2023
1d51b23
Merge pull request #513 from mrava87/bug-nonstatconv3d
mrava87 Jul 20, 2023
d88aaf1
doc: fixed some typos in nonstatconvolve files
mrava87 Jul 20, 2023
35e216f
Merge pull request #515 from mrava87/doc-nonstatconv
mrava87 Jul 20, 2023
8ae98bb
bug: add forceflat to restriction to avoid unexpected unflattening of…
mrava87 Jul 20, 2023
efd0c25
Merge pull request #516 from mrava87/bug-restrictionflatten
mrava87 Jul 20, 2023
5e263f7
doc: updated readthedocs yaml file
mrava87 Aug 7, 2023
e8b9b8f
Merge pull request #519 from mrava87/doc-update
mrava87 Aug 7, 2023
a64fba1
minor: fix flake8 issue in convolve1d
mrava87 Aug 7, 2023
18a5b61
Merge pull request #520 from mrava87/dev
mrava87 Aug 7, 2023
a892de6
bug: fixed convmtx as discussed in https://github.com/PyLops/pylops/i…
mrava87 Aug 7, 2023
e8ec0f8
fix: correct basic solvers' handling of ndarrays
mrava87 Aug 7, 2023
f083f8c
Merge pull request #522 from mrava87/fix-basicsolver
mrava87 Aug 8, 2023
390cd98
bug: fixed convmtx as discussed in https://github.com/PyLops/pylops/i…
mrava87 Aug 23, 2023
63e7c48
Merge pull request #521 from mrava87/fix-convmtx
mrava87 Sep 6, 2023
01e2c45
minor: second implementation to BlendingContinuous
mrava87 Sep 10, 2023
0c50936
Merge pull request #525 from mrava87/patch-fastdeblending
mrava87 Sep 10, 2023
e6e0338
build: switch from setup.py to pyproject.toml (#530)
mrava87 Oct 1, 2023
32a40c2
feature: restyling of Kirchhoff operator
mrava87 Oct 1, 2023
7ed1d7f
minor: coverage action to use only python 3.8
mrava87 Oct 1, 2023
937a24b
remark on classical sinograms added + jacobian correction; added two …
fedor-goncharov Oct 3, 2023
25315b1
fix: change make rule for tests
mrava87 Oct 3, 2023
d24eb26
Merge pull request #534 from mrava87/patch-maketest
mrava87 Oct 3, 2023
f57a2a2
fix: change handling of version in pyproject.toml/setup.cfg
mrava87 Oct 5, 2023
130cc29
minor: fix setuptools version
mrava87 Oct 5, 2023
385b108
minor: try to fetch versions
mrava87 Oct 5, 2023
30d4217
minor: change of versions of setuptools
mrava87 Oct 5, 2023
2a471d9
minor: add fetch of versions
mrava87 Oct 5, 2023
0ba2276
minor: Update setuptools
mrava87 Oct 5, 2023
de821eb
minor: Workaround in GA to get right version with SCM
mrava87 Oct 5, 2023
a98d826
minor: Workaround in GA to get right version with SCM
mrava87 Oct 5, 2023
2a69b82
Merge pull request #535 from mrava87/patch-setup1
mrava87 Oct 5, 2023
a894e15
minor: small text changes to ctscan tutorial
mrava87 Oct 6, 2023
41dc437
minor: added fedor-goncharov to contributors
mrava87 Oct 6, 2023
91d988a
Merge pull request #532 from fedor-goncharov/tutorial-ctscan-correction
mrava87 Oct 6, 2023
ce16536
update isort precommit hook
cako Oct 9, 2023
e782fd3
improve language
cako Oct 9, 2023
8146658
minor: fixed epsdist and sign of 3d wavelet
mrava87 Oct 10, 2023
00f7034
minor: fix doc to reflect wavelet sign
mrava87 Oct 14, 2023
d0aa50d
Merge pull request #531 from mrava87/feature-kirchhoffimproved
mrava87 Oct 16, 2023
35aeae5
doc: added pylops-mpi to extensions page
mrava87 Oct 26, 2023
5e1567c
Merge pull request #540 from mrava87/doc-extension
mrava87 Oct 26, 2023
47b672d
minor: improved signal definition in sliding example
mrava87 Oct 29, 2023
1d4c683
Merge pull request #541 from mrava87/doc-slidingex
mrava87 Oct 29, 2023
c8f54fc
minor: prepare for v2.2.0
mrava87 Nov 10, 2023
5b06bc6
Merge pull request #542 from mrava87/v.2.2.0
mrava87 Nov 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest ]
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements-dev.txt; fi
- name: Install pylops
run: |
python -m setuptools_scm
pip install .
- name: Test with pytest
run: |
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/codacy-coverage-reporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ on: [push, pull_request_target]

jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest, ]
python-version: ["3.8", ]

runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest coverage
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements-dev.txt; fi
- name: Install pylops
run: |
pip install .
pip install coverage
- name: Code coverage with coverage
run: |
coverage run -m pytest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- --line-length=88

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
Expand Down
23 changes: 23 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Declare the Python requirements required to build your docs
python:
install:
- requirements: requirements-dev.txt
- method: pip
path: .
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 2.2.0

* Added `pylops.signalprocessing.NonStationaryConvolve3D` operator
* Added nd-array capabilities to `pylops.basicoperators.Identity` and `pylops.basicoperators.Zero`
* Added second implementation in `pylops.waveeqprocessing.BlendingContinuous` which is more
performant when dealing with small number of receivers
* Added `forceflat` property to operators with ambiguous `rmatvec` (`pylops.basicoperators.Block`,
`pylops.basicoperators.Bilinear`, `pylops.basicoperators.BlockDiag`, `pylops.basicoperators.HStack`,
`pylops.basicoperators.MatrixMult`, `pylops.basicoperators.VStack`, and `pylops.basicoperators.Zero`)
* Improved `dynamic` mode of `pylops.waveeqprocessing.Kirchhoff` operator
* Modified `pylops.signalprocessing.Convolve1D` to allow both filters that are both shorter and longer of the
input vector
* Modified all solvers to use `matvec/rmatvec` instead of `@/.H @` to improve performance


# 2.1.0
* Added `pylops.signalprocessing.DCT`, `pylops.signalprocessing.NonStationaryConvolve1D`,
`pylops.signalprocessing.NonStationaryConvolve2D`, `pylops.signalprocessing.NonStationaryFilters1D`, and
Expand Down
2 changes: 1 addition & 1 deletion MIGRATION_V1_V2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ should be used as a checklist when converting a piece of code using PyLops from
for every operator by default. While the change is mostly backwards compatible, there are some operators (e.g. the ``Bilinear``
transpose/conjugate) which can output reshaped arrays instead of 1d-arrays. To ensure no breakage, you can entirely disable this
feature either globally by setting ``pylops.set_ndarray_multiplication(False)``, or locally with the context manager
``pylops.disabled_ndarray_multiplication()``. Both will revert to v1.x behavior. At this time, PyLops sparse solvers do
``pylops.disabled_ndarray_multiplication()``. Both will revert to v1.x behavior. At this time, PyLops solvers do
*not* support N-D array multiplication.

See the table at the end of this document for support ndarray operations.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dev-install_conda:

tests:
make pythoncheck
$(PYTHON) setup.py test
pytest

doc:
cd docs && rm -rf source/api/generated && rm -rf source/gallery &&\
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,5 @@ A list of video tutorials to learn more about PyLops:
* Juan Daniel Romero, jdromerom
* Aniket Singh Rawat, dikwickley
* Rohan Babbar, rohanbabbar04
* Wei Zhang, ZhangWeiGeo
* Fedor Goncharov, fedor-goncharov
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
versionSpec: '3.8'
architecture: 'x64'

- script: |
Expand All @@ -65,7 +65,7 @@ jobs:
displayName: 'Install prerequisites and library'

- script: |
python setup.py test
pytest
condition: succeededOrFailed()
displayName: 'Run tests'

Expand All @@ -84,7 +84,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
versionSpec: '3.8'
architecture: 'x64'

- script: |
Expand All @@ -94,6 +94,6 @@ jobs:
displayName: 'Install prerequisites and library'

- script: |
python setup.py test
pytest
condition: succeededOrFailed()
displayName: 'Run tests'
1 change: 1 addition & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Signal processing
ConvolveND
NonStationaryConvolve1D
NonStationaryConvolve2D
NonStationaryConvolve3D
NonStationaryFilters1D
NonStationaryFilters2D
Interp
Expand Down
18 changes: 18 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
Changelog
=========

Version 2.2.0
-------------

*Released on: 11/11/2023*

* Added :class:`pylops.signalprocessing.NonStationaryConvolve3D` operator
* Added nd-array capabilities to :class:`pylops.basicoperators.Identity` and :class:`pylops.basicoperators.Zero`
* Added second implementation in :class:`pylops.waveeqprocessing.BlendingContinuous` which is more
performant when dealing with small number of receivers
* Added `forceflat` property to operators with ambiguous `rmatvec` (:class:`pylops.basicoperators.Block`,
:class:`pylops.basicoperators.Bilinear`, :class:`pylops.basicoperators.BlockDiag`, :class:`pylops.basicoperators.HStack`,
:class:`pylops.basicoperators.MatrixMult`, :class:`pylops.basicoperators.VStack`, and :class:`pylops.basicoperators.Zero`)
* Improved `dynamic` mode of :class:`pylops.waveeqprocessing.Kirchhoff` operator
* Modified :class:`pylops.signalprocessing.Convolve1D` to allow both filters that are both shorter and longer of the
input vector
* Modified all solvers to use `matvec/rmatvec` instead of `@/.H @` to improve performance


Version 2.1.0
-------------

Expand Down
4 changes: 3 additions & 1 deletion docs/source/credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ Contributors
* `Muhammad Izzatullah <https://github.com/izzatum>`_, izzatum
* `Juan Daniel Romero <https://github.com/jdromerom>`_, jdromerom
* `Aniket Singh Rawat <https://github.com/dikwickley>`_, dikwickley
* `Rohan Babbar <https://github.com/rohanbabbar04>`_, rohanbabbar04
* `Rohan Babbar <https://github.com/rohanbabbar04>`_, rohanbabbar04
* `Wei Zhang <https://github.com/ZhangWeiGeo>`_, ZhangWeiGeo
* `Fedor Goncharov <https://github.com/fedor-goncharov>`_, fedor-goncharov
7 changes: 4 additions & 3 deletions docs/source/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ for academic purposes.

Spin-off projects that aim at extending the capabilities of PyLops are:

* `PyLops-GPU <https://github.com/PyLops/pylops-gpu>`_ : PyLops for GPU arrays (incorporated into PyLops).
* `PyLops-Distributed <https://github.com/PyLops/pylops-distributed>`_: PyLops for distributed systems with many computing nodes.
* `PyLops-MPI <https://github.com/PyLops/pylops-mpi>`_: PyLops for distributed systems with many computing nodes using MPI
* `PyProximal <https://github.com/PyLops/pyproximal>`_: Proximal solvers which integrate with PyLops Linear Operators.
* `Curvelops <https://github.com/PyLops/curvelops>`_: Python wrapper for the Curvelab 2D and 3D digital curvelet transforms.
* `Curvelops <https://github.com/PyLops/curvelops>`_: Python wrapper for the Curvelab 2D and 3D digital curvelet transforms.
* `PyLops-GPU <https://github.com/PyLops/pylops-gpu>`_ : PyLops for GPU arrays (unmantained! the core features are now incorporated into PyLops).
* `PyLops-Distributed <https://github.com/PyLops/pylops-distributed>`_ : PyLops for distributed systems with many computing nodes using Dask (unmantained!).
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ or via ``pip`` with

Torch
-----
`Torch <http://pytorch.org>`_ used to allow seamless integration between PyLops and PyTorch operators.
`Torch <http://pytorch.org>`_ is used to allow seamless integration between PyLops and PyTorch operators.

Install it via ``conda`` with:

Expand Down
117 changes: 115 additions & 2 deletions examples/plot_convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
from scipy.sparse.linalg import lsqr

import pylops
Expand Down Expand Up @@ -132,7 +133,7 @@
plt.subplots_adjust(top=0.8)

###############################################################################
# Finally we do the same using three dimensional signals and
# We now do the same using three dimensional signals and
# filters taking advantage of the
# :py:class:`pylops.signalprocessing.ConvolveND` operator.
ny, nx, nz = 13, 10, 7
Expand All @@ -149,7 +150,7 @@
xlsqr = xlsqr.reshape(Cop.dims)

fig, axs = plt.subplots(3, 3, figsize=(10, 12))
fig.suptitle("Convolve 3d data", y=0.95, fontsize=14, fontweight="bold")
fig.suptitle("Convolve 3d data", y=0.98, fontsize=14, fontweight="bold")
axs[0][0].imshow(x[ny // 3], cmap="gray", vmin=-1, vmax=1)
axs[0][1].imshow(y[ny // 3], cmap="gray", vmin=-1, vmax=1)
axs[0][2].imshow(xlsqr[ny // 3], cmap="gray", vmin=-1, vmax=1)
Expand All @@ -172,3 +173,115 @@
axs[2][1].axis("tight")
axs[2][2].axis("tight")
plt.tight_layout()

###############################################################################
# Up until now, we have only considered the case where the filter is compact
# and much shorter of the input data. There are however scenarios where the
# opposite (i.e., filter is longer than the signal) is desired. This is for
# example the case when one wants to estimate a filter (:math:`\mathbf{h}`)
# to match two signals (:math:`\mathbf{x}` and :math:`\mathbf{y}`):
#
# .. math::
# J = || \mathbf{y} - \mathbf{X} \mathbf{h} ||_2^2
#
# Such a scenario is very commonly used in so-called adaptive substraction
# techniques. We will try now to use :py:class:`pylops.signalprocessing.Convolve1D`
# to match two signals that have both a phase and amplitude mismatch.

# Define input signal
nt = 101
dt = 0.004
t = np.arange(nt) * dt

x = np.zeros(nt)
x[[int(nt / 4), int(nt / 2), int(2 * nt / 3)]] = [3, -2, 1]
h, th, hcenter = ricker(t[:41], f0=20)

Cop = pylops.signalprocessing.Convolve1D(nt, h=h, offset=hcenter, dtype="float32")
x = Cop * x

# Phase and amplitude corrupt the input
amp = 0.9
phase = 40

y = amp * (
x * np.cos(np.deg2rad(phase))
+ np.imag(sp.signal.hilbert(x)) * np.sin(np.deg2rad(phase))
)

# Define convolution operator
nh = 21
th = np.arange(nh) * dt - dt * nh // 2
Yop = pylops.signalprocessing.Convolve1D(nh, h=y, offset=nh // 2)

# Find filter to match x to y
h = Yop / x
ymatched = Yop @ h

# Find sparse filter to match x to y
hsparse = pylops.optimization.sparsity.fista(Yop, x, niter=100, eps=1e-1)[0]
ymatchedsparse = Yop @ hsparse

fig, ax = plt.subplots(1, 1, figsize=(10, 3))
ax.plot(t, x, "k", lw=2, label=r"$x$")
ax.plot(t, y, "r", lw=2, label=r"$y$")
ax.plot(t, ymatched, "--g", lw=2, label=r"$y_{matched}$")
ax.plot(t, x - ymatched, "--k", lw=2, label=r"$x-y_{matched,sparse}$")
ax.plot(t, ymatchedsparse, "--m", lw=2, label=r"$y_{matched}$")
ax.plot(t, x - ymatchedsparse, "--k", lw=2, label=r"$x-y_{matched,sparse}$")
ax.set_title("Signals to match", fontsize=14, fontweight="bold")
ax.legend(loc="upper right")
plt.tight_layout()

fig, axs = plt.subplots(1, 2, figsize=(10, 3))
axs[0].plot(th, h, "k", lw=2)
axs[0].set_title("Matching filter", fontsize=14, fontweight="bold")
axs[1].plot(th, hsparse, "k", lw=2)
axs[1].set_title("Sparse Matching filter", fontsize=14, fontweight="bold")
plt.tight_layout()


###############################################################################
# Finally, in some cases one wants to convolve (or correlate) two signals of
# the same size. This can also be obtained using
# :py:class:`pylops.signalprocessing.Convolve1D`. We will see here a case
# where the operator is used to trace-wise auto-correlate signals from
# a 2-dimensional array representing a seismic dataset.

# Create data
par = {"ox": -140, "dx": 2, "nx": 140, "ot": 0, "dt": 0.004, "nt": 200, "f0": 20}

v = 1500
t0 = [0.2, 0.4, 0.5]
px = [0, 0, 0]
pxx = [1e-5, 5e-6, 1e-20]
amp = [1.0, -2, 0.5]

t, t2, x, y = pylops.utils.seismicevents.makeaxis(par)
wav = pylops.utils.wavelets.ricker(t[:41], f0=par["f0"])[0]
_, data = pylops.utils.seismicevents.parabolic2d(x, t, t0, px, pxx, amp, wav)

# Convolution operator
Xop = pylops.signalprocessing.Convolve1D(
(par["nx"], par["nt"]), h=data, offset=par["nt"] // 2, axis=-1, method="fft"
)

corr = Xop.H @ data

fig, axs = plt.subplots(1, 2, figsize=(10, 6))
axs[0].imshow(data.T, cmap="gray", vmin=-1, vmax=1, extent=(x[0], x[-1], t[-1], t[0]))
axs[0].set_xlabel("Rec (m)", fontsize=14, fontweight="bold")
axs[0].set_ylabel("T (s)", fontsize=14, fontweight="bold")
axs[0].set_title("Data", fontsize=14, fontweight="bold")
axs[0].axis("tight")
axs[1].imshow(
corr.T,
cmap="gray",
vmin=-10,
vmax=10,
extent=(x[0], x[-1], t[par["nt"] // 2], -t[par["nt"] // 2]),
)
axs[1].set_xlabel("Rec (m)", fontsize=14, fontweight="bold")
axs[1].set_title("Auto-correlation", fontsize=14, fontweight="bold")
axs[1].axis("tight")
plt.tight_layout()
2 changes: 1 addition & 1 deletion examples/plot_ista.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
x[int(nt / 2)] = 1
x[nt - 20] = 0.5

h, th, hcenter = pylops.utils.wavelets.ricker(t[:101], f0=20)
h, th, hcenter = pylops.utils.wavelets.ricker(t[:21], f0=20)

Cop = pylops.signalprocessing.Convolve1D(nt, h=h, offset=hcenter, dtype="float32")
y = Cop * x
Expand Down
Loading
Loading