In [2]:
# Importing
import theano.tensor as T
import sys, os
sys.path.append("../GeMpy")
sys.path.append("../pygeomod")

import GeMpy_core
import Visualization

import importlib
importlib.reload(GeMpy_core)
importlib.reload(Visualization)
import numpy as np
import pandas as pn
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
np.set_printoptions(precision = 6, linewidth= 130, suppress =  True)

%matplotlib inline
#%matplotlib notebook

In [3]:
carbonates = GeMpy_core.GeMpy()

In [4]:
carbonates.import_data( 3405750.7,3486330.0,5816244.1,5906512.6,-4917.7, -3118.861398, 30,30,30,
                                     path_f = None,
                                     path_i = os.pardir+"/input_data/wells2_1711.csv",  sep = ",")

carbonates.Data.Foliations = pn.DataFrame(np.array([3445063.98, 5863089.02, -3778.800000,90,0,1,1]).reshape(1,7),
                                          columns=['X', 'Y', 'Z', 'dip', 'azimuth', 'polarity', 'formation'])
carbonates.Data.Foliations["formation"] = "Top"
carbonates.Data.Foliations["series"] = "Deafult"
carbonates.Data.calculate_gradient()
carbonates.Data.Interfaces[["Z"]].max()


Out[4]:
Z   -3418.861398
dtype: float64

In [5]:
carbonates.update_data()

In [6]:
# Create a class Grid so far just regular grid
carbonates.create_grid()
carbonates.Grid.grid


Out[6]:
array([[ 3405750.75    ,  5816244.      ,    -4917.700195],
       [ 3405750.75    ,  5816244.      ,    -4855.670898],
       [ 3405750.75    ,  5816244.      ,    -4793.64209 ],
       ..., 
       [ 3486330.      ,  5906512.5     ,    -3242.919189],
       [ 3486330.      ,  5906512.5     ,    -3180.890381],
       [ 3486330.      ,  5906512.5     ,    -3118.861328]], dtype=float32)

Plotting raw data


In [7]:
carbonates.Plot.plot_data(direction="z")


/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/font_manager.py:1288: UserWarning: findfont: Font family ['Times New Roman'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/home/bl3/anaconda3/lib/python3.5/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)

In [8]:
# Learn about API authentication here: https://plot.ly/pandas/getting-started
# Find your api_key here: https://plot.ly/settings/api

import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
df = carbonates.Data.Interfaces
df.head()

data = []
clusters = []
#colors = ['rgb(228,26,28)','rgb(55,126,184)','rgb(77,175,74)']

for i in range(len(df['formation'].unique())):
    name = df['formation'].unique()[i]
  
    x = df[ df['formation'] == name ]['X']
    y = df[ df['formation'] == name ]['Y']
    z = df[ df['formation'] == name ]['Z']
    
    trace = dict(
        name = name,
        x = x, y = y, z = z,
        type = "scatter3d",    
        mode = 'markers',
        marker = dict( size=3,  line=dict(width=0) ) )
    data.append( trace )

layout = dict(
    width=800,
    height=550,
    autosize=False,
    title='MAx dataset',
    scene=dict(
        xaxis=dict(
            gridcolor='rgb(255, 255, 255)',
            zerolinecolor='rgb(255, 255, 255)',
            showbackground=True,
            backgroundcolor='rgb(230, 230,230)'
        ),
        yaxis=dict(
            gridcolor='rgb(255, 255, 255)',
            zerolinecolor='rgb(255, 255, 255)',
            showbackground=True,
            backgroundcolor='rgb(230, 230,230)'
        ),
        zaxis=dict(
            gridcolor='rgb(255, 255, 255)',
            zerolinecolor='rgb(255, 255, 255)',
            showbackground=True,
            backgroundcolor='rgb(230, 230,230)'
        ),
        aspectratio = dict( x=1, y=1, z=0.2 ),
        aspectmode = 'automatic'        
    ),
)

fig = dict(data=data, layout=layout)

# IPython notebook
py.iplot(fig, filename='Max data', validate=False)


Out[8]:

In [9]:
carbonates.set_interpolator(u_grade = 2)

In [15]:
# Reset the block
carbonates.Interpolator.block.set_value(np.zeros_like(carbonates.Grid.grid[:,0]))

# Compute the block
carbonates.Interpolator.compute_block_model([0], verbose = 1)


[1 2 3 4]
[1 1 1 ..., 1 1 1] 0
The serie formations are Top|A2|Ca2|A1

In [16]:
np.unique(carbonates.Interpolator.block.get_value())


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

In [17]:
carbonates.Plot.plot_block_section(direction="x", aspect ="auto" )



In [ ]:
carbonates.Plot.plot_potential_field(50, direction="y")

In [20]:
carbonates.Interpolator.a_T.get_value()


Out[20]:
array(121015.12922381242)

In [9]:
import plotly.tools as tls
tls.set_credentials_file(username='leguiom', api_key='hcdlNUAEuGC0m2rRy1pq')

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [253]:
Max = pn.read_excel('../input_data/gypsumDec4.xlsx')
Max


Out[253]:
Well Name Top Bottom Thickness Formation East North Top.1 Base East [m] Base North [m] ... How much gypsum is needed Unnamed: 19 Unnamed: 20 Unnamed: 21 Unnamed: 22 How Unnamed: 24 Unnamed: 25 Unnamed: 26 Unnamed: 27
0 Ahlhorn_Z1 43.37 43.37 3817.17 Top 3445018.28 5863042.02 43.370000 3445018.28 5863042.02 ... 381.477507 404.350160 470.725222 584.433668 610.333132 381.477507 404.350160 470.725222 584.433668 610.333132
1 Ahlhorn_Z1 3773.80 3778.80 5.00 A2 3445063.98 5863089.02 -3773.800000 45.70 47.00 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 Ahlhorn_Z1 3778.80 3880.70 101.90 Ca2 3445065.38 5863092.52 -3778.800000 47.10 50.50 ... 25694.760815 27235.368949 31706.120972 39365.055702 41109.537425 12769.865712 27157.854254 31628.606276 39287.541006 41032.022729
3 Ahlhorn_Z1 3880.70 3923.60 42.90 A1 3445066.78 5863094.82 -3880.700000 48.50 52.80 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 Brinkholz_Z1 41.63 41.63 3888.53 Top 3458765.30 5867877.40 41.600000 3458765.29 5867877.39 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
5 Brinkholz_Z1 3846.90 3858.40 11.50 A2 3458732.20 5867909.50 -3846.900000 -33.10 32.10 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
6 Brinkholz_Z1 3858.40 3909.70 51.30 Ca2 3458730.60 5867912.60 -3858.400000 -34.70 35.20 ... 6849.428639 7260.107125 8451.871359 10493.506510 10958.531390 6370.585247 6781.263733 7973.027967 10014.663118 10479.687999
7 Brinkholz_Z1 3909.70 4194.10 284.40 A1 3458721.60 5867929.80 -3909.700000 -43.70 52.40 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
8 Bethermoor_Z1 27.09 27.09 3930.79 Top 3435998.60 5866053.70 27.100000 3435998.63 5866053.66 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
9 Bethermoor_Z1 3903.70 3906.20 2.50 A2 3435764.20 5865925.00 -3903.700000 -234.40 -128.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
10 Bethermoor_Z1 3906.20 4006.60 100.40 Ca2 3435753.80 5865926.90 -3906.200000 -244.80 -126.80 ... 36691.727353 38891.692320 45275.858160 56212.700380 58703.793729 36639.295701 38839.260668 45223.426508 56160.268728 58651.362077
11 Bethermoor_Z1 4006.60 4036.50 29.90 A1 3435750.70 5865927.50 -4006.600000 -247.90 -126.20 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
12 Cappeln_Z4a 37.26 37.26 3612.00 Top 3439728.46 5850616.60 37.260000 3439728.46 5850616.60 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
13 Cappeln_Z4a 3574.70 3601.60 26.90 A2 3439587.53 5851025.15 3574.700000 -140.90 408.50 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
14 Cappeln_Z4a 3601.60 3624.50 23.00 Ca2 3439587.83 5851027.44 3601.600000 -140.60 410.80 ... 0.000000 0.000000 0.000000 0.000000 0.000000 -389.029913 -389.029913 -389.029913 -389.029913 -389.029913
15 Cappeln_Z4a 3624.50 3838.00 213.50 A1 3439941.96 5850478.67 3624.500000 213.50 -137.90 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
16 Cappeln_Z1a 42.76 42.76 3493.00 Top 3439653.61 5851873.39 42.760000 3439653.61 5851873.39 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
17 Cappeln_Z1a 3493.00 3525.50 32.50 A2 3439761.62 5851726.42 3493.000000 108.00 -147.00 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
18 Cappeln_Z1a 3525.50 3558.00 32.50 Ca2 3439761.20 5851726.44 3525.500000 107.60 -147.00 ... 0.000000 0.000000 0.000000 0.000000 0.000000 -482.889043 -482.889043 -482.889043 -482.889043 -482.889043
19 Cappeln_Z1a 3558.00 3823.90 265.90 A1 3439747.05 5851734.32 3558.000000 93.40 -139.10 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
20 Doetlingen_Z3 23.25 23.25 3669.80 Top 3455608.56 5865710.51 23.300000 3455608.56 5865710.51 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
21 Doetlingen_Z3 3646.60 3706.00 59.50 A2 3455609.90 5865737.50 -3646.556211 1.30 27.00 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
22 Doetlingen_Z3 3706.00 3932.50 226.50 Ca2 3455611.80 5865740.40 -3706.037242 3.30 29.90 ... 15898.456583 16851.697273 19617.944347 24356.857550 25436.243621 15565.094843 16518.335534 19284.582608 24023.495810 25102.881882
23 Doetlingen_Z3 3932.50 4079.00 146.50 A1 3455610.90 5865742.20 -3932.504022 2.30 31.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
24 Goldenstedt Z9 37.52 37.52 3456.40 Top 3453444.56 5846244.10 37.500000 3453444.56 5846244.10 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
25 Goldenstedt Z9 3418.90 3510.80 92.00 A2 3453342.80 5846334.80 -3418.861398 -101.80 90.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
26 Goldenstedt Z9 3510.80 3541.80 31.00 Ca2 3453342.50 5846335.10 -3510.845394 -102.00 91.00 ... 0.000000 0.000000 0.000000 0.000000 0.000000 -541.793739 -541.793739 -541.793739 -541.793739 -541.793739
27 Goldenstedt Z9 3541.80 3784.70 242.80 A1 3453347.90 5846336.30 -3541.842824 -96.60 92.20 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
28 Hengstlage-Nord_Z2 27.50 27.50 3946.40 Top 3445698.91 5872758.56 27.500000 3445698.91 5872758.56 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
29 Hengstlage-Nord_Z2 3918.90 3922.90 4.00 A2 3445752.80 5872955.60 -3918.946657 53.90 197.10 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
42 Reiherholz_Z1 4482.20 4564.20 82.00 Ca2 3459094.00 5886512.00 -4482.178440 71.10 55.60 ... 30655.532464 32493.578866 37827.478830 46965.089564 49046.370511 30580.606986 32418.653388 37752.553351 46890.164086 48971.445032
43 Reiherholz_Z1 4564.20 4605.10 40.80 A1 3459097.70 5886512.60 -4564.227368 74.80 56.20 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
44 Rechterfeld_Z2 51.00 51.00 3861.60 Top 3458810.00 5854790.00 51.000000 3458810.00 5854790.00 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
45 Rechterfeld_Z2 3810.60 3839.10 28.50 A2 3458868.50 5854936.80 -3810.642689 58.50 146.80 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
46 Rechterfeld_Z2 3839.10 3868.60 29.50 Ca2 3458868.10 5854937.30 -3839.139474 58.10 147.30 ... 438.889872 465.204859 541.569368 672.390935 702.188269 -1.600737 24.714251 101.078759 231.900326 261.697660
47 Rechterfeld_Z2 3868.60 4112.30 243.70 A1 3458863.20 5854947.90 -3868.631469 53.20 157.90 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
48 Sagermeer_Z4 14.87 14.87 3827.00 Top 3444813.63 5874785.13 14.870000 3444813.63 5874785.13 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
49 Sagermeer_Z4 3812.20 3815.20 3.00 A2 3445030.80 5874883.30 -3812.157388 217.20 98.20 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
50 Sagermeer_Z4 3815.20 3937.10 122.00 Ca2 3445029.30 5874883.20 -3815.157175 215.70 98.10 ... 42258.552318 44792.293336 52145.057178 64741.224012 67610.263062 42193.012752 44726.753771 52079.517613 64675.684446 67544.723497
51 Sagermeer_Z4 3937.10 3974.60 37.50 A1 3445028.70 5874882.50 -3937.145737 215.00 97.40 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
52 Sagermeer_Z7 17.00 17.00 3940.80 Top 3444584.94 5873902.88 17.000000 3444584.94 5873902.88 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
53 Sagermeer_Z7 3923.80 3927.80 4.00 A2 3444795.30 5873975.70 -3923.816289 210.40 72.80 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
54 Sagermeer_Z7 3927.80 4035.50 107.70 Ca2 3444795.40 5873984.20 -3927.803958 210.50 81.30 ... 35538.635293 37669.463091 43852.997032 54446.132732 56858.939770 35488.631032 37619.458830 43802.992771 54396.128471 56808.935510
55 Sagermeer_Z7 4035.50 4062.40 26.90 A1 3444795.50 5873986.30 -4035.471030 210.50 83.40 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
56 Sagermeer-Nord_Z1 8.27 8.27 3915.80 Top 3444147.76 5880195.42 8.270000 3444147.76 5880195.42 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
57 Sagermeer-Nord_Z1 3907.50 3910.50 3.00 A2 3444010.80 5880140.00 -3907.538307 -137.00 -55.40 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
58 Sagermeer-Nord_Z1 3910.50 4000.00 89.50 Ca2 3444011.90 5880139.90 -3910.537777 -135.90 -55.50 ... 32230.271613 34162.736327 39770.632546 49377.631746 51565.825681 32166.350309 34098.815023 39706.711241 49313.710442 51501.904376
59 Sagermeer-Nord_Z1 4000.00 4036.50 36.50 A1 3444012.00 5880139.70 -4000.030331 -135.80 -55.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
60 Varnhorn_Z1 47.00 47.00 3729.20 Top 3453720.00 5859690.00 47.000000 3453720.00 5859690.00 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
61 Varnhorn_Z1 3682.20 3720.70 38.50 A2 3453789.20 5859755.70 -3682.221602 69.20 65.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
62 Varnhorn_Z1 3720.70 3920.50 199.80 Ca2 3453781.20 5859758.30 -3720.694691 61.20 68.30 ... 7164.605355 7594.181227 8840.784537 10976.365606 11462.788624 6955.202398 7384.778271 8631.381581 10766.962650 11253.385668
63 Varnhorn_Z1 3920.50 4011.40 90.90 A1 3453778.20 5859760.70 -3920.517349 58.20 70.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
64 Goldenstedt_Z11 37.52 37.52 3507.70 Top 3454322.10 5847423.58 37.520000 3454322.10 5847423.58 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
65 Goldenstedt_Z11 3470.20 3548.10 77.90 A2 3454398.80 5847302.80 -3470.169598 76.70 -120.80 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
66 Goldenstedt_Z11 3548.10 3577.10 29.00 Ca2 3454399.70 5847302.90 -3548.117965 77.60 -120.70 ... 0.000000 0.000000 0.000000 0.000000 0.000000 -538.557217 -538.557217 -538.557217 -538.557217 -538.557217
67 Goldenstedt_Z11 3577.10 3832.00 254.90 A1 3454405.30 5847306.80 -3577.102688 83.20 -116.80 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
68 Goldenstedt_12 48.50 48.50 3613.20 Top 3453590.64 5851020.37 48.500000 3453590.64 5851020.37 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
69 Goldenstedt_12 3564.70 3597.70 33.00 A2 3453656.30 5851121.90 -3564.673415 65.70 101.50 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
70 Goldenstedt_12 3597.70 3623.70 26.00 Ca2 3453656.10 5851122.00 -3597.669634 65.50 101.60 ... 0.000000 0.000000 0.000000 0.000000 0.000000 -328.506957 -328.506957 -328.506957 -328.506957 -328.506957
71 Goldenstedt_12 3623.70 3793.70 170.00 A1 3453654.40 5851122.10 -3623.668783 63.70 101.70 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

72 rows × 28 columns


In [255]:
Max = Max[['Well Name', 'East','North','How']]
Max


Out[255]:
Well Name East North How
0 Ahlhorn_Z1 3445018.28 5863042.02 381.477507
1 Ahlhorn_Z1 3445063.98 5863089.02 NaN
2 Ahlhorn_Z1 3445065.38 5863092.52 12769.865712
3 Ahlhorn_Z1 3445066.78 5863094.82 NaN
4 Brinkholz_Z1 3458765.30 5867877.40 NaN
5 Brinkholz_Z1 3458732.20 5867909.50 NaN
6 Brinkholz_Z1 3458730.60 5867912.60 6370.585247
7 Brinkholz_Z1 3458721.60 5867929.80 NaN
8 Bethermoor_Z1 3435998.60 5866053.70 NaN
9 Bethermoor_Z1 3435764.20 5865925.00 NaN
10 Bethermoor_Z1 3435753.80 5865926.90 36639.295701
11 Bethermoor_Z1 3435750.70 5865927.50 NaN
12 Cappeln_Z4a 3439728.46 5850616.60 NaN
13 Cappeln_Z4a 3439587.53 5851025.15 NaN
14 Cappeln_Z4a 3439587.83 5851027.44 -389.029913
15 Cappeln_Z4a 3439941.96 5850478.67 NaN
16 Cappeln_Z1a 3439653.61 5851873.39 NaN
17 Cappeln_Z1a 3439761.62 5851726.42 NaN
18 Cappeln_Z1a 3439761.20 5851726.44 -482.889043
19 Cappeln_Z1a 3439747.05 5851734.32 NaN
20 Doetlingen_Z3 3455608.56 5865710.51 NaN
21 Doetlingen_Z3 3455609.90 5865737.50 NaN
22 Doetlingen_Z3 3455611.80 5865740.40 15565.094843
23 Doetlingen_Z3 3455610.90 5865742.20 NaN
24 Goldenstedt Z9 3453444.56 5846244.10 NaN
25 Goldenstedt Z9 3453342.80 5846334.80 NaN
26 Goldenstedt Z9 3453342.50 5846335.10 -541.793739
27 Goldenstedt Z9 3453347.90 5846336.30 NaN
28 Hengstlage-Nord_Z2 3445698.91 5872758.56 NaN
29 Hengstlage-Nord_Z2 3445752.80 5872955.60 NaN
... ... ... ... ...
42 Reiherholz_Z1 3459094.00 5886512.00 30580.606986
43 Reiherholz_Z1 3459097.70 5886512.60 NaN
44 Rechterfeld_Z2 3458810.00 5854790.00 NaN
45 Rechterfeld_Z2 3458868.50 5854936.80 NaN
46 Rechterfeld_Z2 3458868.10 5854937.30 -1.600737
47 Rechterfeld_Z2 3458863.20 5854947.90 NaN
48 Sagermeer_Z4 3444813.63 5874785.13 NaN
49 Sagermeer_Z4 3445030.80 5874883.30 NaN
50 Sagermeer_Z4 3445029.30 5874883.20 42193.012752
51 Sagermeer_Z4 3445028.70 5874882.50 NaN
52 Sagermeer_Z7 3444584.94 5873902.88 NaN
53 Sagermeer_Z7 3444795.30 5873975.70 NaN
54 Sagermeer_Z7 3444795.40 5873984.20 35488.631032
55 Sagermeer_Z7 3444795.50 5873986.30 NaN
56 Sagermeer-Nord_Z1 3444147.76 5880195.42 NaN
57 Sagermeer-Nord_Z1 3444010.80 5880140.00 NaN
58 Sagermeer-Nord_Z1 3444011.90 5880139.90 32166.350309
59 Sagermeer-Nord_Z1 3444012.00 5880139.70 NaN
60 Varnhorn_Z1 3453720.00 5859690.00 NaN
61 Varnhorn_Z1 3453789.20 5859755.70 NaN
62 Varnhorn_Z1 3453781.20 5859758.30 6955.202398
63 Varnhorn_Z1 3453778.20 5859760.70 NaN
64 Goldenstedt_Z11 3454322.10 5847423.58 NaN
65 Goldenstedt_Z11 3454398.80 5847302.80 NaN
66 Goldenstedt_Z11 3454399.70 5847302.90 -538.557217
67 Goldenstedt_Z11 3454405.30 5847306.80 NaN
68 Goldenstedt_12 3453590.64 5851020.37 NaN
69 Goldenstedt_12 3453656.30 5851121.90 NaN
70 Goldenstedt_12 3453656.10 5851122.00 -328.506957
71 Goldenstedt_12 3453654.40 5851122.10 NaN

72 rows × 4 columns


In [256]:
Max = Max.dropna()

In [278]:
import scipy
frame = 1000
x = np.linspace(Max['East'].min()- frame, Max['East'].max()+frame, 100) 
y = np.linspace(Max["North"].min()- frame, Max["North"].max()+frame, 100)
xi, yi = np.meshgrid(x, y)

# Interpolate
rbf = scipy.interpolate.Rbf(Max['East'], Max['North'],  Max['How'], function='linear')
zi = rbf(xi, yi)

In [197]:
%matplotlib inline

In [247]:
plt.rcParams['figure.autolayout'] = False
plt.rcParams['figure.figsize'] = 10,8
plt.rcParams['axes.labelsize'] = 18
plt.rcParams['axes.titlesize'] = 20
plt.rcParams['font.size'] = 16
plt.rcParams['lines.linewidth'] = 2.0
plt.rcParams['lines.markersize'] = 8
plt.rcParams['legend.fontsize'] = 14

In [257]:
def annotate_plot(frame, label_col, x, y, **kwargs):
    """
    Annotate the plot of a given DataFrame using one of its columns

    Should be called right after a DataFrame or series plot method,
    before telling matplotlib to show the plot.

    Parameters
    ----------
    frame : pandas.DataFrame

    plot_col : str
        The string identifying the column of frame that was plotted

    label_col : str
        The string identifying the column of frame to be used as label

    kwargs:
        Other key-word args that should be passed to plt.annotate

    Returns
    -------
    None

    Notes
    -----
    After calling this function you should call plt.show() to get the
    results. This function only adds the annotations, it doesn't show
    them.
    """
    import matplotlib.pyplot as plt  # Make sure we have pyplot as plt

    for label, x, y in zip(frame[label_col], frame[x], frame[y]):
        plt.annotate(label, xy=(x+0.2, y+0.15), **kwargs)

