In [19]:
import importlib
import theano.tensor as T
import sys, os
sys.path.append("/home/bl3/PycharmProjects/GeMpy/GeMpy")
sys.path.append("/home/bl3/PycharmProjects/GeMpy/pygeomod/pygeomod")
import GeoMig
#import geogrid
#importlib.reload(GeoMig)
importlib.reload(GeoMig)


import numpy as np
%matplotlib inline
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
np.set_printoptions(precision = 4, linewidth= 300, suppress =  True)
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm


test = GeoMig.Interpolator(c_o =None, range_var = 17, nugget_effect= 0.01, u_grade = 0, rescaling_factor=7.5
                          )
test.set_extent(0,10,0,10,0,10)
test.set_resolutions(40,10,40)
test.create_regular_grid_3D()
test.theano_compilation_3D();
#test.theano_set_3D_nugget_degree0()


/home/bl3/anaconda3/lib/python3.5/site-packages/ipykernel/__main__.py:26: DeprecationWarning: stack(*tensors) interface is deprecated, use stack(tensors, axis=0) instead.

In [20]:
test.a.get_value(), test.c_o.get_value()


Out[20]:
(array(17), array(6.8809523809523805))

In [29]:
layer_1 = np.array([[0.5,4,7], [2,4,6], [4,4,7], [5,4,5], [8,4,7], [7,4,8], [1,5,7]], dtype = "float64")#-np.array([5,5,4]))/8+0.5
layer_2 = np.array([[3,5,5]])#, [6,5,4]])
layer_3 = np.array([[1,5,1],[1,5,2],[6,5,3]], dtype = "float64")#- np.array([5,5,4]))/8+0.5

dip_pos_1 = np.array([5,5,7], dtype = "float64")#- np.array([5,5,4]))/8+0.5
dip_pos_2 = np.array([7.,5,2], dtype = "float64")
dip_pos_3 = np.array([8,4,5], dtype = "float64")
dip_angle_1 = float(15)
dip_angle_2 = float(230)


layers = np.asarray([layer_1,layer_2])#,np.array([[2,5,11],[3,1,2],[6,2,1]])])
test.layers = np.asarray([layer_1,layer_2])
dips = np.asarray([dip_pos_1, dip_pos_2])#, dip_pos_3])
dips_angles = np.asarray([dip_angle_1, dip_angle_2], dtype="float64")
azimuths = np.asarray([90,90], dtype="float64")
polarity = np.asarray([1,1], dtype="float64")
#print (dips_angles)
rest = np.vstack((i[1:] for i in layers))
ref = np.vstack((np.tile(i[0],(np.shape(i)[0]-1,1)) for i in layers))
dips_angles.dtype
rest = rest.astype("float64")
ref = ref.astype("float64")

test.azimuths = azimuths
test.dips_angles = dips_angles
test.polarity = polarity
test.dips_position = dips.astype("float64")
dips_angles = dips_angles.astype("float64")
type(dips_angles)
#test.G_x,test.G_y,test.G_z = test.interpolate(test.dips,dips_angles,
#                                              azimuths,polarity, rest, ref)[-3:]

rest, ref;

In [50]:
h = []
h.append((layer_1, layer_2))
h


Out[50]:
[(array([[ 0.5,  4. ,  7. ],
         [ 2. ,  4. ,  6. ],
         [ 4. ,  4. ,  7. ],
         [ 5. ,  4. ,  5. ],
         [ 8. ,  4. ,  7. ],
         [ 7. ,  4. ,  8. ],
         [ 1. ,  5. ,  7. ]]), array([[3, 5, 5]]))]

In [43]:
np.empty?

In [31]:
par2 = 1/(7.5**2)
w = 1/7.5
test.potential_field = test.interpolate(dips,dips_angles,azimuths,polarity, rest, ref)[0].reshape(40,10,40)
test.potential_field = np.swapaxes(test.potential_field,0,1)

test.azimuths = azimuths
test.dips_angles = dips_angles
test.polarity = polarity
test.dips = dips.astype("float64")
test.calculate_gradient()
test.plot_potential_field_2D(direction="y", cell_pos = 4, figsize = (6.2,5), colorbar = True)



In [32]:
test.interpolate(dips,dips_angles,azimuths,polarity, rest, ref)[5], test.c_o.get_value(), 17*17/3/14


Out[32]:
(array([  4.6903,  -4.3154,  -0.7688,   0.9343,  10.7663,  -1.9436,  -3.838 ,  -2.1111, -13.9224, -26.2988,  43.768 ,  -3.0907]),
 array(6.8809523809523805),
 6.8809523809523805)

In [33]:
par2 = 1/(1**2)
w = 1/1
test.potential_field = test.interpolate(dips,dips_angles,azimuths,polarity, rest, ref,
par2, w)[0].reshape(40,10,40)
test.potential_field = np.swapaxes(test.potential_field,0,1)

test.azimuths = azimuths
test.dips_angles = dips_angles
test.polarity = polarity
test.dips = dips.astype("float64")
test.calculate_gradient()
test.plot_potential_field_2D(direction="y", cell_pos = 4, figsize = (6.2,5), colorbar = True)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-d11ce6c52aaf> in <module>()
      2 w = 1/1
      3 test.potential_field = test.interpolate(dips,dips_angles,azimuths,polarity, rest, ref,
----> 4 par2, w)[0].reshape(40,10,40)
      5 test.potential_field = np.swapaxes(test.potential_field,0,1)
      6 

/home/bl3/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)
    852                         'Tried to provide value for implicit input: %s'
    853                         % getattr(self.inv_finder[c], 'variable',
--> 854                                   self.inv_finder[c]))
    855 
    856         # Do the actual work

TypeError: Tried to provide value for implicit input: <TensorType(int64, scalar)>

In [ ]: