From 6db2023324025987c20fb21267981c358877437e Mon Sep 17 00:00:00 2001 From: Laurent Ailleres Date: Thu, 20 Nov 2025 09:07:27 +1100 Subject: [PATCH 1/3] Adding the function to add dataframe as pts with nesting in geohy5.py --- LoopStructural/export/geoh5.py | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/LoopStructural/export/geoh5.py b/LoopStructural/export/geoh5.py index c91501e0..15e03d91 100644 --- a/LoopStructural/export/geoh5.py +++ b/LoopStructural/export/geoh5.py @@ -61,6 +61,47 @@ def add_points_to_geoh5(filename, point, overwrite=True, groupname="Loop"): ) point.add_data(data) +def add_points_from_df(filename, df, overwrite=True, child = None, parent = None, + normal_cols=['nx','ny','nz']): + with geoh5py.workspace.Workspace(filename) as workspace: + entities = workspace.get_entity(child) + child_name = child + child = entities[0] if entities else None + if not child: + child = geoh5py.groups.ContainerGroup.create( + workspace, name=child_name, allow_delete=True, + ) + if parent: + parent.add_children(child) + + for _, row in df.iterrows(): + name = row['name'] + loc = np.array([[row['X'], row['Y'], row['Z']]]) # shape (1,3) + + # remove existing entity if present and overwrite requested + if name in workspace.list_entities_name.values(): + existing = workspace.get_entity(name) + if existing: + existing[0].allow_delete = True + if overwrite: + workspace.remove_entity(existing[0]) + + pts = geoh5py.objects.Points.create( + workspace, + name=name, + vertices=loc, + parent=child, + ) + + # build data dict from normal_cols (and any other columns you want) + data = {} + for col in normal_cols: + if col in row and not pd.isna(row[col]): + # association must be "VERTEX" and values length must match vertices (1) + data[col] = {"association": "VERTEX", "values": np.array([row[col]])} + + if data: + pts.add_data(data) def add_structured_grid_to_geoh5(filename, structured_grid, overwrite=True, groupname="Loop"): with geoh5py.workspace.Workspace(filename) as workspace: From cd2aabe7b005f86ceabcfd9c5cedb776cb0e9a48 Mon Sep 17 00:00:00 2001 From: Laurent Ailleres Date: Thu, 20 Nov 2025 09:55:43 +1100 Subject: [PATCH 2/3] Update geoh5.py --- LoopStructural/export/geoh5.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LoopStructural/export/geoh5.py b/LoopStructural/export/geoh5.py index 15e03d91..c55f68e7 100644 --- a/LoopStructural/export/geoh5.py +++ b/LoopStructural/export/geoh5.py @@ -1,6 +1,8 @@ import geoh5py import geoh5py.workspace import numpy as np +import pandas as pd + from LoopStructural.datatypes import ValuePoints, VectorPoints From 3f064032fa9722340db0e67ac80a01c36b3378cf Mon Sep 17 00:00:00 2001 From: Laurent Ailleres Date: Thu, 20 Nov 2025 10:30:06 +1100 Subject: [PATCH 3/3] Update __init__.py The ability to import that function was missing... annoying! --- LoopStructural/utils/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/LoopStructural/utils/__init__.py b/LoopStructural/utils/__init__.py index 0aaab409..d210e738 100644 --- a/LoopStructural/utils/__init__.py +++ b/LoopStructural/utils/__init__.py @@ -26,6 +26,7 @@ plungeazimuth2vector, azimuthplunge2vector, normal_vector_to_strike_and_dip, + normal_vector_to_dip_and_dip_direction, rotate, ) from .helper import create_surface, create_box