In [272]:
plt.axis('off')


Out[272]:
5891512.0

In [289]:
import seaborn as sns
sns.despine()
plt.imshow(zi, extent=[x.min(), x.max(), y.min(), y.max()], 
           cmap = 'viridis', origin='bottom')
plt.colorbar()
plt.contour(xi, yi, zi, 0,  cmap = 'viridis'),  #extent=[x.min()- 5000, x.max()+
                                                #        5000, y.min()- 5000, y.max()+5000])
plt.plot(Max['East'], Max["North"],'o', c='white')
plt.axis('off')
#annotate_plot(Max, 'Well Name','East', 'North', size = 'small', color='white')
#plt.grid()
plt.savefig('Max_NoFrame.pdf')


/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/font_manager.py:1288: UserWarning:

findfont: Font family ['Times New Roman'] not found. Falling back to Bitstream Vera Sans


In [ ]:


In [215]:
plt.imshow(zi, extent=[x.min(), x.max(), y.min(), y.max()], cmap = 'viridis', origin='bottom')
plt.colorbar()


Out[215]:
<matplotlib.colorbar.Colorbar at 0x7fc442b91390>
/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/figure.py:1744: UserWarning:

This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [68]:
# calculation of spherical covariance given just the position of the known points x! You can use verbose = 1 to see the 
# intermediate steps
def cov_spherical(x,r, C_o = 1, verbose = 0):  
    
    """x = Array: Position of the measured points"
    r =  Range of the spherical semivariogram
    C_o = Nugget, variance
    """
    
    # Createing the lag vector
  #  i, j = np.indices((len(x),len(x)))
  #  h = np.zeros((len(x),len(x)))
  #  for l in range(len(x)):
  #      h[i==l] = abs(x[l]-x)
    h = x    
    # Initializing
    C_h = np.ones_like(h)
    
    # Appliying the function
    C_h = (h<r)*( C_o*(1-1.5*(h/r)+0.5*(h/r)**3))
    if verbose !=0:
        print ("Our lag matrix is")
        print (h)
        print( "Our covariance matrix is")
        print (C_h)
            
    return C_h


def Krigin2(x, x_pos = np.array([1.,4.,5.]) , por = np.array([0.14, 0.19, 0.15]), mu = False, r = 4.5, C_o = 0.005,verbose = 0):  
    if mu == False:
        mu = np.mean(por)
    
    #Lag:
    Y = (por-mu)
    
    # Covariance matrix:
    C_h = cov_spherical(x_pos, r, C_o, verbose = verbose)
    a = len(C_h)
    C_h = np.hstack((C_h, np.ones((a, 1))))
    C_h = np.vstack((C_h, np.ones(a+1)))
    C_h[-1,-1] = 0
    # "Interpolation point":
    b = np.zeros(len(x_pos))
    dist = abs(x-x_pos)
    b = (dist<r)*C_o*(1-1.5*(dist/r)+0.5*(dist/r)**3)
    b = np.append(b,1)
    
    # Solving the system
    lam = np.linalg.solve(C_h, b)

    sol = sum(por*lam[:-1])
    plt.plot(x_pos,por,'o', c = "r")

  
    # Calculate the variance
  
    var = C_o - np.sum(lam[:-1]*b[:-1]) + lam[-1]
    if verbose != 0:
        print ("weight", lam)  
        print (lam*b)
        print ("mean solution", sol)
        print ("variance solution", var)
        
    plt.xlim(0,6)
    plt.ylim(0.1,0.3)
    plt.axvline(pos, c = 'r', ls = ':')
    plt.title("Value at the position of the red line?")
    plt.xlabel("x")
    plt.ylabel("Porosity")
   
    return sol, var

