Skip to content

Commit 36d0b64

Browse files
committed
- [DOC] Finish kriging example
1 parent f059046 commit 36d0b64

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

gempy_plugins/kriging/kriging.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
from gempy_engine.core.data.raw_arrays_solution import RawArraysSolution
1515

16+
from gempy_viewer.modules.plot_2d.visualization_2d import Plot2D
17+
from gempy_viewer.modules.plot_2d.drawer_regular_grid_2d import plot_regular_grid_area
18+
1619
try:
1720
from scipy.spatial.distance import cdist
1821
except ImportError:
@@ -221,7 +224,7 @@ def plot(self, type_='variogram', show_parameters=True):
221224
plt.xlim(0, self.range_ * 4)
222225

223226

224-
class field_solution(object):
227+
class KrigingFieldSolution(object):
225228

226229
def __init__(self, domain, variogram_model, results, field_type):
227230

@@ -307,6 +310,27 @@ def plot_results(self, geo_data, prop='val', direction='y', result='interpolatio
307310
plt.tight_layout()
308311

309312

313+
def plot_kriging_results(geo_data: gp.data.GeoModel, kriging_solution: KrigingFieldSolution, plot_2d: Plot2D,
314+
title: str, result_column: list[str]):
315+
for e, ax in enumerate(plot_2d.axes):
316+
a = np.full_like(kriging_solution.domain.mask, np.nan, dtype=np.double)
317+
vals = kriging_solution.results_df[result_column[e]].values
318+
a[np.where(kriging_solution.domain.mask == True)] = vals
319+
320+
im = plot_regular_grid_area(
321+
ax=ax,
322+
slicer_data=plot_2d.section_data_list[0].slicer_data,
323+
block=a,
324+
resolution=geo_data.grid.regular_grid.resolution,
325+
cmap='viridis',
326+
norm=None,
327+
)
328+
329+
ax.set_title(title)
330+
plot_2d.fig.colorbar(im, label='Property value')
331+
plot_2d.fig.show()
332+
333+
310334
# TODO: check with new ordianry kriging and nugget effect
311335
def simple_kriging(a, b, prop, var_mod, inp_mean):
312336
'''
@@ -463,7 +487,7 @@ def create_kriged_field(domain, variogram_model, distance_type='euclidian',
463487

464488
results_df = pd.DataFrame(data=d)
465489

466-
return field_solution(domain, variogram_model, results_df, field_type='interpolation')
490+
return KrigingFieldSolution(domain, variogram_model, results_df, field_type='interpolation')
467491

468492

469493
def create_gaussian_field(domain, variogram_model, distance_type='euclidian',
@@ -578,4 +602,4 @@ def create_gaussian_field(domain, variogram_model, distance_type='euclidian',
578602
results_df = pd.DataFrame(data=d)
579603
results_df = results_df.sort_values(['X', 'Y', 'Z'])
580604

581-
return field_solution(domain, variogram_model, results_df, field_type='simulation')
605+
return KrigingFieldSolution(domain, variogram_model, results_df, field_type='simulation')

0 commit comments

Comments
 (0)