In [1]:
import sys, os
import matplotlib.pyplot as plt
import pynoddy.history
import pynoddy.output
import copy
import pickle
import scipy.stats
In [2]:
# os.chdir(r"/Users/Florian/Documents/10_Geomodels/Noddy/GBasin/GBasin")
# os.chdir(r"/Users/flow/Documents/02_work/10_Geomodels/06_Noddy/GBasin")
os.chdir(r'/Users/flow/git/pynoddy/examples/')
In [3]:
print pynoddy.__file__
In [4]:
reload(pynoddy.history)
reload(pynoddy.events)
his = "GBasi123.his"
PH = pynoddy.history.NoddyHistory(his)
out = 'GBasin_out'
pynoddy.compute_model(his, out)
print os.getcwd()
PO = pynoddy.output.NoddyOutput(out)
In [5]:
ls
In [6]:
PH.events[5].properties
Out[6]:
In [7]:
import gipps_uncertainty
In [10]:
reload(gipps_uncertainty)
GU = gipps_uncertainty.GUncert(PH, 1000, compute=False)
In [11]:
GU.load_all_models()
In [12]:
print GU.all_blocks.nbytes / 1E6
# pickle.dump(GU.all_blocks, open("all_blocks.pkl", "w"))
In [71]:
GU.calculate_entropy()
Save results and create VTK file for visualisations
In [72]:
pickle.dump(GU.entropy, open("GB_entropy_high.pkl", "w"))
GU.export_to_vtk(GU.entropy, "entropy_high")
In [11]:
modes, bins = scipy.stats.mode(GU.all_blocks)
bins = bins[0,:,:,:]
strat_var_1 = modes[0,:,:,:]
Actually, the correct way is to determine the number of unique values for stratigraphic variability! So: determine the number of unique elements (i.e. possible outputs) in each cell and combine with probability of mode, with bins calculated above:
In [22]:
s = bins.shape
strat_var_new = np.ndarray((s))
for i in range(s[0]):
for j in range(s[1]):
for k in range(s[2]):
strat_var_new[i,j,k] = len(np.unique(GU.all_blocks[:,i,j,k]))
Thankfully, the second return value from the mode function is actually the bin count of the modal value, so exactly what we need for the second part of the stratigraphic variability function:
In [23]:
strat_var_2 = 1. - bins / GU.n
strat_combined = strat_var_new + strat_var_2
Save results and create VTK visualisations:
In [24]:
pickle.dump(strat_var_1, open("strat_num_high.pkl", "w"))
pickle.dump(strat_var_2, open("strat_differs_high.pkl", "w"))
pickle.dump(strat_combined, open("strat_combined_high.pkl", "w"))
In [25]:
GU.export_to_vtk(strat_var_new, "strat_num_high")
GU.export_to_vtk(strat_var_2, "strat_bins_high")
GU.export_to_vtk(strat_combined, "strat_combined_high")
In [13]:
# Extract slice for information theory analysis
GU_slice = GU.all_blocks[:,0,:,:]
pickle.dump(GU_slice, open("Gippsland_x_slice.pkl", "w"))
GU_y_slice = GU.all_blocks[:,:,0,:]
pickle.dump(GU_y_slice, open("Gippsland_y_slice.pkl", "w"))
In [14]:
pwd
Out[14]:
In [125]:
print a
print np.sort(a)
print np.argsort(a)
print "----"
print np.unique(a)
print np.argmax(np.unique(np.sort(a)))
In [187]:
a_sort = np.sort(a)
print a_sort
In [160]:
np.where(a_sort[:-1] != a_sort[1:])
n = float(len(a))
In [197]:
a = np.random.randint(0,3,size=(300,4))
b = [np.sum(a == id_a, axis=0) / 300. for id_a in np.unique(a)]
In [198]:
b
Out[198]:
In [190]:
b
Out[190]:
In [165]:
In [53]:
2**2 + 2**1 + 2**(-2) + 2**(-3)
Out[53]:
In [62]:
def own_sqrt(x):
s = 1.
for k in range(4):
s = 0.5 * (s + x/s)
print s
return s
In [63]:
own_sqrt(2.)
Out[63]:
In [64]:
pynoddy?
In [70]:
cd ~/git/pynoddy/examples/
In [71]:
NH = pynoddy.NoddyHistory("GBasi123.his")
In [118]:
run gipps_uncertainty
In [89]:
for event in NH.events:
print NH.events[event]
In [97]:
NH.events[2].event_type
Out[97]:
In [93]:
type(NH.events)
Out[93]:
In [116]:
NH.events
Out[116]:
In [107]:
np.mod(101,10)
Out[107]:
In [115]:
a = (1,2,3)
print np.random.choice(a, size = 3, replace=False)
In [ ]: