In [2]:
import sys, os
import matplotlib.pyplot as plt
import pynoddy.history
import pynoddy.output
import copy
import pickle
import scipy.stats
In [3]:
# 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/Florian/git/pynoddy/examples/')
In [4]:
print pynoddy.__file__
In [5]:
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 [6]:
import gipps_uncertainty
In [34]:
reload(gipps_uncertainty)
GU = gipps_uncertainty.GUncert(PH, 10, compute=False)
In [35]:
GU.load_all_models()
In [36]:
print GU.all_blocks.nbytes / 1E6
# pickle.dump(GU.all_blocks, open("all_blocks.pkl", "w"))
In [37]:
GU.calculate_entropy()
Save results and create VTK file for visualisations
In [38]:
pickle.dump(GU.entropy, open("GB_entropy.pkl", "w"))
GU.export_to_vtk(GU.entropy, "entropy")
In [40]:
modes, bins = scipy.stats.mode(GU.all_blocks)
bins = bins[0,:,:,:]
strat_var_1 = modes[0,:,:,:]
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 [44]:
strat_var_2 = 1. - bins / GU.n
strat_combined = strat_var_1 + strat_var_2
Save results and create VTK visualisations:
In [45]:
pickle.dump(strat_var_1, open("strat_modes.pkl", "w"))
pickle.dump(strat_var_2, open("strat_differs.pkl", "w"))
pickle.dump(strat_combined, open("strat_combined.pkl", "w"))
In [46]:
GU.export_to_vtk(strat_var_1, "strat_modes")
GU.export_to_vtk(strat_var_2, "strat_bins")
GU.export_to_vtk(strat_combined, "strat_combined")
In [84]:
In [146]:
a = np.array([1,3,1,2,3,5,1,2,5,12,3])
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 [ ]: