Skip to content

Commit c644add

Browse files
committed
[WIP] Moving likelihood function to module
1 parent 7e431f9 commit c644add

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from _apparent_thickness import apparent_thickness_likelihood
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import gempy as gp
2+
import torch
3+
import pyro
4+
5+
def apparent_thickness_likelihood(model_solutions: gp.data.Solutions) -> torch.Tensor:
6+
"""
7+
This function computes the thickness of the geological layer.
8+
"""
9+
simulated_well = model_solutions.octrees_output[0].last_output_center.custom_grid_values
10+
thickness = simulated_well.sum()
11+
pyro.deterministic(
12+
name=r'$\mu_{thickness}$',
13+
value=thickness.detach() # * This is only for az to track progress
14+
)
15+
return thickness

gempy_probability/modules/model_definition/model_examples.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import gempy.core.data
33
import gempy_engine
44
from gempy.modules.data_manipulation.engine_factory import interpolation_input_from_structural_frame
5+
from gempy_probability.modules.likelihoods import apparent_thickness_likelihood
56

67
import pyro
78
import pyro.distributions as dist
@@ -53,7 +54,7 @@ def model(geo_model: gempy.core.data.GeoModel, normal, y_obs_list):
5354

5455
# Compute and observe the thickness of the geological layer
5556
model_solutions: gp.data.Solutions = geo_model.solutions
56-
thickness = _likelihood(model_solutions)
57+
thickness = apparent_thickness_likelihood(model_solutions)
5758

5859
# endregion
5960

@@ -67,14 +68,3 @@ def model(geo_model: gempy.core.data.GeoModel, normal, y_obs_list):
6768
)
6869

6970

70-
def _likelihood(model_solutions: gp.data.Solutions) -> torch.Tensor:
71-
"""
72-
This function computes the thickness of the geological layer.
73-
"""
74-
simulated_well = model_solutions.octrees_output[0].last_output_center.custom_grid_values
75-
thickness = simulated_well.sum()
76-
pyro.deterministic(
77-
name=r'$\mu_{thickness}$',
78-
value=thickness.detach() # * This is only for az to track progress
79-
)
80-
return thickness

0 commit comments

Comments
 (0)