Skip to content

Commit

Permalink
- improved assert of number of orientations
Browse files Browse the repository at this point in the history
  • Loading branch information
Leguark committed Mar 28, 2018
1 parent fa8babb commit c25fb89
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 122 deletions.
34 changes: 18 additions & 16 deletions gempy/theano_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(self, output='geology', optimizer='fast_compile', verbose=[0], dtyp



self.scalar_field_at_interfaces_values = theano.shared(np.cast[dtype](np.zeros(3)), "List with the interface values")
# self.scalar_field_at_interfaces_values = theano.shared(np.cast[dtype](np.zeros(3)), "List with the interface values")

def input_parameters_list(self):
"""
Expand Down Expand Up @@ -957,8 +957,8 @@ def block_series(self):
# TODO this may be expensive because I guess that is a sort algorithm. We just need a +inf and -inf... I guess
#max_pot = 1000
# min_pot = -1000
max_pot = T.max(Z_x) + 1
min_pot = T.min(Z_x) -1
max_pot = T.max(Z_x)
min_pot = T.min(Z_x)

# Value of the potential field at the interfaces of the computed series
self.scalar_field_at_interfaces_values = Z_x[-2*self.len_points: -self.len_points][self.npf_op]
Expand All @@ -968,16 +968,16 @@ def block_series(self):

# A tensor with the values to segment
scalar_field_iter = T.concatenate((
T.stack([max_pot]),
#T.stack([max_pot]),
self.scalar_field_at_interfaces_values,
T.stack([min_pot])
# T.stack([min_pot])
))

if "scalar_field_iter" in self.verbose:
scalar_field_iter = theano.printing.Print("scalar_field_iter")(scalar_field_iter)

# Loop to segment the distinct lithologies
def compare(a, b, n_formation, Zx):
def compare(a, n_formation, Zx):
"""
Treshold of the points to interpolate given 2 potential field values. TODO: This function is the one we
need to change for a sigmoid function
Expand All @@ -993,23 +993,27 @@ def compare(a, b, n_formation, Zx):
"""

if True:
mid_pot = (a - b) / 2 + b
mid_pot = a
# mid_pot = (a - b) / 2 + b
# mid_pot = a

n_formation = theano.printing.Print("n_formation")(n_formation)
# The 5 rules the slope of the function
sigm = ((1. / (1 + T.exp(-500 * (Z_x - b))) + 1. / (1 + T.exp(500 * (Z_x - a)))) - 1) * n_formation
# sigm = ((1. / (1 + T.exp(-100 * (Z_x - b))) + 1. / (1 + T.exp(100 * (Z_x - a)))) - 1) * n_formation

sigm = 1. / (1 + T.exp(-1000 * (Z_x - a)))
if True:
sigm = theano.printing.Print("middle point")(sigm)
return sigm # * n_formation
#return T.switch(T.le(Zx, a) * T.ge(Zx, b), - sigm + n_formation + 1, 0)

else:

return T.le(Zx, a) * T.ge(Zx, b) * n_formation
# else:
#
# return T.le(Zx, a) * T.ge(Zx, b) * n_formation

partial_block, updates2 = theano.scan(
fn=compare,
outputs_info=None,
sequences=[dict(input=scalar_field_iter, taps=[0, 1]), self.n_formation_op_float],
sequences=[dict(input=scalar_field_iter, taps=[0]), self.n_formation_op_float],
non_sequences=Z_x,
name='Looping compare',
profile=False,
Expand Down Expand Up @@ -1154,7 +1158,7 @@ def compute_a_series(self,
# ==================

if 'yet_simulated' in self.verbose:
scalar_field_at_form= theano.printing.Print('scalar_field_at_form')(scalar_field_at_form)
scalar_field_at_form= theano.printing.Print('scalar_field_at_form_out')(scalar_field_at_form)

#if 'yet_simulated' in self.verbose:
# self.yet_simulated = theano.printing.Print('yet_simulated')(self.yet_simulated)
Expand Down Expand Up @@ -1190,8 +1194,6 @@ def compute_a_series(self,
self.len_i_1 = len_i_1

# Printing
if 'yet_simulated' in self.verbose:
self.yet_simulated = theano.printing.Print('yet1')(self.yet_simulated)
if 'n_formation' in self.verbose:
self.n_formation_op = theano.printing.Print('n_formation_series')(self.n_formation_op)

Expand Down
372 changes: 271 additions & 101 deletions notebooks/prototype_notebooks/ch1-gradient.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions notebooks/tutorials/Change grid fast.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@
{
"ename": "NameError",
"evalue": "name 'depth_grid_res' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-13-1305283b3d12>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m x_to_interpolate = np.vstack((depth_grid_res,\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0minterp_data\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minterpolator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpandas_rest_layer_points\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'X'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Y'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Z'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m interp_data.interpolator.pandas_ref_layer_points_rep[['X', 'Y', 'Z']].as_matrix()))\n",
"\u001b[0;31mNameError\u001b[0m: name 'depth_grid_res' is not defined"
]
],
"output_type": "error"
}
],
"source": [
Expand Down Expand Up @@ -292,9 +292,9 @@
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"current_citInitial": 1.0,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"eqNumInitial": 1.0,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
Expand All @@ -318,7 +318,7 @@
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"threshold": 4.0,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false,
Expand Down

0 comments on commit c25fb89

Please sign in to comment.