<jupyter_start><jupyter_text>Normal Score Transform<jupyter_code>import sys
ppath = "../.."

if ppath not in sys.path:
    sys.path.append(ppath)

import pygeostatistics as pygs
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Read Spatial Data:<jupyter_code>from pygeostatistics.gslib_reader import SpatialData

data = SpatialData('../../testData/test.gslib')

print(data.df.shape)

vr = data.vr['por']
vr[:20]<jupyter_output>(85, 4)<jupyter_text>Setup Normal Score Transform:<jupyter_code>from pygeostatistics.normal_score_transform import NormalScoreTransform

nst = NormalScoreTransform(
    vr, np.ones_like(vr),
    0, 30,
    0, 1,
    15, 1)
nst.create_transform_func()<jupyter_output><empty_output><jupyter_text>Tranform Data to Normal Score (forward):<jupyter_code>normal_score = nst.transform(vr)

normal_score[:20]<jupyter_output><empty_output><jupyter_text>Transform Normal Score to Data (backward):<jupyter_code>vr_back = nst.back_transform(normal_score)

vr_back[:20]
fig, ax = plt.subplots()
sc = ax.scatter(vr, vr_back, zorder=10)
line, = ax.plot(np.arange(12,18), np.arange(12,18), linestyle='--', color='red', zorder=1)
info = ax.set( 
    xlabel='vr', ylabel='back_transformed', aspect=1, title="vr vs. back_transformed"
    )
fig.set(figwidth=6, figheight=6)
sup = fig.suptitle("Crossplot")<jupyter_output><empty_output><jupyter_text>Plot Data and their cumaltive histograms:<jupyter_code>fig, axes = plt.subplots(ncols=2, nrows=3)

freq = stats.cumfreq(vr, numbins=20)
x = freq.lowerlimit + np.linspace(
    0, freq.binsize*freq.cumcount.size, freq.cumcount.size)

axes[0][0].hist(vr, bins=20)
axes[0][0].set(title="Orginal Data")

axes[0][1].bar(x, freq.cumcount, width=freq.binsize)
axes[0][1].set(title="Cumulative Histogram")

freq2 = stats.cumfreq(normal_score, numbins=20)

x2 = freq2.lowerlimit + np.linspace(
    0, freq2.binsize*freq2.cumcount.size, freq2.cumcount.size)
axes[1][0].hist(normal_score, bins=20)
axes[1][0].set(title="Normal Score")

axes[1][1].bar(x2, freq2.cumcount, width=freq2.binsize)
axes[1][1].set(title="Cumulative Histogram")

freq3 = stats.cumfreq(vr_back, numbins=20)

x3 = freq3.lowerlimit + np.linspace(
    0, freq3.binsize*freq3.cumcount.size, freq3.cumcount.size)
axes[2][0].hist(vr_back, bins=20)
axes[2][0].set(title="Back-transformed Data")

axes[2][1].bar(x3, freq3.cumcount, width=freq3.binsize)
axes[2][1].set(title="Cumulative Histogram")

size = fig.set(figheight=8, figwidth=8)
plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1571150097465887, 'fraction_numerical': 0.03586744639376218, 'mean_word_length': 6.847094801223242, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '46249', 'license': 'MIT', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1029, 'n_words': 161, 'path': 'docs/tutorials/NST.ipynb', 'repo_name': 'wassemalward/pyGeoStatistics', 'size': '2565'}