{"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":31012,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# [Full OpenFWI](https://huggingface.co/datasets/samitizerxu/openfwi) on Huggingface\n\nI uploaded the full OpenFWI dataset for my own ease of use (link in title), but hopefully others can make use of it too in their experiments. You can access a small subset of the dataset by using the `allow_patterns` parameter of `huggingface_hub.snapshot_download`. Thanks to the organizers for releasing such a comprehensive dataset!\n\nIf you use this, I'd really appreciate an upvote :)","metadata":{}},{"cell_type":"code","source":"from huggingface_hub import snapshot_download\n\nmatching_string = [\"FlatVel_A/model/model2.npy\",\"FlatVel_A/data/data2.npy\"]\nsnapshot_download(\n    repo_id=\"samitizerxu/openfwi\",\n    repo_type=\"dataset\",\n    allow_patterns=matching_string,\n    local_dir=\"/kaggle/working\"\n)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-04-16T22:44:59.084920Z","iopub.execute_input":"2025-04-16T22:44:59.085246Z","iopub.status.idle":"2025-04-16T22:45:03.997297Z","shell.execute_reply.started":"2025-04-16T22:44:59.085215Z","shell.execute_reply":"2025-04-16T22:45:03.995524Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!find *","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:23:30.269439Z","iopub.execute_input":"2025-04-16T01:23:30.269780Z","iopub.status.idle":"2025-04-16T01:23:30.394160Z","shell.execute_reply.started":"2025-04-16T01:23:30.269752Z","shell.execute_reply":"2025-04-16T01:23:30.393028Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#### And now we can visualize it as in the tutorial...","metadata":{}},{"cell_type":"code","source":"import numpy as np\nvelocity = np.load('FlatVel_A/model/model2.npy')\ndata = np.load('FlatVel_A/data/data2.npy')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:24:57.166865Z","iopub.execute_input":"2025-04-16T01:24:57.167189Z","iopub.status.idle":"2025-04-16T01:24:57.536585Z","shell.execute_reply.started":"2025-04-16T01:24:57.167164Z","shell.execute_reply":"2025-04-16T01:24:57.535569Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Velocity map size:', velocity.shape)\nprint('Seismic data size:', data.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:24:57.537931Z","iopub.execute_input":"2025-04-16T01:24:57.538206Z","iopub.status.idle":"2025-04-16T01:24:57.543293Z","shell.execute_reply.started":"2025-04-16T01:24:57.538186Z","shell.execute_reply":"2025-04-16T01:24:57.542341Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n## Select a sample in the data\nsample=10","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:24:57.594812Z","iopub.execute_input":"2025-04-16T01:24:57.595147Z","iopub.status.idle":"2025-04-16T01:24:57.600028Z","shell.execute_reply.started":"2025-04-16T01:24:57.595122Z","shell.execute_reply":"2025-04-16T01:24:57.599057Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from matplotlib.colors import ListedColormap\nfig, ax = plt.subplots(1, 1, figsize=(11, 5))\nimg=ax.imshow(velocity[sample,0,:,:],cmap='jet')\nax.set_xticks(range(0, 70, 10))\nax.set_xticklabels(range(0, 700, 100))\nax.set_yticks(range(0, 70, 10))\nax.set_yticklabels(range(0, 700, 100))\nax.set_ylabel('Depth (m)', fontsize=12)\nax.set_xlabel('Offset (m)', fontsize=12)\nclb=plt.colorbar(img, ax=ax)\nclb.ax.set_title('km/s',fontsize=8)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:24:57.924415Z","iopub.execute_input":"2025-04-16T01:24:57.924733Z","iopub.status.idle":"2025-04-16T01:24:58.256861Z","shell.execute_reply.started":"2025-04-16T01:24:57.924710Z","shell.execute_reply":"2025-04-16T01:24:58.255251Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Seismic data size:', data.shape)\n\nfig,ax=plt.subplots(1,5,figsize=(20,5))\nax[0].imshow(data[sample,0,:,:],extent=[0,70,1000,0],aspect='auto',cmap='gray',vmin=-0.5,vmax=0.5)\nax[1].imshow(data[sample,1,:,:],extent=[0,70,1000,0],aspect='auto',cmap='gray',vmin=-0.5,vmax=0.5)\nax[2].imshow(data[sample,2,:,:],extent=[0,70,1000,0],aspect='auto',cmap='gray',vmin=-0.5,vmax=0.5)\nax[3].imshow(data[sample,3,:,:],extent=[0,70,1000,0],aspect='auto',cmap='gray',vmin=-0.5,vmax=0.5)\nax[4].imshow(data[sample,4,:,:],extent=[0,70,1000,0],aspect='auto',cmap='gray',vmin=-0.5,vmax=0.5)\nfor axis in ax:\n   axis.set_xticks(range(0, 70, 10))\n   axis.set_xticklabels(range(0, 700, 100))\n   axis.set_yticks(range(0, 2000, 1000))\n   axis.set_yticklabels(range(0, 2,1))\n   axis.set_ylabel('Time (s)', fontsize=12)\n   axis.set_xlabel('Offset (m)', fontsize=12)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-16T01:24:58.262225Z","iopub.execute_input":"2025-04-16T01:24:58.262681Z","iopub.status.idle":"2025-04-16T01:24:58.827771Z","shell.execute_reply.started":"2025-04-16T01:24:58.262642Z","shell.execute_reply":"2025-04-16T01:24:58.826723Z"}},"outputs":[],"execution_count":null}]}