In [1]:
#general imports
import matplotlib.pyplot as plt
import pygslib
#make the plots inline
%matplotlib inline
You can use Pandas to import your data from csv, execel, sql database, json, html, among others. If the data is in GSLIB format you can use the function gslib.read_gslib_file(filename)
to import the data into a Pandas DataFrame.
In [3]:
# To put the GSLIB file into a Pandas DataFrame
mydata= pygslib.gslib.read_gslib_file(u'../datasets/true.dat')
In [5]:
# This is a 2D grid file with two variables
# To add a dummy variable BHID = 1 use this code
mydata['bhid']=1
# printing to verify results
print (' \n **** 5 first rows in my datafile **** \n\n ', mydata.tail(n=5))
In [6]:
# GSLIB grids have not coordinates
# To add coordinates use addcoord function
#first prepare a parameter file
par= { 'nx' : 50,
'ny' : 50,
'nz' : 1,
'xmn' : 0.5,
'ymn' : 0.5,
'zmn' : 1,
'xsiz': 1,
'ysiz': 1,
'zsiz': 10,
'grid': mydata }
# then run the function
mydataxyz=pygslib.gslib.addcoord(**par)
# this is to see the output
mydataxyz
Out[6]:
In [7]:
# Now we can plot the centroids of the cells
plt.plot(mydataxyz['x'],mydataxyz['y'], '+')
Out[7]:
In [ ]: