-
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
Showing
133 changed files
with
9,163 additions
and
118 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 7384e4368c80a77c74dfe9ccb0c64130 | ||
config: bf128f32401c8c51e9df4523ae774d05 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
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,10 @@ | ||
# copy the .env.sample to .env and populate it with their own values when they clone the repository. | ||
# cp .env.sample .env | ||
# Example path | ||
GIT_PERSONAL_ACCESS_TOKEN="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" | ||
PATH_TO_COLLINSTOWN="/mnt/d/OneDrive - Terranigma Solutions GmbH/Documents/Projects/Ongoing Projects/Vector/DataSets/Share/Leapfrog_OMF/Leapfrog_OMF/Collinstown.omf" | ||
|
||
PATH_TO_STONEPARK="/mnt/d/OneDrive - Terranigma Solutions GmbH/Documents/Projects/Ongoing Projects/Vector/DataSets/Stonepark/Stonepark.omf" | ||
PATH_TO_STONEPARK2="/mnt/d/OneDrive - Terranigma Solutions GmbH/Documents/Projects/Ongoing Projects/Vector/DataSets/Share/Leapfrog_OMF/Leapfrog_OMF/Stonepark.omf" | ||
|
||
PATH_TO_STONEPARK_Subsurface="/mnt/d/OneDrive - Terranigma Solutions GmbH/Documents/Projects/Ongoing Projects/Vector/DataSets/Stonepark/Subsurface" |
133 changes: 133 additions & 0 deletions
133
_downloads/2f3603a17cd50bc65aeadb777e3c4e90/collinstown_OMF_to_subsurface.ipynb
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,133 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Reading COLLINSTOWN OMF project\n\nThis tutorial demonstrates how to read an OMF project file in COLLINSTOWN.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Required Libraries:\n\nImport the required libraries. \n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import omfvista\nimport pandas as pd\nimport pyvista\nimport subsurface\nfrom subsurface import TriSurf, LineSet\nfrom subsurface.visualization import to_pyvista_mesh, pv_plot, to_pyvista_line, init_plotter\nfrom subsurface.writer import base_structs_to_binary_file\nfrom dotenv import dotenv_values" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Load OMF Project:\n\nLoad the OMF project using a fixture.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def load_omf():\n config = dotenv_values()\n path = config.get('PATH_TO_COLLINSTOWN')\n omf = omfvista.load_project(path)\n return omf\n\nomf = load_omf()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Read OMF with PyVista:\n\nVisualize the OMF project with PyVista.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"if False:\n omf.plot(multi_colors=True, show_edges=True, notebook=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Convert OMF to Unstructured Single Block:\n\nConvert the loaded OMF project into an unstructured single block for further analysis.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"meshes = []\nlines = []\nfor e in range(omf.n_blocks):\n\n block_name = omf.get_block_name(e)\n polydata_obj: pyvista.PolyData = omf[block_name]\n # Check if the polydata is a mesh and if is not continue\n print(polydata_obj.cell_type(0))\n unstruct_pyvista: pyvista.UnstructuredGrid = polydata_obj.cast_to_unstructured_grid()\n\n grid = unstruct_pyvista \n cell_data = {name: grid.cell_data[name] for name in grid.cell_data}\n match polydata_obj.cell_type(0):\n case pyvista.CellType.TRIANGLE:\n if False: continue # TODO: Remove this\n \n cells_pyvista = unstruct_pyvista.cells.reshape(-1, 4)[:, 1:]\n new_cell_data = {\n **{\n \"Formation_Major_\": e,\n },\n **cell_data\n }\n unstruct: subsurface.UnstructuredData = subsurface.UnstructuredData.from_array(\n vertex=unstruct_pyvista.points,\n cells=cells_pyvista,\n cells_attr=pd.DataFrame(new_cell_data)\n )\n \n ts = TriSurf(mesh=unstruct)\n s = to_pyvista_mesh(ts)\n meshes.append(s)\n\n \n case pyvista.CellType.LINE:\n if \"Formation_Major\" not in cell_data.keys(): continue\n cells_pyvista = unstruct_pyvista.cells.reshape(-1, 3)[:, 1:]\n unstruct: subsurface.UnstructuredData = subsurface.UnstructuredData.from_array(\n vertex=unstruct_pyvista.points,\n cells=cells_pyvista,\n cells_attr=pd.DataFrame(cell_data)\n )\n line = LineSet(data=unstruct)\n s = to_pyvista_line(line, radius=100, as_tube=True, spline=False)\n \n lines.append(s)\n\nif False: # Replace with condition for exporting to Liquid Earth\n base_structs_to_binary_file(\"leapfrog1\", unstruct)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Visualize Unstructured Data:\nUse Subsurface and PyVista to visualize the unstructured data.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"plotter = init_plotter()\nfor mesh in meshes[3:]:\n plotter.add_mesh(mesh, cmap=\"magma\", opacity=0.7)\n\nfor line in lines:\n plotter.add_mesh(line, cmap=\"viridis\", opacity=1)\n\nplotter.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
118 changes: 118 additions & 0 deletions
118
_downloads/332b9ea3642c2c20e3a6b81a57e38ce7/collinstown_OMF_to_subsurface.py
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,118 @@ | ||
""" | ||
Reading COLLINSTOWN OMF project | ||
================================ | ||
This tutorial demonstrates how to read an OMF project file in COLLINSTOWN. | ||
""" | ||
|
||
# %% | ||
# Required Libraries: | ||
# ~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Import the required libraries. | ||
|
||
import omfvista | ||
import pandas as pd | ||
import pyvista | ||
import subsurface | ||
from subsurface import TriSurf, LineSet | ||
from subsurface.visualization import to_pyvista_mesh, pv_plot, to_pyvista_line, init_plotter | ||
from subsurface.writer import base_structs_to_binary_file | ||
from dotenv import dotenv_values | ||
|
||
# %% | ||
# Load OMF Project: | ||
# ~~~~~~~~~~~~~~~~~ | ||
# | ||
# Load the OMF project using a fixture. | ||
|
||
def load_omf(): | ||
config = dotenv_values() | ||
path = config.get('PATH_TO_COLLINSTOWN') | ||
omf = omfvista.load_project(path) | ||
return omf | ||
|
||
omf = load_omf() | ||
|
||
# %% | ||
# Read OMF with PyVista: | ||
# ~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Visualize the OMF project with PyVista. | ||
|
||
if False: | ||
omf.plot(multi_colors=True, show_edges=True, notebook=False) | ||
|
||
# %% | ||
# Convert OMF to Unstructured Single Block: | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Convert the loaded OMF project into an unstructured single block for further analysis. | ||
|
||
meshes = [] | ||
lines = [] | ||
for e in range(omf.n_blocks): | ||
|
||
block_name = omf.get_block_name(e) | ||
polydata_obj: pyvista.PolyData = omf[block_name] | ||
# Check if the polydata is a mesh and if is not continue | ||
print(polydata_obj.cell_type(0)) | ||
unstruct_pyvista: pyvista.UnstructuredGrid = polydata_obj.cast_to_unstructured_grid() | ||
|
||
grid = unstruct_pyvista | ||
cell_data = {name: grid.cell_data[name] for name in grid.cell_data} | ||
match polydata_obj.cell_type(0): | ||
case pyvista.CellType.TRIANGLE: | ||
if False: continue # TODO: Remove this | ||
|
||
cells_pyvista = unstruct_pyvista.cells.reshape(-1, 4)[:, 1:] | ||
new_cell_data = { | ||
**{ | ||
"Formation_Major_": e, | ||
}, | ||
**cell_data | ||
} | ||
unstruct: subsurface.UnstructuredData = subsurface.UnstructuredData.from_array( | ||
vertex=unstruct_pyvista.points, | ||
cells=cells_pyvista, | ||
cells_attr=pd.DataFrame(new_cell_data) | ||
) | ||
|
||
ts = TriSurf(mesh=unstruct) | ||
s = to_pyvista_mesh(ts) | ||
meshes.append(s) | ||
|
||
|
||
case pyvista.CellType.LINE: | ||
if "Formation_Major" not in cell_data.keys(): continue | ||
cells_pyvista = unstruct_pyvista.cells.reshape(-1, 3)[:, 1:] | ||
unstruct: subsurface.UnstructuredData = subsurface.UnstructuredData.from_array( | ||
vertex=unstruct_pyvista.points, | ||
cells=cells_pyvista, | ||
cells_attr=pd.DataFrame(cell_data) | ||
) | ||
line = LineSet(data=unstruct) | ||
s = to_pyvista_line(line, radius=100, as_tube=True, spline=False) | ||
|
||
lines.append(s) | ||
|
||
if False: # Replace with condition for exporting to Liquid Earth | ||
base_structs_to_binary_file("leapfrog1", unstruct) | ||
|
||
# %% | ||
# Visualize Unstructured Data: | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Use Subsurface and PyVista to visualize the unstructured data. | ||
|
||
plotter = init_plotter() | ||
for mesh in meshes[3:]: | ||
plotter.add_mesh(mesh, cmap="magma", opacity=0.7) | ||
|
||
for line in lines: | ||
plotter.add_mesh(line, cmap="viridis", opacity=1) | ||
|
||
plotter.show() | ||
|
||
|
||
|
Oops, something went wrong.