-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from AmirMardan/16-error-occurs-in-the-simple-…
…fwi-example fixing the device selection and a bug in `tauxz` buffer
- Loading branch information
Showing
25 changed files
with
2,158 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.8", "3.9", "3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install flake8 pytest | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pyc | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyfwi.readthedocs.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 41 additions & 44 deletions
85
example/fwi_example.ipynb → example/fwi_example_crosswell.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import os | ||
|
||
import sys | ||
sys.path.append(os.path.abspath('./src/')) | ||
|
||
import PyFWI.wave_propagation as wave | ||
import PyFWI.acquisition as acq | ||
import PyFWI.seiplot as splt | ||
import PyFWI.model_dataset as md | ||
from PyFWI.fwi import FWI | ||
|
||
Model = md.ModelGenerator('louboutin') | ||
model = Model() | ||
|
||
im = splt.earth_model(model, cmap='coolwarm') | ||
|
||
model_shape = model[[*model][0]].shape | ||
#%% ================== Parameters and Geometry ================== | ||
|
||
inpa = { | ||
'ns': 4, # Number of sources | ||
'sdo': 4, # Order of FD | ||
'fdom': 15, # Central frequency of source | ||
'dh': 7, # Spatial sampling rate | ||
'dt': 0.004, # Temporal sampling rate | ||
'acq_type': 1, # Type of acquisition (0: crosswell, 1: surface, 2: both) | ||
't': 0.6, # Length of operation | ||
'npml': 20, # Number of PML | ||
'pmlR': 1e-5, # Coefficient for PML (No need to change) | ||
'pml_dir': 2, # type of boundary layer | ||
} | ||
|
||
seisout = 0 # Type of output 0: Pressure | ||
|
||
inpa['rec_dis'] = 1 * inpa['dh'] # Define the receivers' distance | ||
|
||
|
||
offsetx = inpa['dh'] * model_shape[1] | ||
depth = inpa['dh'] * model_shape[0] | ||
|
||
src_loc, rec_loc, n_surface_rec, n_well_rec = acq.acq_parameters(inpa['ns'], | ||
inpa['rec_dis'], | ||
offsetx, | ||
depth, | ||
inpa['dh'], | ||
inpa['sdo'], | ||
acq_type=inpa['acq_type']) | ||
rec_loc[:, 1] -= 2 * inpa['dh'] | ||
|
||
# Create the source | ||
src = acq.Source(src_loc, inpa['dh'], inpa['dt']) | ||
src.Ricker(inpa['fdom']) | ||
|
||
#%% ================== Forward Modelling ================== | ||
# Create the wave object | ||
W = wave.WavePropagator(inpa, src, rec_loc, model_shape, | ||
n_well_rec=n_well_rec, | ||
components=seisout, chpr=0) | ||
|
||
# Call the forward modelling | ||
d_obs = W.forward_modeling(model, show=False) # show=True can show the propagation of the wave | ||
|
||
plt.imshow(d_obs["taux"], cmap='gray', | ||
aspect="auto", extent=[0, d_obs["taux"].shape[1], inpa['t'], 0]) | ||
|
||
#%% ================== Initial model ================== | ||
m0 = Model(smoothing=1) | ||
m0['vs'] *= 0.0 | ||
m0['rho'] = np.ones_like(model['rho']) | ||
|
||
fig = splt.earth_model(m0, ['vp'], cmap='coolwarm') | ||
|
||
fig.axes[0].plot(src_loc[:,0]//inpa["dh"], | ||
src_loc[:,1]//inpa["dh"], "rv", markersize=5) | ||
|
||
fig.axes[0].plot(rec_loc[:,0]//inpa["dh"], | ||
rec_loc[:,1]//inpa["dh"], "b*", markersize=3) | ||
|
||
|
||
#%% ================== FWI ================== | ||
inpa['energy_balancing'] = True | ||
|
||
fwi = FWI(d_obs, inpa, src, rec_loc, model_shape, | ||
components=seisout, chpr=20, n_well_rec=n_well_rec) | ||
|
||
m_est, _ = fwi(m0, method="lbfgs", | ||
freqs=[25, 45], iter=[2, 2], | ||
n_params=1, k_0=1, k_end=2) | ||
|
||
fig = splt.earth_model(m_est, ['vp'], cmap='jet') | ||
|
||
plt.show() | ||
a = 1 |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.