Skip to content

Commit

Permalink
Nscore transform with conditional points
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrofgr committed Jun 8, 2021
1 parent d8500fb commit 7abd3d3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Additional_examples/example_nscore_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# data
x = np.loadtxt('./Data/data1.dat')
reference_log = x[:,1].reshape(-1, 1)
n_ptos = reference_log.shape[0]

# NSCORE TRANSFORMATION - Transform th non-parametric reference log/data to a Gaussian distributed varible
referencelog_uniform = NonParametricToUniform(reference_log, reference_log)
Expand All @@ -27,12 +28,20 @@
axs[2].hist(referencelog_gaussian[:,0], bins=15)

# NSCORE BACK TRANSFORMATION - Sequential Gaussian Simulation of a non-parametric distribution
xcoords = np.arange(reference_log.shape[0]).reshape((reference_log.shape[0],1))
cond_depth = np.array([]).reshape((0,1))
cond_values = np.array([]).reshape((0,1))
xcoords = np.arange(reference_log.shape[0]).reshape((reference_log.shape[0],1))

n_ptos_cond = 20;
dcoords = np.random.choice(n_ptos, n_ptos_cond ,replace=False).reshape((n_ptos_cond,1))
cond_depth = xcoords[dcoords].reshape((n_ptos_cond,1))
cond_values = reference_log[dcoords].reshape((n_ptos_cond,1))

# Transform conditional points from non parametric to uniform
cond_values_uniform = NonParametricToUniform(cond_values, reference_log)
cond_values_gaussian = norm.ppf(cond_values_uniform)


# Simulate a Gaussian simulation with zero mean and std 1
simulation_gaussian = SeqGaussianSimulation(xcoords, cond_depth, cond_values, 0.0, 1.0, 10.0, 'exp', 0)
simulation_gaussian = SeqGaussianSimulation(xcoords, cond_depth, cond_values_gaussian, 0.0, 1.0, 20.0, 'sph', 0)
# Transform from Gaussian to uniform
simulation_uniform = norm.cdf(simulation_gaussian)
# Then, transform from uniform to target non parametric distribution
Expand All @@ -44,6 +53,11 @@
plt.plot(simulation_uniform)
plt.plot(simulation_non_parametric)

plt.figure()
plt.plot(xcoords,reference_log)
plt.plot(xcoords,simulation_non_parametric)
plt.plot(cond_depth,cond_values,'o')

fig, axs = plt.subplots(1, 3)
axs[0].hist(simulation_gaussian[:,0], bins=15)
axs[1].hist(simulation_uniform[:,0], bins=15)
Expand Down

0 comments on commit 7abd3d3

Please sign in to comment.