In [2]:
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
In [3]:
os.getcwd()
Out[3]:
In [4]:
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()
In [5]:
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)
Out[5]:
In [6]:
dips
Out[6]:
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]:
In [54]:
test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[7]
Out[54]:
In [55]:
test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[2]
Out[55]:
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;
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])
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]:
In [46]:
dip_pos_1[1]
Out[46]:
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
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]:
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)