This documentation is not for the latest stable Salvus version.
xarray
Python
packages into our notebook.%matplotlib inline
%config Completer.use_jedi = False
from pathlib import Path
import os
import requests
import shutil
from typing import List
import scipy
import obspy
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
from salvus.flow import api
from salvus.flow import simple_config as config
from salvus.toolbox import toolbox
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
# Download Marmousi model ~150 MB.
target_path = "elastic-marmousi-model.tar.gz"
if not Path(target_path).exists():
url = (
"https://s3.amazonaws.com/open.source.geoscience/open_data"
"/elastic-marmousi/elastic-marmousi-model.tar.gz"
)
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(target_path, "wb") as f:
f.write(response.raw.read())
shutil.unpack_archive(target_path)
xarray
as an intermediary to encapsulate both the model parameters and geometry. More info on xarray
, including extensive documentation, can be found here. Reading our Marmousi model into an xarray.Dataset
is trivial, and the process can be inspected by opening the acompanying getting_started_tools.py
file.xarray
dataset with the following information# Read marmousi model.
model_directory = Path("./elastic-marmousi-model/model")
marmousi_model = toolbox.read_elastic_marmousi(model_directory, ["VP", "RHO"])
xarray.Dataset
object is the ability to quickly plot the contained data. Let's do this below as a way to quickly QC that the model reading went correctly.marmousi_model["VP"].T.plot(aspect="auto", figsize=(15, 5))
plt.show()
marmousi_model["RHO"].T.plot(aspect="auto", figsize=(15, 5))
plt.show()