NDF-Poli-USP / spyro

Wave propagators for seismic domains with application to full waveform inversion.
GNU General Public License v3.0
34 stars 15 forks source link

running error for Marmousi model #109

Open acse-yw11823 opened 1 week ago

acse-yw11823 commented 1 week ago

Hello. I was running the '''run_fwi_2d.py file''' in the/spyro/paper folder. And I need to download the Meshes and associated velocity models from here. And for the 2D FWI, the guess meshes are generated by running the Python script make_guess_meshes.py which uses the Python package SeismicMesh. I meet the following error when I running make_guess_meshes.py :

(firedrake) (base) yw11823@IC-FVFL80FW1WGC FWI_2D_DATA % pyth
on make_guess_problem.py 
Traceback (most recent call last):
  File "/Users/yw11823/ACSE/irp/spyro/FWI_2D_DATA/make_guess_problem.py", line 14, in <module>
    ef = get_sizing_function_from_segy(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 135, in get_sizing_function_from_segy
    vp, nz, nx, ny = read_velocity_model(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 602, in read_velocity_model
    return _read_segy(filename)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 637, in _read_segy
    with segyio.open(filename, ignore_geometry=True) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/segyio/open.py", line 162, in open
    fd = _segyio.segyiofd(str(filename), mode, endians[endian])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

I could not find vp_guess4.segy from anywhere. Does anyone have any clue??

Many thanks for the help!!!

Olender commented 1 week ago

We do not have any .segy files in the public repository, because they are too large. Fortunately, all the data used for the paper is available in the assets section of the GMD paper (https://gmd.copernicus.org/articles/15/8639/2022/gmd-15-8639-2022-assets.html). There you will find a script calling seismicmesh to generate the guess mesh file. The guess velocity model should be generated based on Marmousi using the specifications mentioned in the paper. You can use the method from https://github.com/Olender/spyro-1/blob/main/spyro/tools/velocity_smoother.py With this method you can try out different standard deviations of the Gaussian filter ant try out different initial guesses.

acse-yw11823 commented 1 week ago

Many thanks for the reply!! I found them now! :)

acse-yw11823 commented 1 week ago

I noticed that the link you provided is the same as the one I found earlier. I successfully found a script called make_guess_problem.py as before. The issue arises when I run this script; it shows the following error:

(firedrake) (base) yw11823@IC-FVFL80FW1WGC FWI_2D_DATA % /Users/yw11823/ACSE/irp/firedrake/bin/python /Users/yw11823/ACSE/irp/spy
ro/FWI_2D_DATA/make_guess_problem.py
Traceback (most recent call last):
  File "/Users/yw11823/ACSE/irp/spyro/FWI_2D_DATA/make_guess_problem.py", line 14, in <module>
    ef = get_sizing_function_from_segy(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 135, in get_sizing_function_from_segy
    vp, nz, nx, ny = read_velocity_model(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 602, in read_velocity_model
    return _read_segy(filename)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/SeismicMesh/sizing/mesh_size_function.py", line 637, in _read_segy
    with segyio.open(filename, ignore_geometry=True) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yw11823/ACSE/irp/firedrake/lib/python3.11/site-packages/segyio/open.py", line 162, in open
    fd = _segyio.segyiofd(str(filename), mode, endians[endian])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

Here is the context of the script:

import meshio
from SeismicMesh import *
import segyio

fname = "vp_guess4.segy"
bbox = (-3500.0, 0.0, 0.0, 17000.0)
cpwl = 3.08 #2.22 #1.69 #$20 #7.02 #3.96 #2.67 #2.028
freq = 5.0
grade = 0.15
hmin = 1500 / (cpwl * freq)
pad = 4500.0 / freq  # cmax / freq
###########
rectangle = Rectangle(bbox)
ef = get_sizing_function_from_segy(
    fname,
    bbox,
    hmin=hmin,
    wl=cpwl,
    freq=freq,
    grade=grade,
    domain_pad=pad,
    pad_style="edge",
    units="m-s",
)

write_velocity_model(
    fname,
    ofname="velocity_models/marmousi_guess",
    bbox=bbox,
    domain_pad=pad,
    pad_style="edge",
    units="m-s",
)
points, cells = generate_mesh(domain=rectangle, edge_length=ef, verbose=2)
meshio.write_points_cells("meshes/marmousi_guess.vtk", points / 1000.0, [("triangle", cells)])
meshio.write_points_cells(
    "meshes/marmousi_guess.msh",
    points / 1000.0,
    [("triangle", cells)],
    file_format="gmsh22",
    binary=False,
)

I believe the error is related to the missing vp_guess4.segyfile, but I have been unable to locate it.

Many thanks!!!!!

Olender commented 1 week ago

Run the https://github.com/Olender/spyro-1/blob/main/spyro/tools/velocity_smoother.py method with the sigma stated in the paper and save the file as vp_guess4.segy.

acse-yw11823 commented 1 week ago

I see!! I got that! I was being stupid. Many thanks for your patience! I appreciate it!

Olender commented 1 week ago

You're welcome! No worries at all, we all have questions sometimes. I'm glad I could help. Feel free to reach out if you have any more questions or need further assistance. These questions help us to improve our code and make it more user friendly. Happy coding!

The code in PR #104, is going be merged this week and should address not only the current difficulties new users have in running spyro code, but also comes with various jupyter notebook tutorials to help (including a forward propagation case using the overthrust velocity model). After it passes, I plan on making a FWI tutorial with the Marmousi case as well.