cjohnson318/geostatsmodels

geoplot.semivariogram from example gives error

Opened this issue · 0 comments

Hello C Johnson,

I came across your interesting software today and immediately tried to run few examples. I followed the example from
http://nbviewer.jupyter.org/github/cjohnson318/geostatsmodels/blob/master/notebooks/VariogramAnalysis.ipynb

and my code is

import numpy as np
from pandas import DataFrame, Series
from geostatsmodels import utilities, kriging, variograms, model, geoplot
import matplotlib.pyplot as plt
from scipy.stats import norm


z = open('ZoneA.dat','r' ).readlines()
z = [ i.strip().split() for i in z[10:] ]
z = np.array( z, dtype=np.float )
z = DataFrame( z, columns=['x','y','thk','por','perm','lperm','lpermp','lpermr'] )
P = np.array( z[['x','y','por']] )

fig, ax = plt.subplots()
fig.set_size_inches(8,8)
cmap = geoplot.YPcmap
ax.scatter( z.x/1000, z.y/1000, c=z.por, s=64,cmap=cmap)
ax.set_aspect(1)
plt.xlim(-2,22)
plt.ylim(-2,17.5)

plt.xlabel('Easting [m]')
plt.ylabel('Northing [m]')
th=plt.title('Porosity %')

tolerance = 1000
lags = np.arange( tolerance, 10000, tolerance*2 )
sill = np.var(P[:,2])

pw = utilities.pairwise(P)
geoplot.hscattergram(P,pw,1000,500)

tolerance = 250
lags = np.arange( tolerance, 10000, tolerance*2 )
sill = np.var(P[:,2])

geoplot.semivariogram( P, lags, tolerance )

I use the same data as in the example. However, I am unable to get a plot of semivariogram and instead I get

Traceback (most recent call last):

  File "<ipython-input-51-b20e0e8f00c3>", line 1, in <module>
    runfile('C:/PYTHON/geostatistics/geo1.py', wdir='C:/PYTHON/geostatistics')

  File "C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/PYTHON/geostatistics/geo1.py", line 37, in <module>
    geoplot.semivariogram( P, lags, tolerance )

  File "C:\Anaconda\lib\site-packages\geostatsmodels\geoplot.py", line 82, in semivariogram
    h, sv = variograms.semivariogram( data, lags, tol )

TypeError: iteration over a 0-d array

Can you please help me to get over this issue ?