-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gao
committed
Oct 31, 2024
1 parent
a9bbc96
commit 6b4a94d
Showing
19 changed files
with
3,149 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,333 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import warnings\n", | ||
"warnings.filterwarnings(\"ignore\")\n", | ||
"\n", | ||
"import plot\n", | ||
"import models\n", | ||
"from feature_ecoding.clip_surface import Fault_feature\n", | ||
"import torch\n", | ||
"import pandas as pd\n", | ||
"import os\n", | ||
"import importlib" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"GPU amount: 1\n", | ||
"device: cuda\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"torch.manual_seed(0)\n", | ||
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", | ||
"\n", | ||
"if torch.cuda.is_available():\n", | ||
" num_GPU = torch.cuda.device_count()\n", | ||
" print(f\"GPU amount: {num_GPU}\")\n", | ||
"else:\n", | ||
" num_GPU = 0\n", | ||
"\n", | ||
"print(f\"device: {device}\")\n", | ||
"root_path = os.path.abspath('.')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"1. load observational data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"surface_points = pd.read_csv(os.path.join(root_path, 'data', 'case2', 'original_data', 'filtered_surface_points.csv'))\n", | ||
"orientation_points = pd.read_csv(os.path.join(root_path, 'data', 'case2', 'original_data', 'filtered_orientations.csv'))\n", | ||
"extent = [451000,456000, 6782000, 6784000, -6927, -4953]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot.observation(surface_points, orientation_points, extent)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"2. modeling fault surfaces" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Finish modeling fault3 | Loss_i: 0.016700157895684242, Loss_o: 0.05635257437825203, Loss_ab:0.0\n", | ||
"Finish modeling fault4 | Loss_i: 0.012287864461541176, Loss_o: 0.058752622455358505, Loss_ab:0.0\n", | ||
"------Finish-------\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"fault_mesh = models.fault_ConcatMLP(surface_points, # original data read from csv file\n", | ||
" orientation_points, # original data read from csv file\n", | ||
" extent, # domain boundary\n", | ||
" resolution=[60, 30, 30], # resolution of the fault mesh, lower resolution to reduce the computation time in feature encoding,\n", | ||
" in_dim=3, # input dimension of neural network\n", | ||
" hidden_dim=256, # hidden layer's dimension of neural network\n", | ||
" out_dim=1, # output dimension of neural network, the only output is a scalar value\n", | ||
" n_hidden_layers=2, # number of hidden layers\n", | ||
" activation='Softplus', # activation function, default is 'Softplus'\n", | ||
" beta_list=[25, 70], # `beta` values for Softplus activation function, the length related to the number of faults\n", | ||
" concat = True, # whether to concat the input features to hidden layers\n", | ||
" epochs=3000, # number of forward and backward propagation process \n", | ||
" lr=0.001, # learning rate\n", | ||
" above_below=True) # whether to use `above_below` loss function, default is False" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot.fault_mesh(fault_mesh, surface_points, orientation_points, extent)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#importlib.reload(plot)\n", | ||
"plot.observation_fault_mesh(surface_points, orientation_points, extent, fault_mesh)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"3. fault feature encoding" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"domain_mesh_features, label_interf_all, orie_points_all = Fault_feature.encoding(extents=extent, # domain boundary\n", | ||
" resolution=[100, 100, 100], # resolution of the domain mesh\n", | ||
" mesh_list=fault_mesh, # fault mesh list\n", | ||
" surface_points=surface_points, # original data read from csv file\n", | ||
" orientation_points=orientation_points, # original data read from csv file\n", | ||
" movement=['down','down'], # 'up' or 'down', relative movement in fault right side\n", | ||
" fault_direct=['right','right'], # fault surface direction, insures correct feature encoding\n", | ||
" decimate=0.0) # reserve all the points in fault mesh" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"\" plot.feature_encoding(mesh_list=fault_mesh, # fault mesh list after editing\\n number=0, # 0 is the first mesh, 1 is the second mesh\\n extent=extent, # domain boundary\\n type='obs_point', # 'mesh_point' or 'obs_point', visualization type\\n side='up', # 'up' or 'down', 'up' is the side which assigned value 1 in the feature encoding\\n domain_mesh_features=domain_mesh_features, # meshgrid points of interpreated domain\\n label_interf_all=label_interf_all, # strtigraphic points with labels\\n orie_points_all=orie_points_all) # orientation points \"" | ||
] | ||
}, | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"\"\"\" plot.feature_encoding(mesh_list=fault_mesh, # fault mesh list after editing\n", | ||
" number=0, # 0 is the first mesh, 1 is the second mesh\n", | ||
" extent=extent, # domain boundary\n", | ||
" type='obs_point', # 'mesh_point' or 'obs_point', visualization type\n", | ||
" side='up', # 'up' or 'down', 'up' is the side which assigned value 1 in the feature encoding\n", | ||
" domain_mesh_features=domain_mesh_features, # meshgrid points of interpreated domain\n", | ||
" label_interf_all=label_interf_all, # strtigraphic points with labels\n", | ||
" orie_points_all=orie_points_all) # orientation points \"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"4. modeling the discontinuious stratigraphic" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Training losses | Loss_i: 0.482204794883728, Loss_o: 0.5115153789520264\n", | ||
"each epoch training time : 0.002317742586135864 seconds\n", | ||
"Inference time: 6.364690065383911 seconds\n", | ||
"------Finish-------\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"stratigraphic_mesh, scalar_field_strat = models.stratigraphic_ConcatMLP(interface_data=label_interf_all, # stratigraphic points with labels\n", | ||
" orientation_data=orie_points_all, # orientation points\n", | ||
" meshgrid_data=domain_mesh_features, # meshgrid points of interpreated domain\n", | ||
" extent=extent, # domain boundary\n", | ||
" resolution=[100, 100, 100], # resolution of the domain mesh\n", | ||
" in_dim=5, # input dimension of neural network\n", | ||
" hidden_dim=512, # hidden layer's dimension of neural network\n", | ||
" out_dim=1, # output dimension of neural network, the only output is a scalar value\n", | ||
" n_hidden_layers=2, # number of hidden layers\n", | ||
" activation='Softplus', # activation function, default is 'Softplus'\n", | ||
" beta=210, # `beta` value for Softplus activation function\n", | ||
" concat=True, # whether to concat the input features to hidden layers\n", | ||
" epochs=1000, # number of forward and backward propagation process\n", | ||
" lr=0.001, # learning rate\n", | ||
" alpha=1) # the efficiency of orientation loss, default is 0.1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot.scalar_field(scalar_field_strat, fault_mesh)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"5. modeling the unconformity layer" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Finish modeling BCU | Loss_i: 0.004268969874829054, Loss_o: 0.010167177766561508\n", | ||
"------Finish-------\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"unconformity_mesh, scalar_field_unconf = models.unconformity_ConcatMLP(surface_points, \n", | ||
" orientation_points, \n", | ||
" extent,\n", | ||
" resolution=[100, 100, 100], \n", | ||
" in_dim=3,\n", | ||
" hidden_dim=256, \n", | ||
" out_dim=1,\n", | ||
" n_hidden_layers=2,\n", | ||
" activation='Softplus', # Softplus, ReLU , LeakyReLU, Tanh, Sigmoid, and ELU can be selected\n", | ||
" beta_list=[100], \n", | ||
" concat = False,\n", | ||
" epochs=2000,\n", | ||
" lr=0.001,)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#importlib.reload(plot)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot.final_structure(fautl_mesh_list = fault_mesh,\n", | ||
" stratigraphic_mesh = stratigraphic_mesh,\n", | ||
" unconformity_mesh_list = unconformity_mesh,\n", | ||
" surface_points = surface_points,\n", | ||
" orientation_points = orientation_points,\n", | ||
" extent=extent,\n", | ||
" unconformity=True,)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot.layer(scalar_field_strat, fault_mesh, extent)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "ml_modeling", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.15" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
X,Y,Z,dx,dy,dz,formation,group,type | ||
550,500,-600,-0.894934362,9.58E-18,0.446197813,fault2,fault2,fault | ||
350,500,-700,0.894934362,1.00E-12,0.446197813,fault1,fault1,fault | ||
400,500,-625,1.00E-12,1.00E-12,1,rock4,B,stratigraphic | ||
150,500,-550,1.00E-12,1.00E-12,1,rock4,A,stratigraphic | ||
850,500,-525,1.00E-12,1.00E-12,1,rock4,C,stratigraphic | ||
400,500,-675,1.00E-12,1.00E-12,1,rock3,B,stratigraphic | ||
150,500,-600,1.00E-12,1.00E-12,1,rock3,A,stratigraphic | ||
850,500,-575,1.00E-12,1.00E-12,1,rock3,C,stratigraphic | ||
850,500,-625,1.00E-12,1.00E-12,1,rock2,C,stratigraphic | ||
150,500,-650,1.00E-12,1.00E-12,1,rock2,A,stratigraphic | ||
150,500,-700,1.00E-12,1.00E-12,1,rock1,A,stratigraphic | ||
850,500,-675,1.00E-12,1.00E-12,1,rock1,C,stratigraphic |
Oops, something went wrong.