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")
sys.path.append("/home/miguel/PycharmProjects/GeMpy/GeMpy")
import GeoMig
#import geogrid
#importlib.reload(GeoMig)
importlib.reload(GeoMig)
import numpy as np

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib
import matplotlib.cm as cmx
from skimage import measure

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

In [4]:
sandstone = GeoMig.Interpolator(range_var = np.float32(110000)
                               ) # Range used in geomodeller

# Setting the extent and resolution of the grid
sandstone.set_extent(696000,747000,6863000,6950000,-20000, 2000)
sandstone.set_resolutions(40,10,40)
sandstone.create_regular_grid_3D()

sandstone.theano_compilation_3D()


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

In [7]:
np.sqrt((sandstone.xmax-sandstone.xmin)**2+
        (sandstone.ymax-sandstone.ymin)**2+
        (sandstone.zmax-sandstone.zmin)**2)


Out[7]:
103218.21544669333

Defining Input data


In [135]:
import pandas as pn
Foliations = pn.read_csv(os.pardir+"/input_data/a_Foliations.csv")
Interfaces = pn.read_csv(os.pardir+"/input_data/a_Points.csv")
# Foliations[Foliations["formation"] == "EarlyGranite"]
a = Foliations[Foliations["formation"] == Foliations["formation"].unique()[0]]

a = pn.concat([Foliations, Interfaces])
(a.max()[:3] - a.min()[:3]), np.max((a.max()[:3] - a.min()[:3]))


Out[135]:
(X    48265.4
 Y    48561.5
 Z    9013.63
 dtype: object, 48561.5)

In [42]:
Interfaces


Out[42]:
X Y Z formation
0 735484.817806 6.891936e+06 -1819.319309 SimpleMafic2
1 729854.915982 6.891938e+06 -1432.263309 SimpleMafic2
2 724084.267161 6.891939e+06 -4739.830309 SimpleMafic2
3 733521.625000 6.895282e+06 521.555240 SimpleMafic2
4 721933.375000 6.884592e+06 496.669295 SimpleMafic2
5 724251.000000 6.886909e+06 484.550926 SimpleMafic2
6 727316.313000 6.886460e+06 478.254423 SimpleMafic2
7 729858.250000 6.887134e+06 484.259574 SimpleMafic2
8 732699.250000 6.885040e+06 494.526481 SimpleMafic2
9 716849.500000 6.887358e+06 508.981894 SimpleMafic2
10 719017.625000 6.892218e+06 508.179387 SimpleMafic2
11 739179.440691 6.891936e+06 -552.591309 SimpleBIF
12 735564.599804 6.891936e+06 -2652.196309 SimpleBIF
13 730009.009977 6.891938e+06 -2088.409309 SimpleBIF
14 718795.791326 6.891941e+06 -2773.169309 SimpleBIF
15 724143.386160 6.891939e+06 -5569.907309 SimpleBIF
16 723877.188000 6.899768e+06 529.152169 SimpleBIF
17 732998.313000 6.898049e+06 521.619609 SimpleBIF
18 743689.438000 6.891769e+06 512.811278 SimpleBIF
19 712961.813000 6.882722e+06 547.826016 SimpleBIF
20 716284.875000 6.891346e+06 515.586860 SimpleBIF
21 718942.875000 6.897600e+06 538.490136 SimpleBIF
22 722157.625000 6.882947e+06 481.747055 SimpleBIF
23 723952.000000 6.885488e+06 480.122832 SimpleBIF
24 728736.813000 6.885488e+06 477.929009 SimpleBIF
25 738829.813000 6.878087e+06 470.081431 SimpleBIF
26 715522.708428 6.891941e+06 -2810.185309 SimpleMafic
27 722100.017223 6.891940e+06 -5640.110309 SimpleMafic
28 728133.723035 6.891938e+06 -8458.173309 SimpleMafic
29 733022.378883 6.891937e+06 -7358.592309 SimpleMafic
... ... ... ... ...
40 738924.813000 6.900194e+06 551.633725 SimpleMafic
41 729430.813000 6.908718e+06 517.178069 SimpleMafic
42 726929.750000 6.916017e+06 502.161614 SimpleMafic
43 745312.750000 6.878221e+06 452.733051 EarlyGranite
44 741494.625000 6.877536e+06 460.202350 EarlyGranite
45 735914.188000 6.876556e+06 456.482389 EarlyGranite
46 734739.375000 6.874011e+06 446.031913 EarlyGranite
47 733564.563000 6.874598e+06 452.620638 EarlyGranite
48 734837.313000 6.876850e+06 469.895650 EarlyGranite
49 735326.813000 6.881354e+06 492.347775 EarlyGranite
50 733858.313000 6.882724e+06 486.360734 EarlyGranite
51 731508.625000 6.881941e+06 476.162317 EarlyGranite
52 729746.438000 6.879004e+06 468.440123 EarlyGranite
53 727788.375000 6.878514e+06 465.162276 EarlyGranite
54 729354.813000 6.881354e+06 469.466421 EarlyGranite
55 729159.000000 6.884095e+06 480.639992 EarlyGranite
56 726319.875000 6.884389e+06 472.411447 EarlyGranite
57 723284.938000 6.882235e+06 475.413461 EarlyGranite
58 721522.688000 6.879592e+06 471.253042 EarlyGranite
59 720935.313000 6.881941e+06 492.156175 EarlyGranite
60 720445.813000 6.883704e+06 498.308040 EarlyGranite
61 717410.875000 6.883508e+06 507.584619 EarlyGranite
62 714571.688000 6.882039e+06 506.534612 EarlyGranite
63 711243.063000 6.879494e+06 505.437117 EarlyGranite
64 709676.625000 6.881550e+06 515.202397 EarlyGranite
65 710264.063000 6.883900e+06 524.055665 EarlyGranite
66 707914.438000 6.882724e+06 507.245636 EarlyGranite
67 703802.563000 6.877340e+06 483.052807 EarlyGranite
68 699886.500000 6.872934e+06 470.146586 EarlyGranite
69 697047.375000 6.869214e+06 456.299059 EarlyGranite

70 rows × 4 columns

So there is four series, 3 of one single layer and 1 with 2. Therefore we need 4 potential fields, so lets begin.

Early Granite

Points


In [43]:
# We extract the points of the formations and we make a numpy array float 32 out of it
layers = Points[Points["formation"] == "EarlyGranite"].as_matrix()[:,:-1].astype("float32")
layers
# The code for rest and ref has to change a bit according to the number of layer per formation
rest = layers[1:]
ref = np.tile(layers[0],(np.shape(layers)[0]-1,1))
layers


Out[43]:
array([[  745312.75,  6878221.  ,      452.73],
       [  741494.62,  6877535.5 ,      460.2 ],
       [  735914.19,  6876556.5 ,      456.48],
       [  734739.38,  6874011.  ,      446.03],
       [  733564.56,  6874598.5 ,      452.62],
       [  734837.31,  6876850.5 ,      469.9 ],
       [  735326.81,  6881354.  ,      492.35],
       [  733858.31,  6882724.5 ,      486.36],
       [  731508.62,  6881941.  ,      476.16],
       [  729746.44,  6879004.  ,      468.44],
       [  727788.38,  6878514.5 ,      465.16],
       [  729354.81,  6881354.  ,      469.47],
       [  729159.  ,  6884095.  ,      480.64],
       [  726319.88,  6884389.  ,      472.41],
       [  723284.94,  6882235.  ,      475.41],
       [  721522.69,  6879591.5 ,      471.25],
       [  720935.31,  6881941.  ,      492.16],
       [  720445.81,  6883703.5 ,      498.31],
       [  717410.88,  6883507.5 ,      507.58],
       [  714571.69,  6882039.  ,      506.53],
       [  711243.06,  6879493.5 ,      505.44],
       [  709676.62,  6881549.5 ,      515.2 ],
       [  710264.06,  6883899.5 ,      524.06],
       [  707914.44,  6882724.5 ,      507.25],
       [  703802.56,  6877340.  ,      483.05],
       [  699886.5 ,  6872934.5 ,      470.15],
       [  697047.38,  6869214.  ,      456.3 ]], dtype=float32)

In [50]:
Foliations


Out[50]:
X Y Z azimuth dip polarity formation
0 739426.627684 6.891935e+06 75.422691 220.000000 70.000 1 SimpleBIF
1 717311.112372 6.891941e+06 -1497.488309 90.000000 60.000 1 SimpleBIF
2 723415.321182 6.891939e+06 -5298.154309 10.000000 20.000 1 SimpleMafic
3 742907.686575 6.891935e+06 -2786.869309 250.000000 60.000 1 SimpleMafic
4 712584.536312 6.891942e+06 -582.769334 90.014000 60.000 1 SimpleMafic
5 724309.279198 6.905712e+06 -3763.862995 90.000000 50.000 1 SimpleMafic
6 728653.933257 6.905715e+06 -4196.807995 269.962000 9.090 1 SimpleMafic
7 732788.182361 6.905718e+06 -1680.306995 269.962000 60.000 1 SimpleMafic
8 727261.874621 6.877214e+06 -5666.992176 360.000000 20.000 1 SimpleMafic
9 718902.531298 6.900479e+06 -1882.895297 83.123000 20.726 1 SimpleMafic
10 733335.732778 6.903151e+06 -1538.629297 255.407000 51.633 1 SimpleMafic
11 730820.452963 6.902599e+06 -3825.776297 258.709000 21.801 1 SimpleMafic
12 725461.656000 6.915002e+06 510.686328 103.095000 60.000 1 SimpleMafic
13 726102.312000 6.917776e+06 499.040304 0.000000 -60.000 1 SimpleMafic
14 727390.156000 6.913487e+06 517.569243 71.561000 -60.000 1 SimpleMafic
15 743403.687500 6.877878e+06 454.749952 169.802194 80.000 1 EarlyGranite
16 738704.406500 6.877046e+06 458.148740 170.056246 80.000 1 EarlyGranite
17 735326.781500 6.875284e+06 452.966456 114.812185 80.000 1 EarlyGranite
18 734151.969000 6.874305e+06 448.179887 206.518042 80.000 1 EarlyGranite
19 734200.938000 6.875724e+06 461.985804 299.406115 80.000 1 EarlyGranite
20 735082.063000 6.879102e+06 480.551436 276.153239 80.000 1 EarlyGranite
21 734592.563000 6.882039e+06 487.287083 223.053093 80.000 1 EarlyGranite
22 732683.469000 6.882333e+06 481.711952 161.600709 80.000 1 EarlyGranite
23 730627.531500 6.880472e+06 477.402658 120.986348 80.000 1 EarlyGranite
24 728767.406500 6.878759e+06 470.031623 165.980598 80.000 1 EarlyGranite
25 728571.594000 6.879934e+06 472.536776 298.870347 80.000 1 EarlyGranite
26 729256.906500 6.882724e+06 471.722924 265.872737 80.000 1 EarlyGranite
27 727739.437500 6.884242e+06 474.258726 185.941204 80.000 1 EarlyGranite
28 724802.406500 6.883312e+06 473.707869 144.627207 80.000 1 EarlyGranite
29 722403.813000 6.880913e+06 470.707065 123.702047 80.000 1 EarlyGranite
30 721229.000500 6.880766e+06 477.680894 255.876557 80.000 1 EarlyGranite
31 720690.563000 6.882822e+06 489.909423 254.444427 80.000 1 EarlyGranite
32 718928.344000 6.883606e+06 509.462245 176.274084 80.000 1 EarlyGranite
33 715991.281500 6.882773e+06 505.165864 152.654159 80.000 1 EarlyGranite
34 712907.375500 6.880766e+06 512.582136 142.596411 80.000 1 EarlyGranite
35 710459.844000 6.880522e+06 511.839758 232.658556 80.000 1 EarlyGranite
36 709970.344000 6.882724e+06 532.967915 283.997896 80.000 1 EarlyGranite
37 709089.250500 6.883312e+06 519.457428 153.495937 80.000 1 EarlyGranite
38 705858.500500 6.880032e+06 494.307044 127.403250 80.000 1 EarlyGranite
39 701844.531500 6.875137e+06 476.658525 131.656118 80.000 1 EarlyGranite
40 698466.937500 6.871074e+06 463.972201 127.377257 80.000 1 EarlyGranite

Foliations


In [64]:
dips = Foliations[Foliations["formation"] == "EarlyGranite"].as_matrix()[:,:3].astype("float32")
dips_angles = Foliations[Foliations["formation"] == "EarlyGranite"]["dip"].as_matrix().astype("float32")
azimuths = Foliations[Foliations["formation"] == "EarlyGranite"]["azimuth"].as_matrix().astype("float32")
polarity = Foliations[Foliations["formation"] == "EarlyGranite"]["polarity"].as_matrix().astype("float32")
Foliations[Foliations["formation"] == ("EarlyGranite|SimpleMafic")].as_matrix()


Out[64]:
array([], shape=(0, 7), dtype=object)

In [110]:
series_name = {"EarlyGranite_Series":("EarlyGranite","Blabla")}
assert type(series_name) is dict, "cool"
assert sum(len(i) for i in series_name.values()) is 2, "bad"

In [116]:
"|".join(series_name["EarlyGranite_Series"])


Out[116]:
'EarlyGranite|Blabla'

In [105]:
"SimpleBIF|EarlyGranite"


Out[105]:
'SimpleBIF|EarlyGranite'

In [120]:
df = Foliations
df[df['formation'].str.contains("SimpleBIF|EarlyGranite")]
df['formation'].str.contains("SimpleBIF|EarlyGranite").unique()


Out[120]:
array([True, False], dtype=object)

Checking Gradients


In [98]:
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, G_y, G_z;

Choosing important isovalues to plot


In [88]:
b = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,0.1,-0.33333,-3*(-0.3333),0.8557,8.557,1)[0]
arg1,h1 = np.argmin((abs(interpolator.grid - ref[0])).sum(1)), b[np.argmin((abs(interpolator.grid - ref[0])).sum(1))]
arg2, h2 =np.argmin((abs(interpolator.grid - ref[1])).sum(1)), b[np.argmin((abs(interpolator.grid - ref[1])).sum(1))]

Plotting potential field


In [89]:
"""
xmin = layers[:,0].min()
xmax = layers[:,0].max()
ymin = layers[:,1].min()
ymax = layers[:,1].max()
zmin = layers[:,2].min()
zmax = layers[:,2].max()
"""
nx = 50
ny = 50
nz = 50
dx = (xmax-xmin)/nx
dy = (ymax-ymin)/ny
dz = (zmax-zmin)/nz

#Genereting a regular grid
interpolator.create_regular_grid_3D(xmin,xmax,ymin,ymax,zmin,zmax,nx,ny,nz)
interpolator.theano_set_3D_nugget_degree0()

val = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,0.1,-0.33333,-3*(-0.3333),0.8557,8.557,1)[0]

G_x, G_y, G_z = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,0.1,-0.33333,-3*(-0.3333),0.8557,8.557,1)[-3:]

sol_early_granite = val.reshape(50,50,50,
    order = "C")


arg1,h1 = np.argmin((abs(interpolator.grid - ref[0])).sum(1)), val[np.argmin((abs(interpolator.grid - ref[0])).sum(1))]
arg2, h2 =np.argmin((abs(interpolator.grid - ref[1])).sum(1)), val[np.argmin((abs(interpolator.grid - ref[1])).sum(1))]

In [46]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

cm = plt.get_cmap("jet")
cNorm = matplotlib.colors.Normalize(vmin=sol_early_granite.min(), vmax=sol_early_granite.max())
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)

isolines = np.linspace(h1,sol_early_granite.min()+(sol_early_granite.max()-sol_early_granite.min())*0.01,1)
print(isolines)

for i in isolines[0:10]:
    vertices = measure.marching_cubes(sol_early_granite, i, spacing = (dx,dy,dz),
    gradient_direction = "descent")[0]

    ax.scatter(vertices[::10,0]+xmin,vertices[::10,1]+ymin,zmin+vertices[::10,2],color=scalarMap.to_rgba(i),alpha = 0.2)
    #color=scalarMap.to_rgba(vertices[::10,2])
    
ax.scatter(layers[:,0],layers[:,1],layers[:,2], s = 50, c = "r" )
ax.scatter(ref[0,0],ref[0,1],ref[0,2], s = 100, c = "g")


ax.quiver3D(dips[:,0],dips[:,1],dips[:,2], G_x,G_y,G_z, pivot = "tail",  length = 40,
            arrow_length_ratio = 0.01 )
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.ticklabel_format(style='sci',  scilimits=(0,0))


[-19.06]

In [90]:
val[1]


Out[90]:
-0.0010114675

In [99]:
c_sol = np.array(
           [-0.0672002794173474499173082108427479397,
           4.47894052448361357221529033267870545387,
           32.7214861975830686446897743735462427139,
           -15.099054128442860545078474387992173433,
           -35.570184227211939287371933460235595703,
           -23.597843507073847035826474893838167190,
           -9.1367069719955349427209512214176356792,
           4.81630221861661045323899088543839752674,
           24.1023567655768538031679781852290034294,
           14.7752332477670034194261461379937827587,
           -38.436698200821716397967975353822112083,
           -28.905171663223260480890530743636190891,
           -1.7122911401057445690554459361010231077,
           9.55799062954935685354485030984506011009,
           36.4091553829197351888069533742964267730,
           -33.354975131192752257902611745521426200,
           -25.801132784690611998712483909912407398,
           -0.1197362474730433445913035939156543463,
           7.08067481512648022601297270739451050758,
           9.69679697095352999269834981532767415046,
           -21.877845350465118912097750580869615077,
           -35.105888270549193919123354135081171989,
           21.2502460242014201696747477399185299873,
           9.82027576377756972192401008214801549911,
           2.07133868598002734984220296610146760940,
           1.30424286272239964290520219947211444377,
           -1.8828536134931623813315582083305343985,
           -15.775675207285329904038917447905987501,
           -21.336313523266436931180578540079295635,
           -28.427134067245340531826514052227139472,
           15.0210994227116518828779589966870844364,
           1.32815973934092612651625131547916680574,
           -9.2895525062595538656751159578561782836,
           -20.264065055578527108082198537886142730,
           -21.763582635243821528092666994780302047,
           -43.355299704163869023432198446244001388,
           16.2989847048205618307292752433568239212,
           -4.4946721317183548904949930147267878055,
           -15.817089609635042180002528766635805368,
           -15.765853757006459190392888558562844991,
           -27.297752956749189223728535580448806285,
           -6.7064720245132667386656066810246556997,
           -7.0304665651463196240911202039569616317,
           -17.817243710581472271314851241186261177,
           -13.029291273947210427763820916879922151,
           -22.536084666631584383367226109839975833,
           -18.233255694548414993505502934567630290,
           7.80734573679180154925916212960146367549,
           -40.204061576787147203049244126304984092,
           -8.3847706346175101543849450536072254180,
           -1.0361008900613859484707290903315879404,
           -1.2482482257017757376615918474271893501,
           0.29967542823352022463012644948321394622,
           0.05352316474983948024757296479947399348,
           0.03556908685958661692216864480542426463,
           0.09169942120311701250212621516766375862,
           -0.2939963147728482106835201648209476843,
           -0.0893806584383176616626087707118131220,
           0.04834027985525080756135096748948853928,
           -0.0607725134815840367652484133031975943,
           -0.1120108487523314849676481230744684580,
           -0.0594942684137691607526576831332931760,
           -0.0674597421954390569220905149450118187,
           -0.0250704422226563083953010391269344836,
           0.03042081585143702887608085916326672304,
           0.00750322929848960731152862635440214944,
           0.02354094701283681798087421555010223528,
           -0.2011706776817408781621310254195122979,
           -0.2215903621346705931749454521195730194,
           0.12022485101380796235215342449009767733,
           0.01920049472747586277732168014154012780,
           -0.0331575839206144085125060883001424372,
           -0.0734614301462658547681172649390646256,
           0.04975284539966429164792316441889852285,
           -0.1481455425060009822857409744756296277,
           -0.0550581186556105758866941357609903207,
           0.03515883845201003138347672916097508277,
           0.27185731576003852039136177154432516545,
           -96.726595831147122339643829036504030227,
           908.478903399191722201067022979259490966,
           -763.10020175088720861822366714477539062,
           -196.48550866070672782370820641517639160,
           -27.602873878443197952492482727393507957,
           -81.235904022154358017360209487378597259,
           707.459640987386478627740871161222457885,
           -442.66541640357462483734707348048686981,
           -231.53821638419398709629604127258062362,
           -643.65061207514315810840344056487083435,
           234.722439055014092446072027087211608886,
           707.076346739397308738261926919221878051,
           -170.05407504704984944510215427726507186,
           446.355938756530917999043595045804977416,
           -802.94228665506841480237198993563652038,
           -374.90165841315047146053984761238098144,
           1120.47665956918308438616804778575897216,
           -467.94990174027645934984320774674415588,
           325.925390909614804968441603705286979675,
           -601.36014778938852032297290861606597900,
           -939.50747080699079560872633010149002075,
           1363.67222528979527851333841681480407714,
           2.04947601616707331118050205986946821212,
           -41.055459973937189488424337469041347503,
           36.7466477144488479211759113240987062454,
           -11.348044426398136153011364513076841831
    ]
)

In [112]:
import pymc as pm
a = pm.Uniform('a', lower=-10000.1, upper=10000.1, )
b = pm.Uniform('b', lower=-10000.1, upper=10000.1, )
c = pm.Uniform('c', lower=-10000.1, upper=10000.1, )
d = pm.Uniform('d', lower=-10000.1, upper=10000.1, )
e = pm.Uniform('e', lower=-1.1, upper=1.1, )
f = pm.Uniform('f', lower=-1.1, upper=1.1, )

@pm.deterministic
def this(value = 0, a = a ,b = b,c = c,d = d,e= e,f =f, c_sol = c_sol):
    sol = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                                 a,b,-3*b,d,e,f)[1]

    
    #error = abs(sol-c_sol)
    #print (error)
    return sol
  
like= pm.Normal("likelihood", this, 1./np.square(1e-30),
                value = c_sol, observed = True, size = len(c_sol)
)
model = pm.Model([a,b,c,d,e,f, like])

In [113]:
M = pm.MAP(model)
M.fit()

In [114]:
a.value, b.value, c.value,d.value, e.value, f.value, this.value, c_sol, interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,1,1,1,1,1,1)[1]


Out[114]:
(array(4556.87857596751),
 array(21.665116108523762),
 array(-6104.283354739862),
 array(9999.684773969651),
 array(-0.05333732686571408),
 array(-0.19436194546932145),
 array([ 0.,  0.,  0., -0., -0., -0., -0.,  0.,  0.,  0., -0., -0., -0.,  0.,  0., -0., -0.,  0.,  0.,  0., -0., -0.,  0.,  0.,
         0.,  0., -0., -0., -0., -0.,  0.,  0., -0., -0., -0., -0.,  0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0.,  0.,
        -0., -0., -0., -0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
         0.,  0.,  0.,  0.,  0.,  0., -0.,  0., -0.,  0., -0.,  0.,  0., -0.,  0., -0., -0.,  0., -0.,  0., -0., -0.,  0., -0.,
         0., -0., -0.,  0.,  0.,  0.,  0., -0.], dtype=float32),
 array([   -0.07,     4.48,    32.72,   -15.1 ,   -35.57,   -23.6 ,    -9.14,     4.82,    24.1 ,    14.78,   -38.44,   -28.91,
           -1.71,     9.56,    36.41,   -33.35,   -25.8 ,    -0.12,     7.08,     9.7 ,   -21.88,   -35.11,    21.25,     9.82,
            2.07,     1.3 ,    -1.88,   -15.78,   -21.34,   -28.43,    15.02,     1.33,    -9.29,   -20.26,   -21.76,   -43.36,
           16.3 ,    -4.49,   -15.82,   -15.77,   -27.3 ,    -6.71,    -7.03,   -17.82,   -13.03,   -22.54,   -18.23,     7.81,
          -40.2 ,    -8.38,    -1.04,    -1.25,     0.3 ,     0.05,     0.04,     0.09,    -0.29,    -0.09,     0.05,    -0.06,
           -0.11,    -0.06,    -0.07,    -0.03,     0.03,     0.01,     0.02,    -0.2 ,    -0.22,     0.12,     0.02,    -0.03,
           -0.07,     0.05,    -0.15,    -0.06,     0.04,     0.27,   -96.73,   908.48,  -763.1 ,  -196.49,   -27.6 ,   -81.24,
          707.46,  -442.67,  -231.54,  -643.65,   234.72,   707.08,  -170.05,   446.36,  -802.94,  -374.9 ,  1120.48,  -467.95,
          325.93,  -601.36,  -939.51,  1363.67,     2.05,   -41.06,    36.75,   -11.35]),
 array([-0.17, -0.17, -0.89,  0.44,  0.86,  0.98,  0.67, -0.31, -0.84, -0.24,  0.86,  0.98,  0.1 , -0.57, -0.82,  0.96,  0.95,
        -0.06, -0.45, -0.6 ,  0.78,  0.96, -0.44, -0.78, -0.74, -0.78,  0.97,  0.97,  0.41,  0.88, -0.48, -0.11,  0.72,  0.93,
         0.51,  0.96, -0.48,  0.07,  0.98,  0.8 ,  0.55,  0.24,  0.26,  0.98,  0.87,  0.78,  0.6 , -0.24,  0.88,  0.6 ,  0.65,
         0.6 , -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17,
        -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17, -0.17,  0.  , -0.  ,  0.  , -0.  ,  0.  , -0.  , -0.  ,
         0.  , -0.  ,  0.  ,  0.  , -0.  ,  0.  , -0.  ,  0.  ,  0.  , -0.  ,  0.  , -0.  ,  0.  ,  0.  , -0.  , -0.  , -0.  ,
        -0.  ,  0.  ], dtype=float32))

In [ ]:

Simple Mafic2 and SimpleBif

Points and foliations


In [7]:
# We extract the points of the formations and we make a numpy array float 32 out of it
layer_1 = Points[Points["formation"] == "SimpleMafic2"].as_matrix()[:,:-1].astype("float32")
layer_2 = Points[Points["formation"] == "SimpleBIF"].as_matrix()[:,:-1].astype("float32")
layers = np.asarray([layer_1,layer_2])

# The code for rest and ref has to change a bit according to the number of layer per formation
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 = np.asarray(
    [Foliations[Foliations["formation"] == "SimpleMafic2"].as_matrix()[:,:3].astype("float32"),
     Foliations[Foliations["formation"] == "SimpleBIF"].as_matrix()[:,:3].astype("float32")]
                )
dips_angles = np.asarray(
    [Foliations[Foliations["formation"] == "EarlyGranite"]["dip"].as_matrix().astype("float32"),
     Foliations[Foliations["formation"] == "EarlyGranite"]["dip"].as_matrix().astype("float32")]
                        )
azimuths =  np.asarray(
    [Foliations[Foliations["formation"] == "SimpleMafic2"]["azimuth"].as_matrix().astype("float32"),
     Foliations[Foliations["formation"] == "SimpleBIF"]["dip"].as_matrix().astype("float32")]
                        )

polarity =  np.asarray(
    [Foliations[Foliations["formation"] == "SimpleMafic2"]["polarity"].as_matrix().astype("float32"),
     Foliations[Foliations["formation"] == "SimpleBIF"]["polarity"].as_matrix().astype("float32")]
                        )
"""
dips = np.asarray(
     Foliations[Foliations["formation"] == "SimpleBIF"].as_matrix()[:,:3].astype("float32")
                )
dips_angles = np.asarray(
     Foliations[Foliations["formation"] == "SimpleBIF"]["dip"].as_matrix().astype("float32")
                        )
azimuths =  np.asarray(
     Foliations[Foliations["formation"] == "SimpleBIF"]["azimuth"].as_matrix().astype("float32")
                        )

polarity =  np.asarray(
     Foliations[Foliations["formation"] == "SimpleBIF"]["polarity"].as_matrix().astype("float32")
                        )

ref


Out[7]:
array([[  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  735484.81,  6891936.5 ,    -1819.32],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59],
       [  739179.44,  6891935.5 ,     -552.59]], dtype=float32)

Solving and Plotting


In [23]:
xmin = 696000
xmax = 747000
ymin = 6863000
ymax = 6950000
zmin = -20000
zmax = 2000
"""
xmin = layers[0][:,0].min()
xmax = layers[0][:,0].max()
ymin = layers[0][:,1].min()
ymax = layers[0][:,1].max()
zmin = layers[0][:,2].min()
zmax = layers[0][:,2].max()
"""

importlib.reload(GeoMig)
interpolator = GeoMig.GeoMigSim_pro2(c_o = np.float32(1),range = np.sqrt((xmax-xmin)**2+(ymax-ymin)**2+(zmax-zmin)**2))


nx = 50
ny = 50
nz = 50
dx = (xmax-xmin)/nx
dy = (ymax-ymin)/ny
dz = (zmax-zmin)/nz

#Genereting a regular grid
interpolator.create_regular_grid_3D(xmin,xmax,ymin,ymax,zmin,zmax,nx,ny,nz)
interpolator.theano_set_3D_nugget()

In [35]:
val = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                               0.1,-0.33333,1,0.85,1,1)[0]

G_x, G_y, G_z = interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                                         0.1,-0.33333,1,0.85,1,1)[-3:]
print()
sol_early_granite = val.reshape(50,50,50,
    order = "C")


arg1,h1 = np.argmin((abs(interpolator.grid - ref[0])).sum(1)), val[np.argmin((abs(interpolator.grid - ref[0])).sum(1))]
arg2, h2 =np.argmin((abs(interpolator.grid - ref[-1])).sum(1)), val[np.argmin((abs(interpolator.grid - ref[-1])).sum(1))]



fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

cm = plt.get_cmap("jet")
cNorm = matplotlib.colors.Normalize(vmin=sol_early_granite.min(),
                                    vmax=sol_early_granite.max())
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)

isolines = np.linspace(sol_early_granite.min()+(sol_early_granite.max()-sol_early_granite.min())*0.01,
                       sol_early_granite.max()-(sol_early_granite.max()-sol_early_granite.min())*0.01,
                       3)

isolines = np.linspace(h1,
                       h2,
                       2)
print(isolines)

for i in isolines[0:10]:
    vertices = measure.marching_cubes(sol_early_granite, i, spacing = (dx,dy,dz),
    gradient_direction = "descent")[0]

    ax.plot_wireframe(vertices[::10,0]+xmin,vertices[::10,1]+ymin,zmin+vertices[::10,2],color=scalarMap.to_rgba(i),alpha = 0.2)
    #color=scalarMap.to_rgba(vertices[::10,2])
    
ax.scatter(layers[0][:,0],layers[0][:,1],layers[0][:,2], s = 50, c = "r" )
ax.scatter(layers[1][:,0],layers[1][:,1],layers[1][:,2], s = 50, c = "yellow" )
ax.scatter(ref[0,0],ref[0,1],ref[0,2], s = 100, c = "g")


ax.quiver3D(dips[:,0],dips[:,1],dips[:,2], G_x,G_y,G_z, pivot = "tail",  length = 400,
            arrow_length_ratio = 0.01 )
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.ticklabel_format(style='sci',  scilimits=(0,0))


[-1.25 -1.25]

In [34]:
ax.plot_trisurf?

In [82]:
h1,h2, sol_early_granite.min(), sol_early_granite.max()


Out[82]:
(3.0458457, 3.0458486, 3.0453672, 3.0469098)

In [21]:
interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                               0.1,-0.33333,1,0.85,1,1)[2].max()


Out[21]:
8.0420867858341905e-05

In [22]:
interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                               0.1,-0.33333,1,0.85,1,1)[3].max()


Out[22]:
4.4534946520081515e-05

In [25]:
interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                               0.1,-0.33333,1,0.85,1,1)[4].max()


Out[25]:
-1.2528119

In [36]:
interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,
                               0.1,-0.33333,1,0.85,1,1)[1]


Out[36]:
array([-1.81,  2.6 , -2.16, -0.  ,  1.03,  1.5 , -0.  ,  0.  ,  0.  ,  0.01,  0.  ,  0.  , -0.  , -0.  , -0.  , -0.  ,  0.01,
        0.  ,  0.  , -0.  ,  0.  , -0.  , -0.  , -0.  ,  0.  , -0.  , -0.  , -0.01,  0.  ,  0.  , -0.  , -0.  , -0.  ,  0.  ,
        0.  ,  0.  ,  0.  ,  0.  ,  0.  ], dtype=float32)

In [ ]:


In [ ]:


In [14]:
import matplotlib.pyplot as plt
%matplotlib notebook
G_x, G_y, G_z = test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,1,1,1,1,1,1)[-3:]

#sol = test.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref,a,b,-3*b,d,1,-1)[2].reshape(20,20,20)
def plot_this_crap(direction):
    fig = plt.figure()
    ax = fig.add_subplot(111)
 
    if direction == "x":

        plt.arrow(dip_pos_1[1],dip_pos_1[2], dip_pos_1_v[1]-dip_pos_1[1],
                  dip_pos_1_v[2]-dip_pos_1[2], head_width = 0.2)
        plt.arrow(dip_pos_2[1],dip_pos_2[2],dip_pos_2_v[1]-dip_pos_2[1], 
                  dip_pos_2_v[2]-dip_pos_2[2], head_width = 0.2)

        plt.plot(layer_1[:,1],layer_1[:,2], "o")
        plt.plot(layer_2[:,1],layer_2[:,2], "o")

        plt.plot(layer_1[:,1],layer_1[:,2], )
        plt.plot(layer_2[:,1],layer_2[:,2], )
        plt.contour( sol[25,:,:] ,30,extent = (0,10,0,10) )

    if direction == "y":

        plt.quiver(dips[:,0],dips[:,2], G_x,G_z, pivot = "tail")

        plt.plot(layer_1[:,0],layer_1[:,2], "o")
        plt.plot(layer_2[:,0],layer_2[:,2], "o")

        plt.plot(layer_1[:,0],layer_1[:,2], )
        plt.plot(layer_2[:,0],layer_2[:,2], )
        plt.contour( sol[:,10,:].T ,10,extent = (0,10,0,10) )

    if direction == "z":

        plt.arrow(dip_pos_1[0],dip_pos_1[1], dip_pos_1_v[0]-dip_pos_1[0],
                  dip_pos_1_v[1]-dip_pos_1[1], head_width = 0.2)
        plt.arrow(dip_pos_2[0],dip_pos_2[1],dip_pos_2_v[0]-dip_pos_2[0], 
                  dip_pos_2_v[1]-dip_pos_2[1], head_width = 0.2)

        plt.plot(layer_1[:,0],layer_1[:,1], "o")
        plt.plot(layer_2[:,0],layer_2[:,1], "o")

        plt.plot(layer_1[:,0],layer_1[:,1], )
        plt.plot(layer_2[:,0],layer_2[:,1], )
        plt.contour( sol[:,:,25] ,30,extent = (0,10,0,10) )
    
    
    
#plt.colorbar()
#plt.xlim(0,10)
#plt.ylim(0,10)
    plt.colorbar()
    plt.title("GeoBulleter v 0.1")

In [ ]:
plot_this_crap

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

Export vtk


In [14]:
"""Export model to VTK

Export the geology blocks to VTK for visualisation of the entire 3-D model in an
external VTK viewer, e.g. Paraview.

..Note:: Requires pyevtk, available for free on: https://github.com/firedrakeproject/firedrake/tree/master/python/evtk

**Optional keywords**:
    - *vtk_filename* = string : filename of VTK file (default: output_name)
    - *data* = np.array : data array to export to VKT (default: entire block model)
