Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
110 changes: 58 additions & 52 deletions docs/tutorials/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
]
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
Expand All @@ -75,6 +75,8 @@
"\n",
"MDIO uses [TGSAI/segy][segy-github] to parse the SEG-Y; the field names conform to its canonical keys defined in [SEGY Binary Header Keys][segy-binary-keys] and [SEGY Trace Header Keys][segy-trace-keys]. Since MDIO v1 we also introduced templates for common seismic data types. For instance, we will be using the `PostStack3DTime` template [here][mdio-template-poststack3dtime], which expects the same canonical keys.\n",
"\n",
"We will also specify the units for the time domain. The spatial units will be automatically parsed from SEG-Y binary header. However, there may be a case where it is corrupt in the file, for that see the [Fixing X/Y Units Issues](https://mdio-python.readthedocs.io/en/stable/tutorials/corrupt_files.html#fixing-x-y-units-issues) section.\n",
"\n",
"In summary, we will use the byte locations as defined for ingestion.\n",
"\n",
"[segy-github]: https://github.com/TGSAI/segy\n",
Expand All @@ -85,17 +87,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from segy.schema import HeaderField\n",
"from segy.standards import get_segy_standard\n",
"\n",
"from mdio import segy_to_mdio\n",
"from mdio.builder.schemas.v1.units import TimeUnitModel\n",
"from mdio.builder.template_registry import get_template\n",
"\n",
"teapot_trace_headers = [\n",
Expand All @@ -109,16 +114,17 @@
"teapot_segy_spec = rev0_segy_spec.customize(trace_header_fields=teapot_trace_headers)\n",
"\n",
"mdio_template = get_template(\"PostStack3DTime\")\n",
"unit_ms = TimeUnitModel(time=\"ms\")\n",
"mdio_template.add_units({\"time\": unit_ms})\n",
"\n",
"segy_to_mdio(\n",
" input_path=input_url,\n",
" output_path=\"filt_mig.mdio\",\n",
" segy_spec=teapot_segy_spec,\n",
" mdio_template=mdio_template,\n",
" overwrite=True,\n",
")"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -141,19 +147,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from mdio import open_mdio\n",
"\n",
"dataset = open_mdio(\"filt_mig.mdio\")\n",
"dataset"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -170,16 +176,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"print(dataset[\"segy_file_header\"].attrs[\"textHeader\"])"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -194,16 +200,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset[\"segy_file_header\"].attrs[\"binaryHeader\"]"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -221,42 +227,42 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset.sizes"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset.inline"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset.crossline"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -278,11 +284,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from mdio.builder.schemas.v1.stats import SummaryStatistics\n",
"\n",
Expand All @@ -292,9 +300,7 @@
"il_dataset = dataset.sel(inline=278)\n",
"il_amp = il_dataset[\"amplitude\"].T\n",
"il_amp.plot(vmin=-2 * std, vmax=2 * std, cmap=\"gray_r\", yincrease=False);"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -313,13 +319,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"twt_data = dataset[\"amplitude\"].sel(time=1000)\n",
"twt_data.plot(vmin=-2 * std, vmax=2 * std, cmap=\"gray_r\", x=\"cdp_x\", y=\"cdp_y\");"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -336,19 +342,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"trace_mask = dataset.trace_mask[:]\n",
"\n",
"twt_data.plot(vmin=-2 * std, vmax=2 * std, cmap=\"gray_r\", x=\"cdp_x\", y=\"cdp_y\", alpha=0.5, figsize=(8, 5))\n",
"trace_mask.plot(vmin=0, vmax=1, x=\"cdp_x\", y=\"cdp_y\", alpha=0.5);"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -380,29 +386,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset.headers[\"cdp_x\"].compute()"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"dataset.headers[\"cdp_y\"].compute()"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -423,11 +429,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"xl_dataset = dataset.sel(crossline=100) # slices everything available in MDIO dataset!\n",
"\n",
Expand All @@ -447,9 +455,7 @@
"hdr_ax.set_xlabel(\"\")\n",
"\n",
"plt.tight_layout()"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -470,11 +476,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from mdio import mdio_to_segy\n",
"\n",
Expand All @@ -483,9 +491,7 @@
" output_path=\"filt_mig_roundtrip.sgy\",\n",
" segy_spec=teapot_segy_spec,\n",
")"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
Expand All @@ -511,11 +517,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"from segy import SegyFile\n",
Expand All @@ -536,22 +544,17 @@
" np.testing.assert_equal(original_segy.trace[idx], roundtrip_segy.trace[idx])\n",
"\n",
"print(\"Files identical!\")"
],
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": [],
"outputs": [],
"execution_count": null
"source": []
}
],
"metadata": {
"mystnb": {
"execution_mode": "force"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand All @@ -569,6 +572,9 @@
"pygments_lexer": "ipython3",
"version": "3.13.5"
},
"mystnb": {
"execution_mode": "force"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {
Expand Down
Loading