Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cgre-aachen/gempy
Browse files Browse the repository at this point in the history
  • Loading branch information
Japhiolite committed Aug 14, 2023
2 parents cd171fe + 9866d78 commit c4c7613
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gempy/core/data_modules/geometric_data.py
Expand Up @@ -162,7 +162,7 @@ def map_data_from_surfaces(self, surfaces, attribute: str, idx=None):
def _add_surface_to_list_from_new_surface_points_or_orientations(self, idx, surface: list | str):
if type(surface) is str: surface = [surface]

# Check is self.df['surface'] is a category
# Check if self.df['surface'] is a category
if not isinstance(self.df['surface'].dtype, pd.CategoricalDtype):
self.df['surface'] = self.df['surface'].astype('category', copy=True)
self.df['surface'] = self.df['surface'].cat.set_categories(self.surfaces.df['surface'].values)
Expand All @@ -172,7 +172,7 @@ def _add_surface_to_list_from_new_surface_points_or_orientations(self, idx, surf
# if s not in self.df['surface'].cat.categories:
# self.df['surface'] = self.df['surface'].cat.add_categories(s)

if type(idx) is int:
if isinstance(idx, (np.int64, int)):
self.df.loc[idx, 'surface'] = surface[0]
elif type(idx) is list:
self.df.loc[idx, 'surface'] = surface
19 changes: 18 additions & 1 deletion test/test_core/test_data_mutation.py
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import pytest
import os
import matplotlib.pyplot as plt

mm = gp.ImplicitCoKriging()
mm.add_surfaces(['surface1', 'foo1', 'foo2', 'foo3'])
Expand Down Expand Up @@ -93,4 +94,20 @@ def test_read_data():
model.read_data(path_i=data_path + "/data/input_data/tut_chapter1/simple_fault_model_points.csv",
path_o=data_path + "/data/input_data/tut_chapter1/simple_fault_model_orientations.csv")

assert model._surface_points.df.shape[0] == 57
assert model._surface_points.df.shape[0] == 57

def test_add_surface_points_to_model():
geo_model = gp.create_model('TestModel1')
gp.init_data(geo_model, extent=[0, 800, 0, 200, -600, 0], resolution=[100, 100, 100])
geo_model.set_default_surfaces()

geo_model.add_surface_points(X=223, Y=0.01, Z=-94, surface='surface1')
geo_model.add_surface_points(X=458, Y=0, Z=-107, surface='surface1')
geo_model.add_surface_points(X=612, Y=0, Z=-14, surface='surface1')
geo_model.add_orientations(X=350, Y=0, Z=-300, surface='surface1', pole_vector=(0, 0, 1))

geo_model.add_surface_points(X=225, Y=1, Z=-269, surface='surface2')
geo_model.add_surface_points(X=459, Y=1, Z=-279, surface='surface2')

#gp.plot_2d(geo_model, cell_number=5, legend='force')
#plt.show()

0 comments on commit c4c7613

Please sign in to comment.