{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":39763,"databundleVersionId":11756775,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:21:56.621259Z","iopub.execute_input":"2026-01-19T06:21:56.621574Z","iopub.status.idle":"2026-01-19T06:21:56.627008Z","shell.execute_reply.started":"2026-01-19T06:21:56.621551Z","shell.execute_reply":"2026-01-19T06:21:56.626004Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Train Dataset","metadata":{}},{"cell_type":"markdown","source":"## Data","metadata":{}},{"cell_type":"code","source":"data = np.load(\"/kaggle/input/waveform-inversion/train_samples/Style_A/data/data1.npy\")\nprint(data.shape)\nx = data[0]   # first sample\nprint(x.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:21:56.629544Z","iopub.execute_input":"2026-01-19T06:21:56.629842Z","iopub.status.idle":"2026-01-19T06:22:04.174005Z","shell.execute_reply.started":"2026-01-19T06:21:56.629819Z","shell.execute_reply":"2026-01-19T06:22:04.173091Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"* 500 -> number of samples\n* 5 -> number of seismic sources per sameple\n* 1000 -> time steps recorded\n* 70 -> number of recievers","metadata":{}},{"cell_type":"markdown","source":"One seismic sample with shape:\n```\n(5, 1000, 70)\nsources × time × receivers\n```","metadata":{}},{"cell_type":"markdown","source":"### 1. Slice by source","metadata":{}},{"cell_type":"markdown","source":"This plot shows 2D seismic shot gathers for a single training sample, visualized separately for each of the 5 seismic sources.\n\nFor each source, the seismic data is displayed as a time × receiver image, where:\n\n* X-axis represents receiver index (spatial location of receivers)\n* Y-axis represents time steps (wave propagation over time)\n* Color intensity represents seismic wave amplitude\n\nThe bright, slanted/curved patterns correspond to wave arrivals and reflections, indicating how seismic energy propagates through the subsurface.\nDifferences across sources reflect different source positions illuminating the same underground structure from different angles.\n\nThis visualization is the primary and most informative representation of seismic input used by CNN-based inversion models.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(18, 4))\n\nfor i in range(5):\n    plt.subplot(1, 5, i + 1)\n    plt.imshow(x[i], aspect=\"auto\", cmap=\"seismic\")\n    plt.title(f\"Source {i+1}\")\n    plt.xlabel(\"Time steps\")\n    plt.ylabel(\"Amplitude\")\n\nplt.suptitle(\"Seismic Waveforms: All 5 Sources\", fontsize=14)\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:22:04.175110Z","iopub.execute_input":"2026-01-19T06:22:04.175550Z","iopub.status.idle":"2026-01-19T06:22:05.085718Z","shell.execute_reply.started":"2026-01-19T06:22:04.175525Z","shell.execute_reply":"2026-01-19T06:22:05.084440Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### 2. Slice by receiver","metadata":{}},{"cell_type":"markdown","source":"This plot shows seismic waveforms recorded at a single receiver location, visualized over time for all 5 seismic sources.\n\n* X-axis represents time steps\n* Y-axis represents wave amplitude\n* Each colored curve corresponds to a different seismic source\n\nDifferences in arrival time and amplitude across sources reflect different source positions illuminating the same receiver.","metadata":{}},{"cell_type":"code","source":"receiver_number = 2  # choose receiver index\n\nplt.figure(figsize=(18, 4))\n\n# x[:, :, receiver_number] -> (5,1000).T -> (1000,5)\n# X-axis → time\n# Each line → one source\nplt.plot(x[:, :, receiver_number].T)\n\nplt.xlabel(\"Time steps\")\nplt.ylabel(\"Amplitude\")\nplt.title(f\"Receiver {receiver_number}: Waveforms from All 5 Sources\")\n\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:22:05.086993Z","iopub.execute_input":"2026-01-19T06:22:05.087374Z","iopub.status.idle":"2026-01-19T06:22:05.331472Z","shell.execute_reply.started":"2026-01-19T06:22:05.087344Z","shell.execute_reply":"2026-01-19T06:22:05.330574Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### 3. Slice by time","metadata":{}},{"cell_type":"markdown","source":"This plot shows a wavefield snapshot of the seismic data at a fixed time step (t = 300) for a single training sample.\n\nAt this specific moment in time:\n\n* X-axis represents the receiver index (spatial positions of receivers)\n* Y-axis represents the seismic source index\n* Color intensity represents the seismic wave amplitude\n\nEach row corresponds to the wave energy recorded from one seismic source across all receivers at the same time step.\nBright regions indicate strong wave arrivals at particular receivers, while darker regions indicate low or no wave energy.\n\nThis visualization provides an instantaneous spatial view of how seismic energy from different sources propagates through the subsurface and reaches the receiver array.","metadata":{}},{"cell_type":"code","source":"time_id = 300  # try early vs late times\n\nplt.figure(figsize=(6, 4))\nplt.imshow(x[:, time_id, :], aspect=\"auto\", cmap=\"seismic\")\nplt.colorbar(label=\"Amplitude\")\nplt.xlabel(\"Receivers\")\nplt.ylabel(\"Sources\")\nplt.title(f\"Wavefield Snapshot at t={time_id}\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:22:05.333420Z","iopub.execute_input":"2026-01-19T06:22:05.333692Z","iopub.status.idle":"2026-01-19T06:22:05.602518Z","shell.execute_reply.started":"2026-01-19T06:22:05.333671Z","shell.execute_reply":"2026-01-19T06:22:05.601528Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Model","metadata":{}},{"cell_type":"code","source":"model = np.load(\"/kaggle/input/waveform-inversion/train_samples/Style_A/model/model1.npy\")\nprint(model.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:22:05.603528Z","iopub.execute_input":"2026-01-19T06:22:05.603851Z","iopub.status.idle":"2026-01-19T06:22:05.616078Z","shell.execute_reply.started":"2026-01-19T06:22:05.603828Z","shell.execute_reply":"2026-01-19T06:22:05.615259Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"This plot shows the ground-truth subsurface velocity map for a single training sample from the dataset.\n\nThe velocity map is a 2D spatial image where:\n\n* Each pixel represents the seismic wave velocity at a specific subsurface location\n* Color intensity (shown by the colorbar) indicates the magnitude of velocity, with lower velocities shown in darker colors and higher velocities in brighter colors\n\nThe smooth spatial variations and localized high-velocity regions reflect different subsurface material properties and structural patterns present in the model.\n\nThis velocity map serves as the supervised learning target for the model, which must learn to predict this image from the corresponding seismic waveform data.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(5, 5))\nplt.imshow(model[0][0], cmap=\"viridis\")\nplt.colorbar(label=\"Velocity\")\nplt.title(\"Velocity Map (Ground Truth)\")\nplt.axis(\"off\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-19T06:22:05.617199Z","iopub.execute_input":"2026-01-19T06:22:05.617635Z","iopub.status.idle":"2026-01-19T06:22:05.793179Z","shell.execute_reply.started":"2026-01-19T06:22:05.617615Z","shell.execute_reply":"2026-01-19T06:22:05.791924Z"}},"outputs":[],"execution_count":null}]}