|
46 | 46 | ] |
47 | 47 | }, |
48 | 48 | { |
49 | | - "metadata": {}, |
50 | 49 | "cell_type": "code", |
51 | | - "outputs": [], |
52 | 50 | "execution_count": null, |
| 51 | + "metadata": {}, |
| 52 | + "outputs": [], |
53 | 53 | "source": [ |
54 | 54 | "import os\n", |
55 | 55 | "\n", |
|
75 | 75 | "\n", |
76 | 76 | "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", |
77 | 77 | "\n", |
| 78 | + "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", |
| 79 | + "\n", |
78 | 80 | "In summary, we will use the byte locations as defined for ingestion.\n", |
79 | 81 | "\n", |
80 | 82 | "[segy-github]: https://github.com/TGSAI/segy\n", |
|
85 | 87 | }, |
86 | 88 | { |
87 | 89 | "cell_type": "code", |
| 90 | + "execution_count": null, |
88 | 91 | "metadata": { |
89 | 92 | "pycharm": { |
90 | 93 | "name": "#%%\n" |
91 | 94 | } |
92 | 95 | }, |
| 96 | + "outputs": [], |
93 | 97 | "source": [ |
94 | 98 | "import matplotlib.pyplot as plt\n", |
95 | 99 | "from segy.schema import HeaderField\n", |
96 | 100 | "from segy.standards import get_segy_standard\n", |
97 | 101 | "\n", |
98 | 102 | "from mdio import segy_to_mdio\n", |
| 103 | + "from mdio.builder.schemas.v1.units import TimeUnitModel\n", |
99 | 104 | "from mdio.builder.template_registry import get_template\n", |
100 | 105 | "\n", |
101 | 106 | "teapot_trace_headers = [\n", |
|
109 | 114 | "teapot_segy_spec = rev0_segy_spec.customize(trace_header_fields=teapot_trace_headers)\n", |
110 | 115 | "\n", |
111 | 116 | "mdio_template = get_template(\"PostStack3DTime\")\n", |
| 117 | + "unit_ms = TimeUnitModel(time=\"ms\")\n", |
| 118 | + "mdio_template.add_units({\"time\": unit_ms})\n", |
| 119 | + "\n", |
112 | 120 | "segy_to_mdio(\n", |
113 | 121 | " input_path=input_url,\n", |
114 | 122 | " output_path=\"filt_mig.mdio\",\n", |
115 | 123 | " segy_spec=teapot_segy_spec,\n", |
116 | 124 | " mdio_template=mdio_template,\n", |
117 | 125 | " overwrite=True,\n", |
118 | 126 | ")" |
119 | | - ], |
120 | | - "outputs": [], |
121 | | - "execution_count": null |
| 127 | + ] |
122 | 128 | }, |
123 | 129 | { |
124 | 130 | "cell_type": "markdown", |
|
141 | 147 | }, |
142 | 148 | { |
143 | 149 | "cell_type": "code", |
| 150 | + "execution_count": null, |
144 | 151 | "metadata": { |
145 | 152 | "pycharm": { |
146 | 153 | "name": "#%%\n" |
147 | 154 | } |
148 | 155 | }, |
| 156 | + "outputs": [], |
149 | 157 | "source": [ |
150 | 158 | "from mdio import open_mdio\n", |
151 | 159 | "\n", |
152 | 160 | "dataset = open_mdio(\"filt_mig.mdio\")\n", |
153 | 161 | "dataset" |
154 | | - ], |
155 | | - "outputs": [], |
156 | | - "execution_count": null |
| 162 | + ] |
157 | 163 | }, |
158 | 164 | { |
159 | 165 | "cell_type": "markdown", |
|
170 | 176 | }, |
171 | 177 | { |
172 | 178 | "cell_type": "code", |
| 179 | + "execution_count": null, |
173 | 180 | "metadata": { |
174 | 181 | "pycharm": { |
175 | 182 | "name": "#%%\n" |
176 | 183 | } |
177 | 184 | }, |
| 185 | + "outputs": [], |
178 | 186 | "source": [ |
179 | 187 | "print(dataset[\"segy_file_header\"].attrs[\"textHeader\"])" |
180 | | - ], |
181 | | - "outputs": [], |
182 | | - "execution_count": null |
| 188 | + ] |
183 | 189 | }, |
184 | 190 | { |
185 | 191 | "cell_type": "markdown", |
|
194 | 200 | }, |
195 | 201 | { |
196 | 202 | "cell_type": "code", |
| 203 | + "execution_count": null, |
197 | 204 | "metadata": { |
198 | 205 | "pycharm": { |
199 | 206 | "name": "#%%\n" |
200 | 207 | } |
201 | 208 | }, |
| 209 | + "outputs": [], |
202 | 210 | "source": [ |
203 | 211 | "dataset[\"segy_file_header\"].attrs[\"binaryHeader\"]" |
204 | | - ], |
205 | | - "outputs": [], |
206 | | - "execution_count": null |
| 212 | + ] |
207 | 213 | }, |
208 | 214 | { |
209 | 215 | "cell_type": "markdown", |
|
221 | 227 | }, |
222 | 228 | { |
223 | 229 | "cell_type": "code", |
| 230 | + "execution_count": null, |
224 | 231 | "metadata": { |
225 | 232 | "pycharm": { |
226 | 233 | "name": "#%%\n" |
227 | 234 | } |
228 | 235 | }, |
| 236 | + "outputs": [], |
229 | 237 | "source": [ |
230 | 238 | "dataset.sizes" |
231 | | - ], |
232 | | - "outputs": [], |
233 | | - "execution_count": null |
| 239 | + ] |
234 | 240 | }, |
235 | 241 | { |
236 | 242 | "cell_type": "code", |
| 243 | + "execution_count": null, |
237 | 244 | "metadata": { |
238 | 245 | "pycharm": { |
239 | 246 | "name": "#%%\n" |
240 | 247 | } |
241 | 248 | }, |
| 249 | + "outputs": [], |
242 | 250 | "source": [ |
243 | 251 | "dataset.inline" |
244 | | - ], |
245 | | - "outputs": [], |
246 | | - "execution_count": null |
| 252 | + ] |
247 | 253 | }, |
248 | 254 | { |
249 | 255 | "cell_type": "code", |
| 256 | + "execution_count": null, |
250 | 257 | "metadata": { |
251 | 258 | "pycharm": { |
252 | 259 | "name": "#%%\n" |
253 | 260 | } |
254 | 261 | }, |
| 262 | + "outputs": [], |
255 | 263 | "source": [ |
256 | 264 | "dataset.crossline" |
257 | | - ], |
258 | | - "outputs": [], |
259 | | - "execution_count": null |
| 265 | + ] |
260 | 266 | }, |
261 | 267 | { |
262 | 268 | "cell_type": "markdown", |
|
278 | 284 | }, |
279 | 285 | { |
280 | 286 | "cell_type": "code", |
| 287 | + "execution_count": null, |
281 | 288 | "metadata": { |
282 | 289 | "pycharm": { |
283 | 290 | "name": "#%%\n" |
284 | 291 | } |
285 | 292 | }, |
| 293 | + "outputs": [], |
286 | 294 | "source": [ |
287 | 295 | "from mdio.builder.schemas.v1.stats import SummaryStatistics\n", |
288 | 296 | "\n", |
|
292 | 300 | "il_dataset = dataset.sel(inline=278)\n", |
293 | 301 | "il_amp = il_dataset[\"amplitude\"].T\n", |
294 | 302 | "il_amp.plot(vmin=-2 * std, vmax=2 * std, cmap=\"gray_r\", yincrease=False);" |
295 | | - ], |
296 | | - "outputs": [], |
297 | | - "execution_count": null |
| 303 | + ] |
298 | 304 | }, |
299 | 305 | { |
300 | 306 | "cell_type": "markdown", |
|
313 | 319 | }, |
314 | 320 | { |
315 | 321 | "cell_type": "code", |
| 322 | + "execution_count": null, |
316 | 323 | "metadata": {}, |
| 324 | + "outputs": [], |
317 | 325 | "source": [ |
318 | 326 | "twt_data = dataset[\"amplitude\"].sel(time=1000)\n", |
319 | 327 | "twt_data.plot(vmin=-2 * std, vmax=2 * std, cmap=\"gray_r\", x=\"cdp_x\", y=\"cdp_y\");" |
320 | | - ], |
321 | | - "outputs": [], |
322 | | - "execution_count": null |
| 328 | + ] |
323 | 329 | }, |
324 | 330 | { |
325 | 331 | "cell_type": "markdown", |
|
336 | 342 | }, |
337 | 343 | { |
338 | 344 | "cell_type": "code", |
| 345 | + "execution_count": null, |
339 | 346 | "metadata": { |
340 | 347 | "pycharm": { |
341 | 348 | "name": "#%%\n" |
342 | 349 | } |
343 | 350 | }, |
| 351 | + "outputs": [], |
344 | 352 | "source": [ |
345 | 353 | "trace_mask = dataset.trace_mask[:]\n", |
346 | 354 | "\n", |
347 | 355 | "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", |
348 | 356 | "trace_mask.plot(vmin=0, vmax=1, x=\"cdp_x\", y=\"cdp_y\", alpha=0.5);" |
349 | | - ], |
350 | | - "outputs": [], |
351 | | - "execution_count": null |
| 357 | + ] |
352 | 358 | }, |
353 | 359 | { |
354 | 360 | "cell_type": "markdown", |
|
380 | 386 | }, |
381 | 387 | { |
382 | 388 | "cell_type": "code", |
| 389 | + "execution_count": null, |
383 | 390 | "metadata": { |
384 | 391 | "pycharm": { |
385 | 392 | "name": "#%%\n" |
386 | 393 | } |
387 | 394 | }, |
| 395 | + "outputs": [], |
388 | 396 | "source": [ |
389 | 397 | "dataset.headers[\"cdp_x\"].compute()" |
390 | | - ], |
391 | | - "outputs": [], |
392 | | - "execution_count": null |
| 398 | + ] |
393 | 399 | }, |
394 | 400 | { |
395 | 401 | "cell_type": "code", |
| 402 | + "execution_count": null, |
396 | 403 | "metadata": { |
397 | 404 | "pycharm": { |
398 | 405 | "name": "#%%\n" |
399 | 406 | } |
400 | 407 | }, |
| 408 | + "outputs": [], |
401 | 409 | "source": [ |
402 | 410 | "dataset.headers[\"cdp_y\"].compute()" |
403 | | - ], |
404 | | - "outputs": [], |
405 | | - "execution_count": null |
| 411 | + ] |
406 | 412 | }, |
407 | 413 | { |
408 | 414 | "cell_type": "markdown", |
|
423 | 429 | }, |
424 | 430 | { |
425 | 431 | "cell_type": "code", |
| 432 | + "execution_count": null, |
426 | 433 | "metadata": { |
427 | 434 | "pycharm": { |
428 | 435 | "name": "#%%\n" |
429 | 436 | } |
430 | 437 | }, |
| 438 | + "outputs": [], |
431 | 439 | "source": [ |
432 | 440 | "xl_dataset = dataset.sel(crossline=100) # slices everything available in MDIO dataset!\n", |
433 | 441 | "\n", |
|
447 | 455 | "hdr_ax.set_xlabel(\"\")\n", |
448 | 456 | "\n", |
449 | 457 | "plt.tight_layout()" |
450 | | - ], |
451 | | - "outputs": [], |
452 | | - "execution_count": null |
| 458 | + ] |
453 | 459 | }, |
454 | 460 | { |
455 | 461 | "cell_type": "markdown", |
|
470 | 476 | }, |
471 | 477 | { |
472 | 478 | "cell_type": "code", |
| 479 | + "execution_count": null, |
473 | 480 | "metadata": { |
474 | 481 | "pycharm": { |
475 | 482 | "name": "#%%\n" |
476 | 483 | } |
477 | 484 | }, |
| 485 | + "outputs": [], |
478 | 486 | "source": [ |
479 | 487 | "from mdio import mdio_to_segy\n", |
480 | 488 | "\n", |
|
483 | 491 | " output_path=\"filt_mig_roundtrip.sgy\",\n", |
484 | 492 | " segy_spec=teapot_segy_spec,\n", |
485 | 493 | ")" |
486 | | - ], |
487 | | - "outputs": [], |
488 | | - "execution_count": null |
| 494 | + ] |
489 | 495 | }, |
490 | 496 | { |
491 | 497 | "cell_type": "markdown", |
|
511 | 517 | }, |
512 | 518 | { |
513 | 519 | "cell_type": "code", |
| 520 | + "execution_count": null, |
514 | 521 | "metadata": { |
515 | 522 | "pycharm": { |
516 | 523 | "name": "#%%\n" |
517 | 524 | } |
518 | 525 | }, |
| 526 | + "outputs": [], |
519 | 527 | "source": [ |
520 | 528 | "import numpy as np\n", |
521 | 529 | "from segy import SegyFile\n", |
|
536 | 544 | " np.testing.assert_equal(original_segy.trace[idx], roundtrip_segy.trace[idx])\n", |
537 | 545 | "\n", |
538 | 546 | "print(\"Files identical!\")" |
539 | | - ], |
540 | | - "outputs": [], |
541 | | - "execution_count": null |
| 547 | + ] |
542 | 548 | }, |
543 | 549 | { |
544 | 550 | "cell_type": "code", |
| 551 | + "execution_count": null, |
545 | 552 | "metadata": {}, |
546 | | - "source": [], |
547 | 553 | "outputs": [], |
548 | | - "execution_count": null |
| 554 | + "source": [] |
549 | 555 | } |
550 | 556 | ], |
551 | 557 | "metadata": { |
552 | | - "mystnb": { |
553 | | - "execution_mode": "force" |
554 | | - }, |
555 | 558 | "kernelspec": { |
556 | 559 | "display_name": "Python 3 (ipykernel)", |
557 | 560 | "language": "python", |
|
569 | 572 | "pygments_lexer": "ipython3", |
570 | 573 | "version": "3.13.5" |
571 | 574 | }, |
| 575 | + "mystnb": { |
| 576 | + "execution_mode": "force" |
| 577 | + }, |
572 | 578 | "widgets": { |
573 | 579 | "application/vnd.jupyter.widget-state+json": { |
574 | 580 | "state": { |
|
0 commit comments