This documentation is not for the latest stable Salvus version.
xarray
Python
packages into our notebook.%matplotlib inline
%config Completer.use_jedi = False
import numpy as np
import os
import shutil
import pathlib
import requests
import time
import xarray as xr
import salvus.namespace as sn
from salvus.namespace import simple_config as sc
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
SIMULATION_MAX_FREQUENCY = 5.0
# Download Marmousi model ~150 MB.
target_path = "elastic-marmousi-model.tar.gz"
if not pathlib.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 and plot marmousi model.
model_directory = pathlib.Path("./elastic-marmousi-model/model")
marmousi = sn.toolbox.read_elastic_marmousi(
model_directory, ["VP", "RHO", "VS"]
)
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["VP"].transpose("y", "x").plot(aspect="auto", figsize=(15, 5))
marmousi["VS"].transpose("y", "x").plot(aspect="auto", figsize=(15, 5))
marmousi["RHO"].transpose("y", "x").plot(aspect="auto", figsize=(15, 5))
<matplotlib.collections.QuadMesh at 0x7fde3a79b590>