def euclidian_distances(points):
    return (np.sqrt((points ** 2).sum(1).reshape((points.shape[0], 1)) +
            (points ** 2).sum(1).reshape((1, points.shape[0])) -
            2 * points.dot(points.T)))

def euclidian_distances2(wells, grid):
     return (np.sqrt(
            (wells ** 2).sum(1).reshape((wells.shape[0], 1)) +
            (grid ** 2).sum(1).reshape((1, grid.shape[0])) -
            2 * wells.dot(grid.T)))

In [130]:
grid_x = np.linspace(x.min(), x.max(),100)
grid_y = np.linspace(y.min(), y.max(),100)

grid = np.vstack((grid_x,grid_y))
grid.T;

ED = euclidian_distances(Max[['East', 'North']])
ED = np.nan_to_num(ED.values)
A = cov_spherical(ED, r = 50000)
A = np.vstack((A, np.ones_like(A[0])))
A = np.hstack((A, np.ones(len(A)).reshape(len(A),1)))

b = cov_spherical(euclidian_distances2(Max[['East', 'North']], grid.T).values, r = 50000)
b = np.vstack((b, np.ones_like(b[0])))

In [132]:
lam = np.linalg.solve(A,b)

In [155]:
sol = (lam[:-1,:].T * Max['How'].values).sum(axis = 1)

In [161]:
plt.contour((grid[0,:], grid[1,:]), sol)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-161-1046a719e2b2> in <module>()
----> 1 plt.contour((grid[0,:], grid[1,:]), sol)

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py in contour(*args, **kwargs)
   2764         ax.hold(hold)
   2765     try:
-> 2766         ret = ax.contour(*args, **kwargs)
   2767     finally:
   2768         ax.hold(washold)

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
   1810                     warnings.warn(msg % (label_namer, func.__name__),
   1811                                   RuntimeWarning, stacklevel=2)
-> 1812             return func(ax, *args, **kwargs)
   1813         pre_doc = inner.__doc__
   1814         if pre_doc is None:

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py in contour(self, *args, **kwargs)
   5642             self.cla()
   5643         kwargs['filled'] = False
-> 5644         return mcontour.QuadContourSet(self, *args, **kwargs)
   5645     contour.__doc__ = mcontour.QuadContourSet.contour_doc
   5646 

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py in __init__(self, ax, *args, **kwargs)
   1422         are described in QuadContourSet.contour_doc.
   1423         """
-> 1424         ContourSet.__init__(self, ax, *args, **kwargs)
   1425 
   1426     def _process_args(self, *args, **kwargs):

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py in __init__(self, ax, *args, **kwargs)
    861         self._transform = kwargs.get('transform', None)
    862 
--> 863         self._process_args(*args, **kwargs)
    864         self._process_levels()
    865 

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py in _process_args(self, *args, **kwargs)
   1443                 self._corner_mask = mpl.rcParams['contour.corner_mask']
   1444 
-> 1445             x, y, z = self._contour_args(args, kwargs)
   1446 
   1447             _mask = ma.getmask(z)

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py in _contour_args(self, args, kwargs)
   1538             warnings.warn('Log scale: values of z <= 0 have been masked')
   1539             self.zmin = z.min()
-> 1540         self._contour_level_args(z, args)
   1541         return (x, y, z)
   1542 

/home/bl3/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py in _contour_level_args(self, z, args)
   1187                 warnings.warn("Contour levels are not increasing")
   1188             else:
-> 1189                 raise ValueError("Contour levels must be increasing")
   1190 
   1191     def _process_levels(self):

ValueError: Contour levels must be increasing

In [152]:
grid[0,:].shape


Out[152]:
(100,)

In [162]:
plt.contourf?

In [ ]: