Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[WIP/ENH] Getting the section running
  • Loading branch information
Leguark committed May 25, 2025
commit 44d3f1bb34fa7c1be36213648e78809303743a7b
34 changes: 4 additions & 30 deletions gempy/core/data/grid_modules/sections_grid.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pydantic import Field, model_validator
from typing import Tuple, Dict, List, Optional

import dataclasses
import numpy as np
from pydantic import Field
from typing import Tuple, Dict, List, Optional

from ..core_utils import calculate_line_coordinates_2points
from ..encoders.converters import short_array_type
Expand Down Expand Up @@ -42,7 +41,7 @@ class Sections:
]

# computed/internal (will be serialized too unless excluded)
names: List[str] = Field(default_factory=list, exclude=True)
names: short_array_type = Field(default=np.array([]), exclude=True)
points: List[List[Tuple[float, float]]] = Field(default_factory=list, exclude=True)
resolution: List[Tuple[int, int]] = Field(default_factory=list, exclude=True)
length: np.ndarray = Field(default_factory=lambda: np.array([0]), exclude=True)
Expand All @@ -51,38 +50,13 @@ class Sections:
values: np.ndarray = Field(default_factory=lambda: np.empty((0, 3)), exclude=True)
extent: Optional[np.ndarray] = Field(default=None, exclude=True)

# def __init__(self, regular_grid=None, z_ext=None, section_dict=None):
# pd = require_pandas()
# if regular_grid is not None:
# self.z_ext = regular_grid.extent[4:]
# else:
# self.z_ext = z_ext
#
# self.section_dict = section_dict
# self.names = []
# self.points = []
# self.resolution = []
# self.length = [0]
# self.dist = []
# self.df = pd.DataFrame()
# self.df['dist'] = self.dist
# self.values = np.empty((0, 3))
# self.extent = None
#
# if section_dict is not None:
# self.set_sections(section_dict)
def __post_init__(self):
self.initialize_computations()
pass

# @model_validator(mode="after")
# def init_class(self):
# self.initialize_computations()
# return self
#
def initialize_computations(self):
# copy names
self.names = list(self.section_dict.keys())
self.names = np.array(list(self.section_dict.keys()))

# build points/resolution/length
self._get_section_params()
Expand Down
3 changes: 1 addition & 2 deletions test/test_modules/test_grids/test_grids_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def test_section_grids():
verify_moment="after",
file_name=f"verify/{geo_model.meta.name}"
)
return
gp.compute_model(geo_model)
gp.compute_model(geo_model, validate_serialization=False)
gpv.plot_2d(
model=geo_model,
section_names=['section_SW-NE', 'section_NW-SE', 'topography'],
Expand Down