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

import GeoMig
#import geogrid
#importlib.reload(GeoMig)
importlib.reload(GeoMig)
import numpy as np

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


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-dd332bc55840> in <module>()
      5 sys.path.append("/home/bl3/PycharmProjects/pygeomod/pygeomod")
      6 
----> 7 import GeoMig
      8 #import geogrid
      9 #importlib.reload(GeoMig)

/home/bl3/PycharmProjects/GeMpy/GeMpy/GeoMig.py in <module>()
     18 
     19 
---> 20 class Interpolator(GeoPlot):
     21     """
     22     Class which contain all needed methods to perform potential field implicit modelling

/home/bl3/PycharmProjects/GeMpy/GeMpy/GeoMig.py in Interpolator()
     86     # TODO: Once we have the data frame extract data to interpolator
     87 
---> 88     def load_data_csv(self, data_type, path=os.getcdw()):
     89         """
     90         Method to load either interface or foliations data csv files. Normally this is in which GeoModeller exports it

AttributeError: module 'os' has no attribute 'getcdw'

In [ ]:
import geogrid
a = geogrid.GeoGrid()
a.xmax = 10
a.xmin = 0
a.ymax = 10
a.ymin = 0
a.zmax = 10
a.zmin = 0
a.define_regular_grid(50,50,50)

In [ ]:


In [ ]:


In [ ]:


In [5]:
test = GeoMig.GeoMigSim_pro2(c_o = np.float32(-0.2),range = np.float32(13))

test.create_regular_grid_3D(0,10,0,10,0,10,50,50,50)
test.theano_set_3D()


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

In [1]:
layer_1 = np.array([[1,5,7],[4,5,7],[6,5,7], [9,5,7]], dtype = "float32")

layer_2 = np.array([[1,5,1],[5,5,1],[9,5,1]], dtype = "float32")

dip_pos_1 = np.array([2,5,5], dtype = "float32")
dip_pos_2 = np.array([8.,5.,5], dtype = "float32")
#dip_pos_3 = np.array([8,4,5], dtype = "float32")
dip_angle_1 = float(0)
dip_angle_2 = float(0)


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="float32")
azimuths = np.asarray([90, 90], dtype="float32")
polarity = np.asarray([1, 1], dtype="float32")
#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("float32")
ref = ref.astype("float32")
dips = dips.astype("float32")
dips_angles = dips_angles.astype("float32")
type(dips_angles)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-9f028bbd0ba0> in <module>()
----> 1 layer_1 = np.array([[1,5,7],[4,5,7],[6,5,7], [9,5,7]], dtype = "float32")
      2 
      3 layer_2 = np.array([[1,5,1],[5,5,1],[9,5,1]], dtype = "float32")
      4 
      5 dip_pos_1 = np.array([2,5,5], dtype = "float32")

NameError: name 'np' is not defined

In [53]:
G_x = np.sin(np.deg2rad(dips_angles)) * np.sin(np.deg2rad(azimuths)) * polarity
G_y = np.sin(np.deg2rad(dips_angles)) * np.cos(np.deg2rad(azimuths)) * polarity
G_z = np.cos(np.deg2rad(dips_angles)) * polarity
G_x[0],G_y[1],G_z[0],G_x[1], G_y[1],G_z[1]


Out[53]:
(0.0, -0.0, 1.0, 0.0, -0.0, 1.0)

In [54]:
test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[7]


Out[54]:
array([[ 0.,  0.,  1.,  1.,  1.,  1.],
       [ 0.,  0.,  1.,  1.,  1.,  1.],
       [ 1.,  1.,  0.,  0.,  1.,  1.],
       [ 1.,  1.,  0.,  0.,  1.,  1.],
       [ 1.,  1.,  1.,  1.,  0.,  0.],
       [ 1.,  1.,  1.,  1.,  0.,  0.]], dtype=float32)

In [55]:
test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[2]


Out[55]:
array([[-0.2       , -0.04439974,  0.        , -0.12408967,  0.        , -0.12408967],
       [-0.04439974, -0.2       , -0.12408967,  0.        , -0.12408967,  0.        ],
       [ 0.        , -0.12408967, -0.2       ,  0.        ,  0.        , -0.12408967],
       [-0.12408967,  0.        ,  0.        , -0.2       , -0.12408967,  0.        ],
       [ 0.        , -0.12408967,  0.        , -0.12408967, -0.2       ,  0.        ],
       [-0.12408967,  0.        , -0.12408967,  0.        ,  0.        , -0.2       ]])

In [ ]:


In [42]:
sol = test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[0].reshape(50,50,50, order = "F")
#sol = np.swapaxes(sol,0,1)

In [43]:
dip_pos_1_v =  [test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[-3][0],
                test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[-1][0],]+ dip_pos_1[0::2]

dip_pos_2_v =  [test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[-3][1],
                test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[-1][1],]+ dip_pos_2[0::2]
print (test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[-1]) 
dip_pos_1_v, dip_pos_2_v, dip_pos_2;


[ 0.70710678  0.70710678]

In [ ]:


In [44]:
h,j,k =sol[5,10,35], sol[25,5,5], sol[30,15,-25]
print(sol[5,25,35], sol[25,25,35],  sol[30,25,35],  sol[45,25,35]) 
print(sol[5,25,5], sol[25,25,5],  sol[45,25,5])


0.733862734467 3.74963487998 4.40451413599 6.48626327603
0.711641729939 3.54708831021 6.61943538563

In [45]:
interfaces_aux = test.geoMigueller(dips,dips_angles,azimuths,polarity,
                rest, ref)[0]


h = sol[10,25,30]# interfaces_aux[np.argmin(abs((test.grid - ref[0]).sum(1)))]
k = sol[30,25,25]# interfaces_aux[np.argmin(abs((test.grid - dips[0]).sum(1)))]
j = sol[45,25,5]#interfaces_aux[np.argmin(abs((test.grid - dips[-1]).sum(1)))]
h,k,j


Out[45]:
(1.5142873563459891, 4.3996999023327437, 6.6194353856317658)

In [46]:
dip_pos_1[1]


Out[46]:
5.0

In [ ]:


In [ ]:


In [50]:
a.grid = sol
a.plot_section('z',cell_pos=27,colorbar = True, alpha = 0.8, cmap = 'coolwarm_r',
                   figsize=(6,6),interpolation= 'nearest' ,ve = 1, geomod_coord= False, contour = False, 
                   )



In [56]:
vertices


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-56-6a2207daec15> in <module>()
----> 1 vertices

NameError: name 'vertices' is not defined

In [131]:
import plotly.plotly as py
from plotly.graph_objs import *
from plotly.tools import FigureFactory as FF
import plotly.graph_objs as go
import plotly.plotly as py
py.sign_in('leguiom', 'wphx7fdchi')
import numpy as np
from skimage import measure


# ========
# PLOTING ISOSURFACES

h = sol[35,25,25]

vertices, simplices = measure.marching_cubes(sol, h, spacing = (1,1,1),
gradient_direction = "descent")
x,y,z = zip(*vertices)  
#colormap=['rgb(255,105,180)','rgb(255,255,51)','rgb(0,191,255)']
fig = FF.create_trisurf(x=x,
                        y=y, 
                        z=z, 
                        plot_edges=False,
                     #   colormap=colormap,
                        simplices=simplices,
                        title="Isosurface")
"""
vertices, simplices = measure.marching_cubes(sol,k, spacing = (1,1,1),
gradient_direction = "descent")
x,y,z = zip(*vertices)  
#colormap=['rgb(255,105,180)','rgb(255,255,51)','rgb(0,191,255)']
fig2 = FF.create_trisurf(x=x,
                        y=y, 
                        z=z, 
                        plot_edges=False,
                       # colormap=colormap,
                        simplices=simplices,
                        title="Isosurface",
                        )

vertices, simplices = measure.marching_cubes(sol,j, spacing = (1,1,1),
gradient_direction = "descent")
x,y,z = zip(*vertices)  
#colormap=['rgb(255,105,180)','rgb(255,255,51)','rgb(0,191,255)']
fig3 = FF.create_trisurf(x=x,
                        y=y, 
                        z=z, 
                        plot_edges=False,
                       # colormap=colormap,
                        simplices=simplices,
                        title="Isosurface",
                        )

"""
# ============
# Plotting interface points

import plotly.graph_objs as go

trace1 = go.Scatter3d(
    x=layers[0][:,0]*5,
    y=layers[0][:,1]*5,
    z=layers[0][:,2]*5,
    mode='markers',
    marker=dict(
        size=12,
        line=dict(
            color='rgba(217, 217, 217, 0.14)',
            width=0.5
        ),
        opacity=0.8
    )
)

trace12 = go.Scatter3d(
    x=layers[1][:,0]*5,
    y=layers[1][:,1]*5,
    z=layers[1][:,2]*5,
    mode='markers',
    marker=dict(
        size=12,
        line=dict(
            color='rgba(217, 217, 217, 0.14)',
            width=0.5
        ),
        opacity=0.8
    )
)

# ================
# Plotting traces

a = np.vstack((dips[:,0],dips[:,0]+G_x))
b = np.vstack((dips[:,1],dips[:,1]+G_y))
c = np.vstack((dips[:,2],dips[:,2]+G_z))


trace2 = go.Scatter3d(
    x=a[:,0]*5, y=b[:,0]*5, z=c[:,0]*5,
    marker=dict(
        size=4,
        color=z,
        colorscale='Viridis',
    ),
    line=dict(
        color='#1f77b4',
        width=1
    )
)


trace3 = go.Scatter3d(
    x=a[:,1]*5, y=b[:,1]*5, z=c[:,1]*5,
    marker=dict(
        size=4,
        color=z,
        colorscale='Viridis',
    ),
    line=dict(
        color='#1f77b4',
        width=1
    )
)
fig.layout['scene']['zaxis']['range'] = [0,50]

#fig.data.append(fig2.data[0])
#fig.data.append(fig3.data[0])
fig.data.append(trace12)
fig.data.append(trace1)
fig.data.append(trace2)
fig.data.append(trace3)

fig.data[1]['visible'] = False
py.iplot(fig)


Out[131]:

In [29]:
a = np.vstack((dips[:,0],dips[:,0]+G_x))
b = np.vstack((dips[:,1],dips[:,1]+G_y))
c = np.vstack((dips[:,2],dips[:,2]+G_z))
a,b,c


Out[29]:
(array([[ 2.        ,  6.        ],
        [ 2.14454389,  5.54548073]], dtype=float32),
 array([[ 4.        ,  3.        ],
        [ 4.39713144,  2.45832467]], dtype=float32),
 array([[ 6.        ,  5.        ],
        [ 6.9063077 ,  5.70710659]], dtype=float32))

In [128]:
fig.layout["shapes"]


Out[128]:
[]

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [120]:
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

init_notebook_mode(connected=False)