"""
vtk_filename = "noddyFunct2"

extent_x = 10
extent_y = 10
extent_z = 10

delx = 0.2
dely = 0.2
delz = 0.2
from pyevtk.hl import gridToVTK
# Coordinates
x = np.arange(0, extent_x + 0.1*delx, delx, dtype='float64')
y = np.arange(0, extent_y + 0.1*dely, dely, dtype='float64')
z = np.arange(0, extent_z + 0.1*delz, delz, dtype='float64')

# self.block = np.swapaxes(self.block, 0, 2)


gridToVTK(vtk_filename, x, y, z, cellData = {"geology" : sol})


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-8308869b7d0c> in <module>()
     19 dely = 0.2
     20 delz = 0.2
---> 21 from pyevtk.hl import gridToVTK
     22 # Coordinates
     23 x = np.arange(0, extent_x + 0.1*delx, delx, dtype='float64')

ImportError: No module named 'pyevtk'

In [ ]:


In [ ]:


In [ ]:

Performance Analysis

CPU


In [32]:
%%timeit
sol =  interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[0]


10 loops, best of 3: 46.8 ms per loop

In [17]:
interpolator.geoMigueller.profile.summary()


Function profiling
==================
  Message: /home/miguel/PycharmProjects/GeMpy/GeoMig.py:1313
  Time in 44 calls to Function.__call__: 8.266213e-01s
  Time in Function.fn.__call__: 8.231266e-01s (99.577%)
  Time in thunks: 8.101749e-01s (98.010%)
  Total compile time: 2.099230e+00s
    Number of Apply nodes: 205
    Theano Optimizer time: 1.619022e+00s
       Theano validate time: 5.564022e-02s
    Theano Linker time (includes C, CUDA code generation/compiling): 1.830056e-01s
       Import time 4.438877e-02s

Time in all call to theano.grad() 0.000000e+00s
Time since theano import 19.954s
Class
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Class name>
  65.5%    65.5%       0.531s       2.36e-04s     C     2244      51   theano.tensor.elemwise.Elemwise
  10.7%    76.2%       0.087s       1.97e-03s     Py      44       1   theano.tensor.nlinalg.MatrixInverse
   9.5%    85.7%       0.077s       1.74e-04s     C      440      10   theano.tensor.blas.Dot22Scalar
   5.8%    91.5%       0.047s       1.52e-04s     C      308       7   theano.tensor.elemwise.Sum
   4.6%    96.1%       0.037s       9.36e-05s     C      396       9   theano.tensor.basic.Alloc
   2.8%    98.8%       0.023s       8.54e-05s     C      264       6   theano.tensor.basic.Join
   0.4%    99.3%       0.004s       2.05e-06s     C     1716      39   theano.tensor.elemwise.DimShuffle
   0.2%    99.5%       0.002s       2.53e-06s     C      660      15   theano.tensor.subtensor.IncSubtensor
   0.1%    99.6%       0.001s       1.03e-06s     C     1056      24   theano.tensor.basic.Reshape
   0.1%    99.7%       0.001s       2.43e-05s     Py      44       1   theano.tensor.extra_ops.FillDiagonal
   0.1%    99.8%       0.001s       1.14e-06s     C      660      15   theano.tensor.subtensor.Subtensor
   0.1%    99.9%       0.001s       9.05e-07s     C      572      13   theano.tensor.opt.MakeVector
   0.0%    99.9%       0.000s       6.72e-06s     C       44       1   theano.tensor.blas_c.CGemv
   0.0%   100.0%       0.000s       7.24e-07s     C      264       6   theano.compile.ops.Shape_i
   0.0%   100.0%       0.000s       6.23e-07s     C      220       5   theano.tensor.basic.ScalarFromTensor
   0.0%   100.0%       0.000s       2.42e-06s     C       44       1   theano.compile.ops.DeepCopyOp
   0.0%   100.0%       0.000s       8.67e-07s     C       44       1   theano.tensor.basic.AllocEmpty
   ... (remaining 0 Classes account for   0.00%(0.00s) of the runtime)

Ops
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Op name>
  30.4%    30.4%       0.246s       5.59e-03s     C       44        1   Elemwise{Composite{(i0 * i1 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4), i5) * Composite{(sqr(i0) * i0)}((i5 - Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) * ((i6 * sqr(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) + i7 + (i8 * i5 * Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))))}}[(0, 1)]
  27.9%    58.3%       0.226s       5.14e-03s     C       44        1   Elemwise{Composite{(i0 * ((LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3), i4) * ((i5 + (i6 * Composite{(sqr(i0) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i7 * Composite{((sqr(sqr(i0)) * sqr(i0)) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4)))) - ((i8 * sqr((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i9 * Composite{(sqr(sqr(i0)
  10.7%    69.0%       0.087s       1.97e-03s     Py      44        1   MatrixInverse
   9.5%    78.5%       0.077s       1.74e-04s     C      440       10   Dot22Scalar
   5.7%    84.2%       0.046s       3.47e-04s     C      132        3   Sum{axis=[0], acc_dtype=float64}
   5.0%    89.1%       0.040s       6.08e-05s     C      660       15   Elemwise{sub,no_inplace}
   4.6%    93.7%       0.037s       9.36e-05s     C      396        9   Alloc
   2.8%    96.5%       0.023s       8.54e-05s     C      264        6   Join
   0.8%    97.3%       0.006s       4.87e-05s     C      132        3   Elemwise{mul,no_inplace}
   0.4%    97.6%       0.003s       6.91e-05s     C       44        1   Elemwise{Composite{Switch(EQ(i0, i1), i1, ((i2 * i3 * i4 * (((i5 * LT(i0, i6) * Composite{(sqr((i0 - i1)) * (i0 - i1))}(i6, i0) * Composite{((i0 * i1) + i2 + (i3 * i4 * i5))}(i7, sqr(i0), i8, i9, i6, i0)) / (i10 * sqr(i0))) - ((i11 * LT(i0, i6) * (((i12 - (i0 * i13 * i14)) + (Composite{(sqr(i0) * i0)}(i0) * i15 * i16)) - (i9 * Composite{(sqr(sqr(i0)) * i0)}(i0)))) / (i10 * sqr(i0))))) + ((i5 * i17 * LT(i0, i6) * Composite{(sqr((i0 - i1)) 
   0.3%    98.0%       0.003s       6.56e-06s     C      396        9   InplaceDimShuffle{x,0}
   0.2%    98.1%       0.002s       3.44e-05s     C       44        1   Elemwise{Composite{(((i0 * i1 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4), i5) * Composite{(sqr(i0) * i0)}((i5 - Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) * ((i6 * sqr(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) + i7 + (i8 * i5 * Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4)))) / i9) - ((i0 * i10 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i11, i12)
   0.2%    98.3%       0.001s       3.03e-05s     C       44        1   Elemwise{Composite{((((LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2), i3) * ((i4 + (i5 * Composite{(sqr(i0) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3))) + (i6 * Composite{((sqr(sqr(i0)) * sqr(i0)) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3)))) - ((i7 * sqr((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3))) + (i8 * Composite{(sqr(sqr(i0)) * 
   0.2%    98.5%       0.001s       2.91e-05s     C       44        1   Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}
   0.2%    98.6%       0.001s       6.94e-06s     C      176        4   Elemwise{Cast{float64}}
   0.1%    98.8%       0.001s       6.85e-06s     C      176        4   Elemwise{Sqr}[(0, 0)]
   0.1%    98.9%       0.001s       3.65e-06s     C      308        7   IncSubtensor{InplaceSet;int64:int64:, int64:int64:}
   0.1%    99.0%       0.001s       6.21e-06s     C      176        4   Sum{axis=[1], acc_dtype=float64}
   0.1%    99.2%       0.001s       1.03e-06s     C     1056       24   Reshape{2}
   0.1%    99.3%       0.001s       2.43e-05s     Py      44        1   FillDiagonal
   ... (remaining 41 Ops account for   0.70%(0.01s) of the runtime)

Apply
------
<% time> <sum %> <apply time> <time per call> <#call> <id> <Apply name>
  30.4%    30.4%       0.246s       5.59e-03s     44   199   Elemwise{Composite{(i0 * i1 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4), i5) * Composite{(sqr(i0) * i0)}((i5 - Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) * ((i6 * sqr(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) + i7 + (i8 * i5 * Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))))}}[(0, 1)](Subtensor{:int64:}.0, Join.0, Reshape{2}.0, Reshape{2}.0, Dot22Scalar.0, InplaceDimShuffl
  27.9%    58.3%       0.226s       5.14e-03s     44   200   Elemwise{Composite{(i0 * ((LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3), i4) * ((i5 + (i6 * Composite{(sqr(i0) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i7 * Composite{((sqr(sqr(i0)) * sqr(i0)) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4)))) - ((i8 * sqr((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i9 * Composite{(sqr(sqr(i0)) * i0)}((C
  10.7%    69.0%       0.087s       1.97e-03s     44   189   MatrixInverse(IncSubtensor{InplaceSet;int64::, int64:int64:}.0)
   5.8%    74.8%       0.047s       1.07e-03s     44   143   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   4.3%    79.1%       0.035s       7.87e-04s     44   191   Alloc(CGemv{inplace}.0, Shape_i{0}.0, TensorConstant{1}, TensorConstant{1}, Elemwise{add,no_inplace}.0)
   4.0%    83.1%       0.032s       7.35e-04s     44   202   Sum{axis=[0], acc_dtype=float64}(Elemwise{Composite{(i0 * i1 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4), i5) * Composite{(sqr(i0) * i0)}((i5 - Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) * ((i6 * sqr(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) + i7 + (i8 * i5 * Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))))}}[(0, 1)].0)
   2.6%    85.7%       0.021s       4.84e-04s     44   145   Join(TensorConstant{0}, Elemwise{sub,no_inplace}.0, Elemwise{sub,no_inplace}.0, Elemwise{sub,no_inplace}.0)
   1.7%    87.5%       0.014s       3.17e-04s     44    86   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   1.7%    89.1%       0.014s       3.09e-04s     44   130   Elemwise{sub,no_inplace}(InplaceDimShuffle{0,x}.0, InplaceDimShuffle{1,0}.0)
   1.6%    90.8%       0.013s       3.02e-04s     44   129   Elemwise{sub,no_inplace}(InplaceDimShuffle{0,x}.0, InplaceDimShuffle{1,0}.0)
   1.5%    92.3%       0.012s       2.83e-04s     44   131   Elemwise{sub,no_inplace}(InplaceDimShuffle{0,x}.0, InplaceDimShuffle{1,0}.0)
   1.4%    93.7%       0.011s       2.58e-04s     44   203   Sum{axis=[0], acc_dtype=float64}(Elemwise{Composite{(i0 * ((LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3), i4) * ((i5 + (i6 * Composite{(sqr(i0) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i7 * Composite{((sqr(sqr(i0)) * sqr(i0)) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4)))) - ((i8 * sqr((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i1, i2, i3) / i4))) + (i9 * 
   1.4%    95.1%       0.011s       2.58e-04s     44    85   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   0.8%    95.9%       0.006s       1.43e-04s     44   198   Elemwise{mul,no_inplace}(Subtensor{int64::}.0, Positions of the points to interpolate.T)
   0.4%    96.3%       0.003s       6.91e-05s     44   178   Elemwise{Composite{Switch(EQ(i0, i1), i1, ((i2 * i3 * i4 * (((i5 * LT(i0, i6) * Composite{(sqr((i0 - i1)) * (i0 - i1))}(i6, i0) * Composite{((i0 * i1) + i2 + (i3 * i4 * i5))}(i7, sqr(i0), i8, i9, i6, i0)) / (i10 * sqr(i0))) - ((i11 * LT(i0, i6) * (((i12 - (i0 * i13 * i14)) + (Composite{(sqr(i0) * i0)}(i0) * i15 * i16)) - (i9 * Composite{(sqr(sqr(i0)) * i0)}(i0)))) / (i10 * sqr(i0))))) + ((i5 * i17 * LT(i0, i6) * Composite{(sqr((i0 - i1)) * (i0 - i1)
   0.3%    96.6%       0.003s       5.74e-05s     44   140   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   0.3%    96.9%       0.002s       5.49e-05s     44    53   InplaceDimShuffle{x,0}(Subtensor{::, int64}.0)
   0.3%    97.1%       0.002s       4.80e-05s     44   201   Sum{axis=[0], acc_dtype=float64}(Elemwise{mul,no_inplace}.0)
   0.2%    97.3%       0.002s       3.44e-05s     44   175   Elemwise{Composite{(((i0 * i1 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4), i5) * Composite{(sqr(i0) * i0)}((i5 - Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) * ((i6 * sqr(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4))) + i7 + (i8 * i5 * Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i3, i4)))) / i9) - ((i0 * i10 * LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i2, i11, i12), i5) * Com
   0.2%    97.5%       0.001s       3.03e-05s     44   172   Elemwise{Composite{((((LT(Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2), i3) * ((i4 + (i5 * Composite{(sqr(i0) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3))) + (i6 * Composite{((sqr(sqr(i0)) * sqr(i0)) * i0)}((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3)))) - ((i7 * sqr((Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}(i0, i1, i2) / i3))) + (i8 * Composite{(sqr(sqr(i0)) * i0)}((Compo
   ... (remaining 185 Apply instances account for 2.51%(0.02s) of the runtime)

Here are tips to potentially make your code run faster
                 (if you think of new ones, suggest them on the mailing list).
                 Test them first, as they are not guaranteed to always provide a speedup.
We don't know if amdlibm will accelerate this scalar op. deg2rad
We don't know if amdlibm will accelerate this scalar op. deg2rad
  - Try installing amdlibm and set the Theano flag lib.amdlibm=True. This speeds up only some Elemwise operation.

In [ ]:


In [23]:
sys.path.append("/home/bl3/anaconda3/lib/python3.5/site-packages/PyEVTK-1.0.0-py3.5.egg_FILES/pyevtk")
nx = 50
ny = 50
nz = 50

xmin = 1
ymin = 1
zmin = 1
grid =  sol
var_name = "Geology"
#from evtk.hl import gridToVTK
import pyevtk
from pyevtk.hl import gridToVTK

# define coordinates
x = np.zeros(nx + 1)
y = np.zeros(ny + 1)
z = np.zeros(nz + 1)
x[1:] = np.cumsum(delx)
y[1:] = np.cumsum(dely)
z[1:] = np.cumsum(delz)



# plot in coordinates
x += xmin
y += ymin
z += zmin

print (len(x), x)
gridToVTK("GeoMigueller", x, y, z,
          cellData = {var_name: grid})


51 [ 1.   1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2
  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2  1.2]
Out[23]:
'/home/bl3/PycharmProjects/GeMpy/GeoMigueller.vtr'

GPU


In [23]:
interpolator.theano_set_3D()


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

In [26]:
%%timeit
sol =  interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[0].reshape(20,20,20, order = "C")


10 loops, best of 3: 15 ms per loop

In [27]:
interpolator.geoMigueller.profile.summary()


Function profiling
==================
  Message: /home/miguel/PycharmProjects/GeMpy/GeoMig.py:1313
  Time in 42 calls to Function.__call__: 7.134078e-01s
  Time in Function.fn.__call__: 7.101927e-01s (99.549%)
  Time in thunks: 5.815070e-01s (81.511%)
  Total compile time: 2.534589e+00s
    Number of Apply nodes: 290
    Theano Optimizer time: 2.050112e+00s
       Theano validate time: 1.564834e-01s
    Theano Linker time (includes C, CUDA code generation/compiling): 4.177537e-01s
       Import time 0.000000e+00s

Time in all call to theano.grad() 0.000000e+00s
Time since theano import 360.828s
Class
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Class name>
  37.6%    37.6%       0.219s       1.93e-04s     C     1134      27   theano.tensor.elemwise.Elemwise
  16.2%    53.8%       0.094s       3.12e-05s     C     3024      72   theano.sandbox.cuda.basic_ops.GpuElemwise
  13.5%    67.3%       0.079s       1.87e-04s     C      420      10   theano.tensor.blas.Dot22Scalar
   9.5%    76.9%       0.056s       6.01e-05s     C      924      22   theano.sandbox.cuda.basic_ops.GpuFromHost
   6.3%    83.2%       0.037s       8.70e-04s     Py      42       1   theano.tensor.nlinalg.MatrixInverse
   3.9%    87.0%       0.022s       3.57e-05s     C      630      15   theano.sandbox.cuda.basic_ops.GpuIncSubtensor
   3.8%    90.8%       0.022s       7.45e-05s     C      294       7   theano.sandbox.cuda.basic_ops.GpuAlloc
   3.2%    94.0%       0.018s       7.32e-05s     C      252       6   theano.sandbox.cuda.basic_ops.GpuJoin
   2.5%    96.5%       0.015s       3.89e-05s     C      378       9   theano.sandbox.cuda.basic_ops.HostFromGpu
   1.6%    98.1%       0.009s       1.32e-05s     C      714      17   theano.sandbox.cuda.basic_ops.GpuReshape
   0.4%    98.5%       0.002s       1.90e-05s     C      126       3   theano.sandbox.cuda.basic_ops.GpuCAReduce
   0.2%    98.8%       0.001s       9.42e-07s     C     1470      35   theano.sandbox.cuda.basic_ops.GpuDimShuffle
   0.2%    99.0%       0.001s       2.85e-05s     Py      42       1   theano.tensor.extra_ops.FillDiagonal
   0.2%    99.1%       0.001s       6.17e-06s     C      168       4   theano.tensor.elemwise.Sum
   0.2%    99.3%       0.001s       1.60e-06s     C      630      15   theano.sandbox.cuda.basic_ops.GpuSubtensor
   0.1%    99.5%       0.001s       3.29e-06s     C      252       6   theano.tensor.subtensor.IncSubtensor
   0.1%    99.6%       0.001s       1.77e-05s     C       42       1   theano.sandbox.cuda.basic_ops.GpuAllocEmpty
   0.1%    99.7%       0.001s       9.17e-07s     C      546      13   theano.tensor.opt.MakeVector
   0.1%    99.8%       0.000s       5.26e-06s     C       84       2   theano.tensor.basic.Alloc
   0.1%    99.8%       0.000s       2.10e-06s     C      168       4   theano.tensor.elemwise.DimShuffle
   ... (remaining 5 Classes account for   0.19%(0.00s) of the runtime)

Ops
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Op name>
  37.2%    37.2%       0.216s       5.15e-04s     C      420       10   Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}
  13.5%    50.7%       0.079s       1.87e-04s     C      420       10   Dot22Scalar
   9.5%    60.2%       0.056s       6.01e-05s     C      924       22   GpuFromHost
   6.4%    66.6%       0.037s       6.32e-05s     C      588       14   GpuElemwise{sub,no_inplace}
   6.3%    72.9%       0.037s       8.70e-04s     Py      42        1   MatrixInverse
   3.5%    76.4%       0.020s       9.64e-05s     C      210        5   GpuAlloc
   3.2%    79.6%       0.018s       7.32e-05s     C      252        6   GpuJoin
   3.1%    82.7%       0.018s       4.29e-05s     C      420       10   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}
   3.0%    85.7%       0.018s       5.22e-05s     C      336        8   GpuElemwise{Composite{(i0 * (i1 ** i2))},no_inplace}
   2.5%    88.2%       0.015s       3.89e-05s     C      378        9   HostFromGpu
   2.2%    90.3%       0.013s       4.27e-05s     C      294        7   GpuIncSubtensor{InplaceSet;int64:int64:, int64:int64:}
   1.6%    92.0%       0.009s       1.32e-05s     C      714       17   GpuReshape{2}
   1.3%    93.3%       0.007s       8.91e-05s     C       84        2   GpuElemwise{Composite{(i0 * sqr(i1))},no_inplace}
   0.6%    93.8%       0.003s       3.85e-05s     C       84        2   GpuIncSubtensor{InplaceSet;int64::, int64:int64:}
   0.5%    94.4%       0.003s       3.76e-05s     C       84        2   GpuIncSubtensor{InplaceSet;int64:int64:, int64::}
   0.4%    94.8%       0.002s       1.90e-05s     C      126        3   GpuCAReduce{add}{1,0}
   0.4%    95.1%       0.002s       2.45e-05s     C       84        2   GpuIncSubtensor{InplaceSet;int64:int64:, int64}
   0.3%    95.4%       0.002s       1.96e-05s     C       84        2   GpuAlloc{memset_0=True}
   0.2%    95.6%       0.001s       2.86e-05s     C       42        1   GpuIncSubtensor{InplaceSet;:int64:, int64}
   0.2%    95.8%       0.001s       2.85e-05s     Py      42        1   FillDiagonal
   ... (remaining 67 Ops account for   4.19%(0.02s) of the runtime)

Apply
------
<% time> <sum %> <apply time> <time per call> <#call> <id> <Apply name>
  22.8%    22.8%       0.133s       3.16e-03s     42   205   Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}(Reshape{2}.0, Reshape{2}.0, Dot22Scalar.0)
   7.9%    30.7%       0.046s       1.09e-03s     42   162   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   6.9%    37.6%       0.040s       9.60e-04s     42   197   Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}(Reshape{2}.0, Reshape{2}.0, Dot22Scalar.0)
   6.9%    44.5%       0.040s       9.55e-04s     42   198   Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}(Reshape{2}.0, Reshape{2}.0, Dot22Scalar.0)
   6.3%    50.8%       0.037s       8.70e-04s     42   271   MatrixInverse(HostFromGpu.0)
   3.0%    53.8%       0.018s       4.20e-04s     42   115   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   2.9%    56.7%       0.017s       3.97e-04s     42   215   GpuFromHost(Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}.0)
   2.6%    59.3%       0.015s       3.56e-04s     42   207   GpuFromHost(Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}.0)
   2.0%    61.3%       0.012s       2.83e-04s     42   114   Dot22Scalar(Elemwise{Cast{float64}}.0, InplaceDimShuffle{1,0}.0, TensorConstant{2.0})
   1.5%    62.8%       0.009s       2.04e-04s     42   275   GpuAlloc(GpuGemv{inplace}.0, Shape_i{0}.0, TensorConstant{1}, TensorConstant{1}, Elemwise{add,no_inplace}.0)
   1.2%    64.0%       0.007s       1.61e-04s     42   208   GpuFromHost(Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}.0)
   1.1%    65.1%       0.006s       1.53e-04s     42   129   GpuAlloc(GpuElemwise{sub,no_inplace}.0, TensorConstant{1}, TensorConstant{3}, Elemwise{Composite{Switch(EQ(i0, i1), (i0 // (-i0)), i0)}}.0, Shape_i{0}.0)
   1.0%    66.1%       0.006s       1.40e-04s     42   230   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}(GpuFromHost.0, GpuDimShuffle{x,x}.0)
   0.9%    67.0%       0.005s       1.28e-04s     42   105   GpuElemwise{sub,no_inplace}(GpuDimShuffle{x,0}.0, GpuReshape{2}.0)
   0.9%    67.9%       0.005s       1.21e-04s     42   289   HostFromGpu(GpuElemwise{Composite{((((i0 * i1) / i2) + i3) + i4)}}[(0, 1)].0)
   0.9%    68.8%       0.005s       1.20e-04s     42   150   GpuJoin(TensorConstant{0}, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0)
   0.8%    69.6%       0.005s       1.12e-04s     42   144   GpuJoin(TensorConstant{0}, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0)
   0.8%    70.3%       0.004s       1.05e-04s     42   125   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   0.7%    71.1%       0.004s       1.02e-04s     42   202   GpuFromHost(Elemwise{Composite{Cast{float32}(sqrt(((i0 + i1) - i2)))}}.0)
   0.7%    71.8%       0.004s       1.00e-04s     42   138   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   ... (remaining 270 Apply instances account for 28.22%(0.16s) of the runtime)

Here are tips to potentially make your code run faster
                 (if you think of new ones, suggest them on the mailing list).
                 Test them first, as they are not guaranteed to always provide a speedup.
  - Try installing amdlibm and set the Theano flag lib.amdlibm=True. This speeds up only some Elemwise operation.

In [19]:
interpolator.theano_set_3D_legacy()


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

In [21]:
%%timeit
sol =  interpolator.geoMigueller(dips,dips_angles,azimuths,polarity, rest, ref)[0].reshape(20,20,20, order = "C")


100 loops, best of 3: 8.26 ms per loop

In [22]:
interpolator.geoMigueller.profile.summary()


Function profiling
==================
  Message: /home/miguel/PycharmProjects/GeMpy/GeoMig.py:891
  Time in 412 calls to Function.__call__: 3.404917e+00s
  Time in Function.fn.__call__: 3.387632e+00s (99.492%)
  Time in thunks: 2.173600e+00s (63.837%)
  Total compile time: 2.628126e+00s
    Number of Apply nodes: 267
    Theano Optimizer time: 2.358552e+00s
       Theano validate time: 1.787663e-01s
    Theano Linker time (includes C, CUDA code generation/compiling): 2.059927e-01s
       Import time 0.000000e+00s

Time in all call to theano.grad() 0.000000e+00s
Time since theano import 323.117s
Class
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Class name>
  40.6%    40.6%       0.882s       2.58e-05s     C    34196      83   theano.sandbox.cuda.basic_ops.GpuElemwise
  10.1%    50.6%       0.219s       3.54e-05s     C     6180      15   theano.sandbox.cuda.basic_ops.GpuIncSubtensor
   9.1%    59.8%       0.199s       4.83e-05s     C     4120      10   theano.sandbox.cuda.blas.GpuDot22Scalar
   9.1%    68.9%       0.199s       4.82e-04s     Py     412       1   theano.tensor.nlinalg.MatrixInverse
   9.0%    77.9%       0.195s       6.75e-05s     C     2884       7   theano.sandbox.cuda.basic_ops.GpuAlloc
   7.2%    85.1%       0.157s       6.35e-05s     C     2472       6   theano.sandbox.cuda.basic_ops.GpuJoin
   4.0%    89.1%       0.087s       8.83e-06s     C     9888      24   theano.sandbox.cuda.basic_ops.GpuReshape
   3.5%    92.6%       0.077s       2.66e-05s     C     2884       7   theano.sandbox.cuda.basic_ops.HostFromGpu
   3.2%    95.8%       0.069s       1.52e-05s     C     4532      11   theano.sandbox.cuda.basic_ops.GpuFromHost
   2.0%    97.8%       0.044s       1.53e-05s     C     2884       7   theano.sandbox.cuda.basic_ops.GpuCAReduce
   0.4%    98.3%       0.009s       5.83e-07s     C    15656      38   theano.sandbox.cuda.basic_ops.GpuDimShuffle
   0.3%    98.6%       0.008s       1.82e-05s     Py     412       1   theano.tensor.extra_ops.FillDiagonal
   0.3%    98.9%       0.007s       1.09e-06s     C     6180      15   theano.sandbox.cuda.basic_ops.GpuSubtensor
   0.3%    99.2%       0.006s       1.38e-05s     C      412       1   theano.sandbox.cuda.basic_ops.GpuAllocEmpty
   0.2%    99.4%       0.005s       1.96e-06s     C     2472       6   theano.tensor.subtensor.IncSubtensor
   0.2%    99.6%       0.004s       6.79e-07s     C     5356      13   theano.tensor.opt.MakeVector
   0.1%    99.7%       0.003s       3.62e-06s     C      824       2   theano.tensor.basic.Alloc
   0.1%    99.8%       0.002s       5.72e-06s     C      412       1   theano.sandbox.cuda.blas.GpuGemv
   0.1%    99.9%       0.002s       6.37e-07s     C     3296       8   theano.tensor.elemwise.Elemwise
   0.1%   100.0%       0.001s       5.51e-07s     C     2472       6   theano.compile.ops.Shape_i
   ... (remaining 1 Classes account for   0.04%(0.00s) of the runtime)

Ops
---
<% time> <sum %> <apply time> <time per call> <type> <#call> <#apply> <Op name>
  15.9%    15.9%       0.345s       5.97e-05s     C     5768       14   GpuElemwise{sub,no_inplace}
   9.1%    25.0%       0.199s       4.83e-05s     C     4120       10   GpuDot22Scalar
   9.1%    34.1%       0.199s       4.82e-04s     Py     412        1   MatrixInverse
   8.3%    42.5%       0.181s       8.79e-05s     C     2060        5   GpuAlloc
   8.1%    50.6%       0.176s       5.35e-05s     C     3296        8   GpuElemwise{Composite{(i0 * (i1 ** i2))},no_inplace}
   7.2%    57.8%       0.157s       6.35e-05s     C     2472        6   GpuJoin
   6.8%    64.6%       0.147s       3.58e-05s     C     4120       10   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}
   5.7%    70.3%       0.125s       4.33e-05s     C     2884        7   GpuIncSubtensor{InplaceSet;int64:int64:, int64:int64:}
   4.0%    74.3%       0.087s       8.83e-06s     C     9888       24   GpuReshape{2}
   3.5%    77.9%       0.077s       2.66e-05s     C     2884        7   HostFromGpu
   3.3%    81.1%       0.071s       8.60e-05s     C      824        2   GpuElemwise{Composite{(i0 * sqr(i1))},no_inplace}
   3.2%    84.3%       0.069s       1.52e-05s     C     4532       11   GpuFromHost
   1.4%    85.7%       0.031s       3.71e-05s     C      824        2   GpuIncSubtensor{InplaceSet;int64:int64:, int64::}
   1.4%    87.1%       0.030s       3.62e-05s     C      824        2   GpuIncSubtensor{InplaceSet;int64::, int64:int64:}
   1.1%    88.2%       0.025s       1.50e-05s     C     1648        4   GpuCAReduce{pre=sqr,red=add}{0,1}
   1.1%    89.3%       0.023s       5.64e-06s     C     4120       10   GpuElemwise{Composite{sqrt(((i0 + i1) - i2))}}[(0, 2)]
   0.9%    90.2%       0.020s       2.39e-05s     C      824        2   GpuIncSubtensor{InplaceSet;int64:int64:, int64}
   0.9%    91.1%       0.019s       1.56e-05s     C     1236        3   GpuCAReduce{add}{1,0}
   0.6%    91.7%       0.014s       1.64e-05s     C      824        2   GpuAlloc{memset_0=True}
   0.5%    92.2%       0.011s       2.78e-05s     C      412        1   GpuIncSubtensor{InplaceSet;:int64:, int64}
   ... (remaining 62 Ops account for   7.77%(0.17s) of the runtime)

Apply
------
<% time> <sum %> <apply time> <time per call> <#call> <id> <Apply name>
   9.1%     9.1%       0.199s       4.82e-04s    412   248   MatrixInverse(HostFromGpu.0)
   3.8%    12.9%       0.082s       1.99e-04s    412   252   GpuAlloc(GpuGemv{inplace}.0, Shape_i{0}.0, TensorConstant{1}, TensorConstant{1}, Elemwise{add,no_inplace}.0)
   2.3%    15.2%       0.051s       1.23e-04s    412   138   GpuAlloc(GpuElemwise{sub,no_inplace}.0, TensorConstant{1}, TensorConstant{3}, Elemwise{Composite{Switch(EQ(i0, i1), (i0 // (-i0)), i0)}}.0, Shape_i{0}.0)
   2.2%    17.4%       0.048s       1.16e-04s    412   184   GpuElemwise{Composite{(i0 * (i1 ** i2))},no_inplace}(CudaNdarrayConstant{[[ 0.75]]}, GpuElemwise{TrueDiv}[(0, 0)].0, CudaNdarrayConstant{[[ 7.]]})
   2.1%    19.6%       0.046s       1.12e-04s    412   176   GpuJoin(TensorConstant{0}, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0)
   2.1%    21.7%       0.046s       1.11e-04s    412   168   GpuJoin(TensorConstant{0}, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0, GpuElemwise{sub,no_inplace}.0)
   2.0%    23.7%       0.044s       1.08e-04s    412   145   GpuDot22Scalar(GpuReshape{2}.0, GpuDimShuffle{1,0}.0, TensorConstant{2.0})
   1.9%    25.6%       0.042s       1.02e-04s    412   109   GpuElemwise{sub,no_inplace}(GpuDimShuffle{x,0}.0, GpuReshape{2}.0)
   1.9%    27.6%       0.042s       1.01e-04s    412   134   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   1.9%    29.5%       0.041s       1.01e-04s    412    40   GpuDot22Scalar(GpuFromHost.0, GpuDimShuffle{1,0}.0, TensorConstant{2.0})
   1.9%    31.4%       0.041s       9.99e-05s    412    49   GpuDot22Scalar(GpuFromHost.0, GpuDimShuffle{1,0}.0, TensorConstant{2.0})
   1.8%    33.2%       0.040s       9.73e-05s    412   156   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   1.8%    35.0%       0.039s       9.57e-05s    412   151   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   1.8%    36.8%       0.039s       9.48e-05s    412   212   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}(GpuElemwise{Composite{sqrt(((i0 + i1) - i2))}}[(0, 2)].0, GpuDimShuffle{x,x}.0)
   1.8%    38.6%       0.038s       9.30e-05s    412   155   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   1.8%    40.3%       0.038s       9.29e-05s    412   153   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}(GpuElemwise{Composite{sqrt(((i0 + i1) - i2))}}[(0, 2)].0, GpuDimShuffle{x,x}.0)
   1.7%    42.1%       0.038s       9.23e-05s    412   154   GpuElemwise{sub,no_inplace}(GpuDimShuffle{0,x}.0, GpuDimShuffle{1,0}.0)
   1.7%    43.8%       0.038s       9.23e-05s    412   110   GpuElemwise{sub,no_inplace}(GpuDimShuffle{x,0}.0, GpuReshape{2}.0)
   1.7%    45.6%       0.038s       9.20e-05s    412   111   GpuElemwise{sub,no_inplace}(GpuDimShuffle{x,0}.0, GpuReshape{2}.0)
   1.7%    47.3%       0.038s       9.16e-05s    412   152   GpuElemwise{Composite{Cast{float32}(LT(i0, i1))},no_inplace}(GpuElemwise{Composite{sqrt(((i0 + i1) - i2))}}[(0, 2)].0, GpuDimShuffle{x,x}.0)
   ... (remaining 247 Apply instances account for 52.68%(1.14s) of the runtime)

Here are tips to potentially make your code run faster
                 (if you think of new ones, suggest them on the mailing list).
                 Test them first, as they are not guaranteed to always provide a speedup.
  Sorry, no tip for today.

In [1]:
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')


[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 2.271379 seconds
Result is [ 1.23178029  1.61879337  1.52278066 ...,  2.20771813  2.29967761
  1.62323284]
Used the cpu

In [1]:
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')


Using gpu device 0: GeForce GTX 970 (CNMeM is disabled, cuDNN not available)
[GpuElemwise{exp,no_inplace}(<CudaNdarrayType(float32, vector)>), HostFromGpu(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.353415 seconds
Result is [ 1.23178029  1.61879349  1.52278066 ...,  2.20771813  2.29967761
  1.62323296]
Used the gpu

In [18]:
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')


[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 2.291412 seconds
Result is [ 1.23178029  1.61879337  1.52278066 ...,  2.20771813  2.29967761
  1.62323284]
Used the cpu

In [ ]:


In [759]:
np.set_printoptions(precision=2)
test.geoMigueller(dips,dips_angles,rest, ref)[1]


Out[759]:
array([[-0.59,  0.08,  0.  ,  0.07],
       [ 0.08, -0.59,  0.07,  0.  ],
       [ 0.  ,  0.12, -0.59,  0.13],
       [ 0.07,  0.  ,  0.13, -0.59]])

In [751]:
T.fill_diagonal?

In [758]:
import matplotlib.pyplot as plt
% matplotlib inline
dip_pos_1_v = np.array([np.cos(np.deg2rad(dip_angle_1))*1,
                        np.sin(np.deg2rad(dip_angle_1))]) + dip_pos_1

dip_pos_2_v = np.array([np.cos(np.deg2rad(dip_angle_2))*1, 
                        np.sin(np.deg2rad(dip_angle_2))]) + dip_pos_2

plt.arrow(dip_pos_1[0],dip_pos_1[1], dip_pos_1_v[0]-dip_pos_1[0],
          dip_pos_1_v[1]-dip_pos_1[1], head_width = 0.2)
plt.arrow(dip_pos_2[0],dip_pos_2[1],dip_pos_2_v[0]-dip_pos_2[0], 
          dip_pos_2_v[1]-dip_pos_2[1], head_width = 0.2)

plt.plot(layer_1[:,0],layer_1[:,1], "o")
plt.plot(layer_2[:,0],layer_2[:,1], "o")

plt.plot(layer_1[:,0],layer_1[:,1], )
plt.plot(layer_2[:,0],layer_2[:,1], )

plt.contour( sol.reshape(50,50) ,30,extent = (0,10,0,10) )
#plt.colorbar()
#plt.xlim(0,10)
#plt.ylim(0,10)
plt.title("GeoBulleter v 0.1")
print (dip_pos_1_v, dip_pos_2_v, layer_1)


[ 2.5   4.87] [ 6.34  3.94] [[ 1.  7.]
 [ 5.  7.]
 [ 6.  7.]
 [ 9.  8.]]

In [443]:
n = 10
#a = T.horizontal_stack(T.vertical_stack(T.ones(n),T.zeros(n)), T.vertical_stack(T.zeros(n), T.ones(n)))
a = T.zeros(n)

print (a.eval())
#U_G = T.horizontal_stack(([T.ones(n),T.zeros(n)],[T.zeros(n),T.ones(n)]))


[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]

In [6]:
T.stack?ö+aeg

In [ ]:
_squared_euclidean_distances2 = T.sqrt(
            (dips ** 2).sum(1).reshape((dips.shape[0], 1)) + (aux_Y ** 2).sum(1).reshape(
                (1, aux_Y.shape[0])) - 2 * dips.dot(aux_Y.T))

        _squared_euclidean_distances3 = T.sqrt(
            (dips ** 2).sum(1).reshape((dips.shape[0], 1)) + (aux_X ** 2).sum(1).reshape(
                (1, aux_X.shape[0])) - 2 * dips.dot(aux_X.T))

        h3 = T.vertical_stack(
            (dips[:, 0] - aux_Y[:, 0].reshape((aux_Y[:, 0].shape[0], 1))).T,
            (dips[:, 1] - aux_Y[:, 1].reshape((aux_Y[:, 1].shape[0], 1))).T
        )


        h4 = T.vertical_stack(
            (dips[:, 0] - aux_X[:, 0].reshape((aux_X[:, 0].shape[0], 1))).T,
            (dips[:, 1] - aux_X[:, 1].reshape((aux_X[:, 1].shape[0], 1))).T)

        r_3 = T.tile(_squared_euclidean_distances2, (2, 1))  # Careful with the number of dimensions
        r_4 = T.tile(_squared_euclidean_distances3, (2, 1))  # Careful with the number of dimensions

        _ans_d1_3 = (r_3 < self.a) * (
            -7 * (self.a - r_3) ** 3 * r_3 * (8 * self.a ** 2 + 9 * self.a * r_3 + 3 * r_3 ** 2) * 1) 
        / (4 * self.a ** 7)

        _ans_d1_4 = (r_4 < self.a) * (
            -7 * (self.a - r_4) ** 3 * r_4 * (8 * self.a ** 2 + 9 * self.a * r_4 + 3 * r_4 ** 2) * 1) 
        / (4 * self.a ** 7)

        _C_GI = (h3 / r_3 * _ans_d1_3 - h4 / r_4 * _ans_d1_4).T

        self._f_CGI = theano.function([dips, aux_X, aux_Y], _C_GI)

In [67]:
import geomodeller_xml_obj
data = geomodeller_xml_obj.GeomodellerClass()
data.load_geomodeller_file('/home/bl3/PycharmProjects/Temp_SandstoneCopy/Temp_SandstoneCopy.xml')
section_elements = data.get_sections() # This reads geomodeller sections. Each section one object

data.get_formation_point_data(section_elements[0])
points_elements = [data.get_formation_point_data(i) for i in section_elements]
print (points_elements[0][0])
points_coord = data.get_point_coordinates(points_elements[0][0])

importlib.reload(geomodeller_xml_obj)

data = geomodeller_xml_obj.GeomodellerClass()
data.load_geomodeller_file('/home/bl3/PycharmProjects/Temp_SandstoneCopy/Temp_SandstoneCopy.xml')
section_dict = data.create_sections_dict()
contact_points_dict = {}
foliation_dict = {}
for i in range(len(section_dict)):
    print ("\n\n\n", next (iter (section_dict.values())), "\n")
    print ("Elements and their ID \n")
    contact_points = data.get_formation_point_data( next (iter (section_dict.values())))

    try:
        for contact_point in contact_points:
            contact_points_dict[contact_point.get("ObservationID")] = contact_point
            print (contact_point, contact_point.get("ObservationID"))
    except TypeError:
        print ("No contact points in the section")
    #ObsID = contact_points.get("ObservationID")
    foliations = data.get_foliations( next (iter (section_dict.values())))
    try:
        for foliation in foliations:
            # dictionary to access with azimth name
            foliation_dict[foliation.get("ObservationID")+"_a"] = foliation
            # dictionary to access with dip name
            foliation_dict[foliation.get("ObservationID")+"_d"] = foliation
            print (foliation, foliation.get("ObservationID"))

    except TypeError:
        print ("No foliation in the section")
    try:
        coord_interface = data.get_point_coordinates(contact_points)
    except TypeError:
        print ("Element does not have iterable objects")

    print ("\nDictionaries:\n ", contact_points_dict, "\n", foliation_dict)

    print ("\n Contact points", contact_points, "\n", coord_interface, "\n")

    print ("foliations" , foliations,  "\n")
    try:
        for i in range(len(foliations)):
            print ("azimut:",data.get_foliation_azimuth(foliations[i]))
            print ("dip",data.get_foliation_dip(foliations[i]))
            print ("coordinates", data.get_foliation_coordinates(foliations[i]))
    except TypeError:
        print ("No foliation in the section")




 <Element '{http://www.geomodeller.com/geo}Section' at 0x7f9624974f48> 

Elements and their ID 

<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098> SM_Seis_E
<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8> SM_Seis_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368> SM_Seis_Ori_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8> SM_Seis_Ori_E
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688> SM_Seis_Ori_W

Dictionaries:
  {'SM_Seis_E': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, 'SM_Seis_C': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>} 
 {'SM_Seis_Ori_E_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, 'SM_Seis_Ori_W_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_W_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_C_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_C_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_E_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>}

 Contact points [<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>] 
 ['SimpleMafic 36284.297,-3068.116 ', 'SimpleMafic 29815.703,-5708.065 '] 

foliations [<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>] 

azimut: 258.709
dip 21.801
coordinates 34448.43,-3825.776
azimut: 255.407
dip 51.633
coordinates 37026.152,-1538.629
azimut: 83.123
dip 20.726
coordinates 22337.496,-1882.895



 <Element '{http://www.geomodeller.com/geo}Section' at 0x7f9624974f48> 

Elements and their ID 

<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098> SM_Seis_E
<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8> SM_Seis_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368> SM_Seis_Ori_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8> SM_Seis_Ori_E
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688> SM_Seis_Ori_W

Dictionaries:
  {'SM_Seis_E': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, 'SM_Seis_C': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>} 
 {'SM_Seis_Ori_E_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, 'SM_Seis_Ori_W_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_W_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_C_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_C_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_E_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>}

 Contact points [<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>] 
 ['SimpleMafic 36284.297,-3068.116 ', 'SimpleMafic 29815.703,-5708.065 '] 

foliations [<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>] 

azimut: 258.709
dip 21.801
coordinates 34448.43,-3825.776
azimut: 255.407
dip 51.633
coordinates 37026.152,-1538.629
azimut: 83.123
dip 20.726
coordinates 22337.496,-1882.895



 <Element '{http://www.geomodeller.com/geo}Section' at 0x7f9624974f48> 

Elements and their ID 

<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098> SM_Seis_E
<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8> SM_Seis_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368> SM_Seis_Ori_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8> SM_Seis_Ori_E
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688> SM_Seis_Ori_W

Dictionaries:
  {'SM_Seis_E': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, 'SM_Seis_C': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>} 
 {'SM_Seis_Ori_E_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, 'SM_Seis_Ori_W_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_W_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_C_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_C_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_E_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>}

 Contact points [<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>] 
 ['SimpleMafic 36284.297,-3068.116 ', 'SimpleMafic 29815.703,-5708.065 '] 

foliations [<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>] 

azimut: 258.709
dip 21.801
coordinates 34448.43,-3825.776
azimut: 255.407
dip 51.633
coordinates 37026.152,-1538.629
azimut: 83.123
dip 20.726
coordinates 22337.496,-1882.895



 <Element '{http://www.geomodeller.com/geo}Section' at 0x7f9624974f48> 

Elements and their ID 

<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098> SM_Seis_E
<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8> SM_Seis_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368> SM_Seis_Ori_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8> SM_Seis_Ori_E
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688> SM_Seis_Ori_W

Dictionaries:
  {'SM_Seis_E': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, 'SM_Seis_C': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>} 
 {'SM_Seis_Ori_E_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, 'SM_Seis_Ori_W_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_W_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_C_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_C_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_E_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>}

 Contact points [<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>] 
 ['SimpleMafic 36284.297,-3068.116 ', 'SimpleMafic 29815.703,-5708.065 '] 

foliations [<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>] 

azimut: 258.709
dip 21.801
coordinates 34448.43,-3825.776
azimut: 255.407
dip 51.633
coordinates 37026.152,-1538.629
azimut: 83.123
dip 20.726
coordinates 22337.496,-1882.895



 <Element '{http://www.geomodeller.com/geo}Section' at 0x7f9624974f48> 

Elements and their ID 

<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098> SM_Seis_E
<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8> SM_Seis_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368> SM_Seis_Ori_C
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8> SM_Seis_Ori_E
<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688> SM_Seis_Ori_W

Dictionaries:
  {'SM_Seis_E': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, 'SM_Seis_C': <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>} 
 {'SM_Seis_Ori_E_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, 'SM_Seis_Ori_W_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_W_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>, 'SM_Seis_Ori_C_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_C_d': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, 'SM_Seis_Ori_E_a': <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>}

 Contact points [<Element '{http://www.geomodeller.com/geo}Interface' at 0x7f9624970098>, <Element '{http://www.geomodeller.com/geo}Interface' at 0x7f96249701d8>] 
 ['SimpleMafic 36284.297,-3068.116 ', 'SimpleMafic 29815.703,-5708.065 '] 

foliations [<Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970368>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f96249704f8>, <Element '{http://www.geomodeller.com/geo}Foliation' at 0x7f9624970688>] 

azimut: 258.709
dip 21.801
coordinates 34448.43,-3825.776
azimut: 255.407
dip 51.633
coordinates 37026.152,-1538.629
azimut: 83.123
dip 20.726
coordinates 22337.496,-1882.895